Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise populating a SparqlService from different input sources #3

Open
psiotwo opened this issue Oct 31, 2024 · 2 comments
Open

Revise populating a SparqlService from different input sources #3

psiotwo opened this issue Oct 31, 2024 · 2 comments

Comments

@psiotwo
Copy link
Collaborator

psiotwo commented Oct 31, 2024

Currently, the class allows to:

  • execute a SPARQL update query - executeUpdateQuery
  • upload a TTL file - uploadTtlFile
  • update/replace Graph - upload/updateGraph/

The goal is to unify the update/replace mechanism for both named/default graphs from file/SPARQL/Model/...
(cc @natan-cox-cognizone)

@psiotwo
Copy link
Collaborator Author

psiotwo commented Nov 17, 2024

Here I would suggest to deprecate uploadTtlFile and introduce the following methods instead:

  /**
   * Adds the triples in the file into the graph:
   * Note: In case the file contains quads, the graph information is ignored, and they are added as triples to the designated graph.
   *
   * @param graphIri IRI of graph being updated, or null if the default graph shall be used
   * @param file     file to replace the graph with.
   */
  void updateGraph(String graphIri, File file);

  /**
   * Adds the quads in the file into the graph:
   * Note: In case the file is a triple format not a quad format, an exception is thrown.
   *
   * @param file     file to replace the dataset with.
   */
  void update(File file);

  /**
   * Replaces the given graph with triples in the file:
   * Note: In case the file contains quads, the graph information is ignored, and they are added as triples to the designated graph.
   *
   * @param graphIri IRI of graph being updated, or null if the default graph shall be used
   * @param file     file to replace the graph with.
   */
  void replaceGraph(String graphIri, File file);


  /**
   * Replaces the data with quads in the file:
   * Note: In case the file is a triple format not a quad format, an exception is thrown.
   *
   * @param file     file to replace the dataset with.
   */
  void replace(File file);

}

What do you think @alexey-lukashov @natan-cox-cognizone?

@natan-cox-cognizone
Copy link

I think update with File does not make a lot of sense. Assume you have a file, the it will typically be the full file, not just the new triples. So, doing it is a bit weird.

Thinking a bit more an update is seldom purely additive. So, I think if we would do update we would need something like

void update(String graphUri, Supplier<Model> addedTriples, Supplier<Model> removedTriples)

Where you can add and remove triples. There could be a method for add only I guess by dropping the last parameter.

Finally, I am not a big fan of File in general. There are probably other resources too (spring Resource?). Or possible even more generic Supplier<Model> as I did in my example.

So

void replaceGraph(String graphIri, Supplier<Model> modelSupplier);

void replaceGraph(String graphIri, Model model);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants