12
12
import fr .inria .corese .command .utils .ConvertString ;
13
13
import fr .inria .corese .command .utils .InputTypeDetector ;
14
14
import fr .inria .corese .command .utils .InputTypeDetector .InputType ;
15
- import fr .inria .corese .core .Graph ;
15
+
16
+ import fr .inria .corese .command .utils .coreseCoreWrapper .RDFLoaderWrapper ;
16
17
import fr .inria .corese .core .load .Load ;
17
- import fr .inria .corese .core .load .LoadFormat ;
18
+ import fr .inria .corese .command .utils .coreseCoreWrapper .GraphWrapper ;
19
+ import fr .inria .corese .core .Graph ;
20
+
18
21
import picocli .CommandLine .Model .CommandSpec ;
19
22
20
23
/**
@@ -64,15 +67,15 @@ public Graph load(String[] inputs, EnumRdfInputFormat inputFormat, boolean recur
64
67
return this .LoadFromStdin (inputFormat );
65
68
}
66
69
67
- Graph graph = Graph . create ();
70
+ Graph graph = GraphWrapper . createGraph ();
68
71
69
72
for (String input : inputs ) {
70
73
InputType type = InputTypeDetector .detect (input );
71
74
72
75
switch (type ) {
73
76
case URL :
74
77
Graph resultGraphUrl = this .loadFromURL (ConvertString .toUrlOrThrow (input ), inputFormat );
75
- graph . merge ( resultGraphUrl );
78
+ GraphWrapper . mergeGraph ( graph , resultGraphUrl );
76
79
break ;
77
80
78
81
case FILE_PATH :
@@ -85,7 +88,7 @@ public Graph load(String[] inputs, EnumRdfInputFormat inputFormat, boolean recur
85
88
} else {
86
89
resultGraph = this .loadFromFile (path , inputFormat );
87
90
}
88
- graph . merge ( resultGraph );
91
+ GraphWrapper . mergeGraph ( graph , resultGraph );
89
92
break ;
90
93
91
94
default :
@@ -200,7 +203,7 @@ private void loadFromDirectoryRecursive(Path path, EnumRdfInputFormat inputForma
200
203
this .loadFromDirectoryRecursive (childFile .toPath (), inputFormat , recursive , graph );
201
204
} else if (childFile .isFile ()) {
202
205
Graph resultGraph = this .loadFromFile (childFile .toPath (), inputFormat );
203
- graph . merge ( resultGraph );
206
+ GraphWrapper . mergeGraph ( graph , resultGraph );
204
207
}
205
208
}
206
209
}
@@ -215,7 +218,7 @@ private void loadFromDirectoryRecursive(Path path, EnumRdfInputFormat inputForma
215
218
* @return The Corese Graph containing the RDF data.
216
219
*/
217
220
private Graph loadFromDirectory (Path path , EnumRdfInputFormat inputFormat , boolean recursive ) {
218
- Graph graph = Graph . create ();
221
+ Graph graph = GraphWrapper . createGraph ();
219
222
this .loadFromDirectoryRecursive (path , inputFormat , recursive , graph );
220
223
221
224
if (this .verbose ) {
@@ -233,21 +236,21 @@ private Graph loadFromDirectory(Path path, EnumRdfInputFormat inputFormat, boole
233
236
*/
234
237
private Graph loadFromInputStream (InputStream inputStream , EnumRdfInputFormat inputFormat ) {
235
238
236
- Graph graph = Graph .create ();
237
- Load load = Load .create (graph );
238
-
239
239
if (inputFormat == null ) {
240
240
throw new IllegalArgumentException (
241
241
"The input format cannot be automatically determined if you use standard input or na URL. "
242
242
+ "Please specify the input format with the option -f." );
243
- } else {
244
- try {
245
- load .parse (inputStream , inputFormat .getCoreseFormat ());
246
- return graph ;
247
- } catch (Exception e ) {
248
- throw new IllegalArgumentException ("Failed to parse RDF file. Check if file is well-formed and that "
249
- + "the input format is correct. " + e .getMessage (), e );
250
- }
243
+ }
244
+
245
+ Graph graph = GraphWrapper .createGraph ();
246
+ Load load = RDFLoaderWrapper .graphLoader (graph );
247
+
248
+ try {
249
+ RDFLoaderWrapper .parse ( load , inputStream , inputFormat .getCoreseFormat ());
250
+ return graph ;
251
+ } catch (Exception e ) {
252
+ throw new IllegalArgumentException ("Failed to parse RDF file. Check if file is well-formed and that "
253
+ + "the input format is correct. " + e .getMessage (), e );
251
254
}
252
255
}
253
256
@@ -259,7 +262,7 @@ private Graph loadFromInputStream(InputStream inputStream, EnumRdfInputFormat in
259
262
*/
260
263
private Optional <EnumRdfInputFormat > guessInputFormat (String input ) {
261
264
262
- EnumRdfInputFormat inputFormat = EnumRdfInputFormat .create (LoadFormat . getFormat (input ));
265
+ EnumRdfInputFormat inputFormat = EnumRdfInputFormat .create ( RDFLoaderWrapper . getLoadFormat (input ));
263
266
264
267
if (inputFormat == null ) {
265
268
if (this .verbose ) {
0 commit comments