@@ -38,7 +38,9 @@ use crate::datakey::DataKeyHandle;
38
38
use crate :: error:: * ;
39
39
use crate :: file:: * ;
40
40
use crate :: json:: { FromJson , ToJson } ;
41
- use crate :: resources:: { DeserializeTextResource , TextResource , TextResourceHandle } ;
41
+ use crate :: resources:: {
42
+ DeserializeTextResource , TextResource , TextResourceBuilder , TextResourceHandle ,
43
+ } ;
42
44
use crate :: selector:: { Offset , OffsetMode , Selector , SelectorBuilder } ;
43
45
use crate :: store:: * ;
44
46
use crate :: substore:: { AnnotationSubStore , AnnotationSubStoreHandle } ;
@@ -59,11 +61,10 @@ use crate::types::*;
59
61
/// # fn main() -> Result<(),StamError> {
60
62
/// let store = AnnotationStore::default()
61
63
/// .with_id("example")
62
- /// .add(TextResource::from_string(
63
- /// "myresource",
64
- /// "Hello world",
65
- /// Config::default(),
66
- /// ))?
64
+ /// .with_resource(TextResourceBuilder::new()
65
+ /// .with_id("myresource")
66
+ /// .with_text("Hello world")
67
+ /// )?
67
68
/// .add(AnnotationDataSet::new(Config::default()).with_id("mydataset"))?
68
69
/// .with_annotation(
69
70
/// AnnotationBuilder::new()
@@ -86,11 +87,10 @@ use crate::types::*;
86
87
/// # fn main() -> Result<(),StamError> {
87
88
/// let store = AnnotationStore::new(Config::default())
88
89
/// .with_id("example")
89
- /// .add (
90
+ /// .with_resource (
90
91
/// TextResourceBuilder::new()
91
92
/// .with_id("myresource")
92
93
/// .with_text("Hello world")
93
- /// .build()?,
94
94
/// )?
95
95
/// .add(
96
96
/// AnnotationDataSet::new(Config::default())
@@ -268,7 +268,7 @@ impl private::StoreCallbacks<TextResource> for AnnotationStore {
268
268
/// parameters from parent to the item
269
269
#[ allow( unused_variables) ]
270
270
fn preinsert ( & self , item : & mut TextResource ) -> Result < ( ) , StamError > {
271
- item. set_config ( self . new_config ( ) ) ;
271
+ item. initialize ( self ) ;
272
272
Ok ( ( ) )
273
273
}
274
274
@@ -1004,7 +1004,7 @@ impl AnnotationStore {
1004
1004
1005
1005
/// Returns a [`Config`] instance suitable for instantiation of dependent instances like TextResource,AnnotationDataSet and
1006
1006
/// This will have the working directory set to the annotation store's directory
1007
- pub fn new_config ( & self ) -> Config {
1007
+ pub ( crate ) fn new_config ( & self ) -> Config {
1008
1008
debug ( & self . config ( ) , || format ! ( "AnnotationStore::new_config" ) ) ;
1009
1009
let mut config = self . config ( ) . clone ( ) ;
1010
1010
config. workdir = self . dirname ( ) ;
@@ -1348,18 +1348,9 @@ impl AnnotationStore {
1348
1348
self
1349
1349
}
1350
1350
1351
- /// Shortcut method to load a resource from file and add it to the store. Returns a handle,
1352
- /// wrap it in a call to `self.resource()` to get the resource itself.
1353
- pub fn add_resource_from_file (
1354
- & mut self ,
1355
- filename : & str ,
1356
- ) -> Result < TextResourceHandle , StamError > {
1357
- let resource = TextResource :: from_file ( filename, self . new_config ( ) ) ?;
1358
- self . insert ( resource)
1359
- }
1360
-
1361
1351
/// Shortcut method to load a dataset from file and add it to the store. Returns a handle,
1362
1352
/// wrap it in a call to `self.dataset()` to get the resource itself.
1353
+ //TODO: REMOTE THIS, obsolete once we have add_dataset()
1363
1354
pub fn add_dataset_from_file (
1364
1355
& mut self ,
1365
1356
filename : & str ,
0 commit comments