1212import fr .inria .corese .command .utils .ConvertString ;
1313import fr .inria .corese .command .utils .InputTypeDetector ;
1414import fr .inria .corese .command .utils .InputTypeDetector .InputType ;
15- import fr .inria .corese .core .Graph ;
15+
16+ import fr .inria .corese .command .utils .coreseCoreWrapper .RDFLoaderWrapper ;
1617import 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+
1821import picocli .CommandLine .Model .CommandSpec ;
1922
2023/**
@@ -64,15 +67,15 @@ public Graph load(String[] inputs, EnumRdfInputFormat inputFormat, boolean recur
6467 return this .LoadFromStdin (inputFormat );
6568 }
6669
67- Graph graph = Graph . create ();
70+ Graph graph = GraphWrapper . createGraph ();
6871
6972 for (String input : inputs ) {
7073 InputType type = InputTypeDetector .detect (input );
7174
7275 switch (type ) {
7376 case URL :
7477 Graph resultGraphUrl = this .loadFromURL (ConvertString .toUrlOrThrow (input ), inputFormat );
75- graph . merge ( resultGraphUrl );
78+ GraphWrapper . mergeGraph ( graph , resultGraphUrl );
7679 break ;
7780
7881 case FILE_PATH :
@@ -85,7 +88,7 @@ public Graph load(String[] inputs, EnumRdfInputFormat inputFormat, boolean recur
8588 } else {
8689 resultGraph = this .loadFromFile (path , inputFormat );
8790 }
88- graph . merge ( resultGraph );
91+ GraphWrapper . mergeGraph ( graph , resultGraph );
8992 break ;
9093
9194 default :
@@ -200,7 +203,7 @@ private void loadFromDirectoryRecursive(Path path, EnumRdfInputFormat inputForma
200203 this .loadFromDirectoryRecursive (childFile .toPath (), inputFormat , recursive , graph );
201204 } else if (childFile .isFile ()) {
202205 Graph resultGraph = this .loadFromFile (childFile .toPath (), inputFormat );
203- graph . merge ( resultGraph );
206+ GraphWrapper . mergeGraph ( graph , resultGraph );
204207 }
205208 }
206209 }
@@ -215,7 +218,7 @@ private void loadFromDirectoryRecursive(Path path, EnumRdfInputFormat inputForma
215218 * @return The Corese Graph containing the RDF data.
216219 */
217220 private Graph loadFromDirectory (Path path , EnumRdfInputFormat inputFormat , boolean recursive ) {
218- Graph graph = Graph . create ();
221+ Graph graph = GraphWrapper . createGraph ();
219222 this .loadFromDirectoryRecursive (path , inputFormat , recursive , graph );
220223
221224 if (this .verbose ) {
@@ -233,21 +236,21 @@ private Graph loadFromDirectory(Path path, EnumRdfInputFormat inputFormat, boole
233236 */
234237 private Graph loadFromInputStream (InputStream inputStream , EnumRdfInputFormat inputFormat ) {
235238
236- Graph graph = Graph .create ();
237- Load load = Load .create (graph );
238-
239239 if (inputFormat == null ) {
240240 throw new IllegalArgumentException (
241241 "The input format cannot be automatically determined if you use standard input or na URL. "
242242 + "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 );
251254 }
252255 }
253256
@@ -259,7 +262,7 @@ private Graph loadFromInputStream(InputStream inputStream, EnumRdfInputFormat in
259262 */
260263 private Optional <EnumRdfInputFormat > guessInputFormat (String input ) {
261264
262- EnumRdfInputFormat inputFormat = EnumRdfInputFormat .create (LoadFormat . getFormat (input ));
265+ EnumRdfInputFormat inputFormat = EnumRdfInputFormat .create ( RDFLoaderWrapper . getLoadFormat (input ));
263266
264267 if (inputFormat == null ) {
265268 if (this .verbose ) {
0 commit comments