Package org.hobbit.storage.queries
Class SparqlQueries
java.lang.Object
org.hobbit.storage.queries.SparqlQueries
This class provides static SPRAQL queries that are loaded from predefined
resources.
- Author:
- Michael Röder (roeder@informatik.uni-leipzig.de)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final String[]An update query that cleans up the graph of containing challenges.private static final StringDeprecated.private static final String[]An update query that cleans up the graph of containing challenges.private static final StringAn update query that closes a challenge.private static final StringA select query for counting the number of experiments of a challenge task.private static final StringA construct query that selects the subgraph of a challenge task that defines an experiment of this task.private static final StringAn update query that changes next execution date for a repeatable challenge.private static final intDefault value of the maximum triples a single update query should have.private static final StringA construct query for getting the analysis results of all systems for a certain benchmark.private static final StringAn update query that deletes the graph of a challenge.private static final StringAn update query that deletes the graph of an experiment.private static final org.apache.jena.rdf.model.ModelAn empty RDF model instance.private static final Stringprivate static final Stringprivate static final StringA construct query for getting the analysis results of all systems for a certain benchmark.private static final StringA construct query that retrieves the graph of a challenge.private static final StringA construct query that retrieves the graph of a challenge.private static final StringA construct query for getting the organizer of the challenge two which a given challenge tasks belong to.private static final StringA construct query that retrieves the tasks of a challenge.private static final StringA construct query that selects the graph of an experiment that is part of a given challenge task.private static final StringA construct query that selects the graph of an experiment that is part of a given challenge task.private static final StringA construct query that selects the graph of an experiment.private static final StringA construct query for getting the licensing data of the specified dataset.private static final StringA construct query that retrieves the graph of a repeatable challenge.private static final StringA construct query that retrieves a shallow of a challenge.private static final StringA construct query that selects a shallow graph of an experiment.private static final Stringprivate static final org.slf4j.Loggerprivate static final StringAn update query that moves involvesSystem triples between graphs.private static final Stringprivate static final Stringprivate static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final String[]cleanUpChallengeGraphQueries(String graphUri) Returns a SPARQL update query for cleaning up the graph of a challenge configs.static final StringcleanUpChallengeGraphQuery(String graphUri) Deprecated.A single large query does not seem to be supported by all triple stores.static final String[]cleanUpPrivateGraphQueries(String graphUri) Returns a SPARQL update query for cleaning up the private result graph.static final StringcountExperimentsOfTaskQuery(String challengeTaskUri, String graphUri) Returns a SPARQL query for counting the number of experiments of a challenge task.static final StringdeleteAnalysisResults(String analysisResultSetUri, String graphUri) Returns a SPARQL DELETE query for removing the analysis results set with the given URI.static final StringdeleteChallengeGraphQuery(String challengeUri, String graphUri) Returns a SPARQL update query for deleting the graph of a challenge.static final StringdeleteExperimentGraphQuery(String experimentUri, String graphUri) Returns a SPARQL update query for deleting the graph of an experiment.private static final StringextendQuery(String query, String target, String extension) Extends a SPARQL query by inserting specified extension string every time a target string is found.static final StringgetAnalysisResultsOfBenchmark(String benchmarkUri, String graphUri) Returns a SPARQL CONSTRUCT query for getting the analysis results of all systems for a certain benchmark.static final StringgetChallengeGraphQuery(String challengeUri, String graphUri) Returns a SPARQL query for retrieving the graph of a challenge.static final StringgetChallengePublishInfoQuery(String challengeUri, String graphUri) Returns a SPARQL query for retrieving a graph comprising the task URIs and the publication date of a challenge if this challenge is closed.static final StringgetChallengeTaskOrganizer(String challengeTaskUri, String graphUri) Returns a SPARQL CONSTRUCT query for getting the organizer of the challenge two which a given challenge tasks belong to.static final StringgetChallengeTasksQuery(String challengeUri, String graphUri) Returns a SPARQL query for retrieving the tasks of a challenge.static final StringgetCloseChallengeQuery(String challengeUri, String graphUri) Returns a SPARQL query for adding the closed triple to the challenge with the given URI.static final StringgetCreateExperimentFromTaskQuery(String experimentUri, String challengeTaskUri, String systemUri, String graphUri) Returns a SPARQL query for creating a subgraph of a challenge task that defines an experiment of this task.static final StringgetExperimentGraphOfBenchmarkQuery(String benchmarkUri, String graphUri) Returns a SPARQL query for retrieving the graphs of experiments that involve the given benchmark.static final StringgetExperimentGraphOfBenchmarksQuery(List<String> benchmarkUris, String graphUri) Returns a SPARQL query for retrieving the graphs of experiments that involve one of the given benchmarks.static final StringgetExperimentGraphOfSystemsQuery(List<String> systemUris, String graphUri) Returns a SPARQL query for retrieving the graphs of experiments that involve one of the given systems.static final StringgetExperimentGraphQuery(String experimentUri, String graphUri) Returns a SPARQL query for retrieving the graph of an experiment.static final StringgetExperimentOfTaskQuery(String experimentUri, String challengeTaskUri, String graphUri) Returns a SPARQL query for retrieving the graph of an experiment that is part of the given challenge task.static final StringgetLicenseOfDataset(String graphUri) Returns a SPARQL CONSTRUCT query for getting the analysis results of all systems for a certain benchmark.static final StringgetMoveChallengeSystemQuery(String challengeUri, String graphUri, String newGraphUri) Returns a SPARQL query for moving involvesSystem triples between graphs for a challenge with given URI.static final StringgetRepeatableChallengeInfoQuery(String challengeUri, String graphUri) Returns a SPARQL query for retrieving a graph comprising repeatable challenge properties if this challenge is closed.static final StringgetShallowChallengeGraphQuery(String challengeUri, String graphUri) Returns a SPARQL query for retrieving a shallow graph of a challenge.static final StringgetShallowExperimentGraphQuery(String experimentUri, String graphUri) Returns a SPARQL query for retrieving a shallow graph of an experiment containing the links to the system instance, the benchmark and the challenge task and the labels of them.static final StringgetUpdateDateOfNextExecutionQuery(String challengeUri, Calendar newValue, String graphUri) Returns a SPARQL query for updating the date of next execution for a repeatable challenge with given URI.static final String[]getUpdateQueriesFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri) Generates one or several SPARQL UPDATE queries based on the differences between the two given models.static final String[]getUpdateQueriesFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri, int maxTriplesPerQuery) Generates one or several SPARQL UPDATE queries based on the differences between the two given models.static final StringgetUpdateQueryFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri) Generates a SPARQL UPDATE query based on the differences between the two given models.static final StringgetUpdateQueryFromStatements(List<org.apache.jena.rdf.model.Statement> deleted, List<org.apache.jena.rdf.model.Statement> inserted, org.apache.jena.shared.PrefixMapping mapping, String graphUri) Generates a SPARQL UPDATE query based on the given list of statements that should be deleted and that should be added in the graph with the given URI.private static final StringLoads the given resource, e.g., a SPARQL query, as String.private static final StringreplacePlaceholders(String query, String[] placeholders, String[] replacements) Replaces the given placeholders in the given query with the given replacements.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
ANALYSIS_RESULT_SET_PLACEHOLDER
- See Also:
-
BENCHMARK_PLACEHOLDER
- See Also:
-
CHALLENGE_PLACEHOLDER
- See Also:
-
CHALLENGE_TASK_PLACEHOLDER
- See Also:
-
EXPERIMENT_PLACEHOLDER
- See Also:
-
GRAPH_PLACEHOLDER
- See Also:
-
NEW_GRAPH_PLACEHOLDER
- See Also:
-
SYSTEM_PLACEHOLDER
- See Also:
-
VALUE_PLACEHOLDER
- See Also:
-
DEFAULT_MAX_UPDATE_QUERY_TRIPLES
private static final int DEFAULT_MAX_UPDATE_QUERY_TRIPLESDefault value of the maximum triples a single update query should have.- See Also:
-
EMPTY_MODEL
private static final org.apache.jena.rdf.model.Model EMPTY_MODELAn empty RDF model instance. -
EXPERIMENT_SELECTION
- See Also:
-
GET_LICENSE_OF_DATASET
A construct query for getting the licensing data of the specified dataset. -
GET_ANALYSIS_RESULTS_OF_BENCHMARK
A construct query for getting the analysis results of all systems for a certain benchmark. -
DELETE_ANALYSIS_RESULTS
A construct query for getting the analysis results of all systems for a certain benchmark. -
GET_CHALLENGE_GRAPH_QUERY
A construct query that retrieves the graph of a challenge. -
GET_SHALLOW_CHALLENGE_GRAPH_QUERY
A construct query that retrieves a shallow of a challenge. -
GET_CHALLENGE_TASKS_QUERY
A construct query that retrieves the tasks of a challenge. -
GET_CHALLENGE_PUBLISH_INFO_QUERY
A construct query that retrieves the graph of a challenge. -
GET_REPEATABLE_CHALLENGE_INFO_QUERY
A construct query that retrieves the graph of a repeatable challenge. -
CLOSE_CHALLENGE_UPDATE_QUERY
An update query that closes a challenge. -
DATE_OF_NEXT_EXECUTION_UPDATE_QUERY
An update query that changes next execution date for a repeatable challenge. -
MOVE_CHALLENGE_SYSTEM_QUERY
An update query that moves involvesSystem triples between graphs. -
GET_EXPERIMENT_QUERY
A construct query that selects the graph of an experiment. -
GET_SHALLOW_EXPERIMENT_QUERY
A construct query that selects a shallow graph of an experiment. -
GET_EXPERIMENT_OF_BENCHMARK_QUERY
A construct query that selects the graph of an experiment that is part of a given challenge task. -
GET_EXPERIMENT_OF_TASK_QUERY
A construct query that selects the graph of an experiment that is part of a given challenge task. -
CREATE_EXPERIMENT_FROM_CHALLENGE_TASK
A construct query that selects the subgraph of a challenge task that defines an experiment of this task. -
DELETE_EXPERIMENT_GRAPH_QUERY
An update query that deletes the graph of an experiment. -
DELETE_CHALLENGE_GRAPH_QUERY
An update query that deletes the graph of a challenge. -
CLEAN_UP_CHALLENGE_GRAPH_QUERY
Deprecated.An update query that cleans up the graph of containing challenges. -
CLEAN_UP_CHALLENGE_GRAPH_QUERIES
An update query that cleans up the graph of containing challenges. -
CLEAN_UP_PRIVATE_GRAPH_QUERIES
An update query that cleans up the graph of containing challenges. -
COUNT_EXP_OF_TASK_QUERY
A select query for counting the number of experiments of a challenge task. -
GET_CHALLENGE_TASK_ORGANIZER
A construct query for getting the organizer of the challenge two which a given challenge tasks belong to.
-
-
Constructor Details
-
SparqlQueries
public SparqlQueries()
-
-
Method Details
-
loadQuery
Loads the given resource, e.g., a SPARQL query, as String.- Parameters:
resourceName- name of the resource that should be loaded- Returns:
- the resource as String or
nullif an error occurs
-
getLicenseOfDataset
Returns a SPARQL CONSTRUCT query for getting the analysis results of all systems for a certain benchmark.- Parameters:
graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL CONSTRUCT query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getAnalysisResultsOfBenchmark
Returns a SPARQL CONSTRUCT query for getting the analysis results of all systems for a certain benchmark.- Parameters:
benchmarkUri- URI of the benchmarkgraphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL CONSTRUCT query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
deleteAnalysisResults
Returns a SPARQL DELETE query for removing the analysis results set with the given URI.- Parameters:
analysisResultSetUri- URI of the analysis result set which should be removedgraphUri- URI of the graph the analysis result set is stored.- Returns:
- the SPARQL DELETE query that performs the removal or
nullif the query hasn't been loaded correctly
-
getChallengeGraphQuery
Returns a SPARQL query for retrieving the graph of a challenge.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getShallowChallengeGraphQuery
Returns a SPARQL query for retrieving a shallow graph of a challenge.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getChallengeTasksQuery
Returns a SPARQL query for retrieving the tasks of a challenge.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getChallengePublishInfoQuery
Returns a SPARQL query for retrieving a graph comprising the task URIs and the publication date of a challenge if this challenge is closed.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getRepeatableChallengeInfoQuery
Returns a SPARQL query for retrieving a graph comprising repeatable challenge properties if this challenge is closed.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getCloseChallengeQuery
Returns a SPARQL query for adding the closed triple to the challenge with the given URI.- Parameters:
challengeUri- URI of the challenge that should be closed.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL update query that performs the insertion or
nullif the query hasn't been loaded correctly
-
getUpdateDateOfNextExecutionQuery
public static final String getUpdateDateOfNextExecutionQuery(String challengeUri, Calendar newValue, String graphUri) Returns a SPARQL query for updating the date of next execution for a repeatable challenge with given URI.- Parameters:
challengeUri- URI of the challenge that should be updated.nullworks like a wildcard.newValue- New value for date of next execution.nullto remove the value.graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL update query that performs the insertion or
nullif the query hasn't been loaded correctly
-
getMoveChallengeSystemQuery
public static final String getMoveChallengeSystemQuery(String challengeUri, String graphUri, String newGraphUri) Returns a SPARQL query for moving involvesSystem triples between graphs for a challenge with given URI.- Parameters:
challengeUri- URI of the challenge that should be updated.nullworks like a wildcard.graphUri- URI of the challenge definition graph.newGraphUri- URI of the public data graph.- Returns:
- the SPARQL update query that performs the operation or
nullif the query hasn't been loaded correctly
-
getExperimentGraphQuery
Returns a SPARQL query for retrieving the graph of an experiment.- Parameters:
experimentUri- URI of the experiment that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getShallowExperimentGraphQuery
Returns a SPARQL query for retrieving a shallow graph of an experiment containing the links to the system instance, the benchmark and the challenge task and the labels of them.- Parameters:
experimentUri- URI of the experiment that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
extendQuery
Extends a SPARQL query by inserting specified extension string every time a target string is found.- Parameters:
query- The original query.target- Target string to find.extension- Extension string to insert.- Returns:
- the modified query or
nullif the query is invalid.
-
getExperimentGraphOfBenchmarksQuery
public static final String getExperimentGraphOfBenchmarksQuery(List<String> benchmarkUris, String graphUri) Returns a SPARQL query for retrieving the graphs of experiments that involve one of the given benchmarks.- Parameters:
benchmarkUris- URIs of the benchmarks that might be involved in the experiment.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getExperimentGraphOfSystemsQuery
public static final String getExperimentGraphOfSystemsQuery(List<String> systemUris, String graphUri) Returns a SPARQL query for retrieving the graphs of experiments that involve one of the given systems.- Parameters:
systemUris- URIs of the systems that might be involved in the experiment.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getExperimentGraphOfBenchmarkQuery
Returns a SPARQL query for retrieving the graphs of experiments that involve the given benchmark.- Parameters:
benchmarkUri- URIs of the benchmark that might be involved in the experiment.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getExperimentOfTaskQuery
public static final String getExperimentOfTaskQuery(String experimentUri, String challengeTaskUri, String graphUri) Returns a SPARQL query for retrieving the graph of an experiment that is part of the given challenge task.- Parameters:
experimentUri- URI of the experiment that should be retrieved.nullworks like a wildcard.challengeTaskUri- URI of the challenge task from which the experiment should be created.nullworks like a wildcard.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getCreateExperimentFromTaskQuery
public static final String getCreateExperimentFromTaskQuery(String experimentUri, String challengeTaskUri, String systemUri, String graphUri) Returns a SPARQL query for creating a subgraph of a challenge task that defines an experiment of this task.- Parameters:
experimentUri- URI of the newly created experiment.challengeTaskUri- URI of the challenge task from which the experiment should be created.nullworks like a wildcard.systemUri- URI of the system of the experiment.nullworks like a wildcard.graphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL construct query that performs the retrieving or
nullif the query hasn't been loaded correctly - Throws:
IllegalArgumentException- if the given experimentUri is null
-
deleteExperimentGraphQuery
Returns a SPARQL update query for deleting the graph of an experiment.- Parameters:
experimentUri- URI of the experiment that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.- Returns:
- the SPARQL update query that performs the deletion or
nullif the query hasn't been loaded correctly
-
deleteChallengeGraphQuery
Returns a SPARQL update query for deleting the graph of a challenge.- Parameters:
challengeUri- URI of the challenge that should be retrieved.nullworks like a wildcard.graphUri- URI of the graph the challenge is stored.- Returns:
- the SPARQL update query that performs the deletion or
nullif the query hasn't been loaded correctly
-
cleanUpChallengeGraphQuery
Deprecated.A single large query does not seem to be supported by all triple stores. UsecleanUpChallengeGraphQueries(String)instead.Returns a SPARQL update query for cleaning up the graph of a challenge configs.- Parameters:
graphUri- URI of the graph the challenge is stored.nullworks like a wildcard.- Returns:
- the SPARQL update query that performs the deletion or
nullif the query hasn't been loaded correctly
-
cleanUpChallengeGraphQueries
Returns a SPARQL update query for cleaning up the graph of a challenge configs.- Parameters:
graphUri- URI of the challenge configuration graph.- Returns:
- the SPARQL update query that performs the deletion or
nullif the query hasn't been loaded correctly
-
cleanUpPrivateGraphQueries
Returns a SPARQL update query for cleaning up the private result graph.- Parameters:
graphUri- URI of the private result graph.- Returns:
- the SPARQL update query that performs the deletion or
nullif the query hasn't been loaded correctly
-
countExperimentsOfTaskQuery
Returns a SPARQL query for counting the number of experiments of a challenge task.- Parameters:
challengeTaskUri- URI of the challenge taskgraphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL select query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
getChallengeTaskOrganizer
Returns a SPARQL CONSTRUCT query for getting the organizer of the challenge two which a given challenge tasks belong to.- Parameters:
challengeTaskUri- URI of the challenge taskgraphUri- URI of the graph the experiment is stored.nullworks like a wildcard.- Returns:
- the SPARQL CONSTRUCT query that performs the retrieving or
nullif the query hasn't been loaded correctly
-
replacePlaceholders
private static final String replacePlaceholders(String query, String[] placeholders, String[] replacements) Replaces the given placeholders in the given query with the given replacements. If a replacement isnull, it is replaced by a variable.- Parameters:
query- the query containing placeholdersplaceholders- the placeholders that should be replacedreplacements- the replacements that should be used to replace the placeholders.- Returns:
- the newly created query or
nullif the given query wasnull.
-
getUpdateQueryFromDiff
public static final String getUpdateQueryFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri) Generates a SPARQL UPDATE query based on the differences between the two given models. Triples that are present in the original model but not in the updated model will be put into the DELETE part of the query. Triples that are present in the updated model but can not be found in the original model will be put into the INSERT part of the query.Note that some stores might have a maximum number of triples that can be processed with a single query. In these cases
getUpdateQueriesFromDiff(Model, Model, String, int)should be used.- Parameters:
original- the original RDF modelupdated- the updated RDF modelgraphUri- the URI of the graph to which the UPDATE query should be applied ornull- Returns:
- The SPARQL UPDATE query
-
getUpdateQueriesFromDiff
public static final String[] getUpdateQueriesFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri) Generates one or several SPARQL UPDATE queries based on the differences between the two given models. Triples that are present in the original model but not in the updated model will be put into the DELETE part of the query. Triples that are present in the updated model but can not be found in the original model will be put into the INSERT part of the query. The changes might be carried out using multiple queries if a single query could hit a maximum number of triples.- Parameters:
original- the original RDF model (nullis interpreted as an empty model)updated- the updated RDF model (nullis interpreted as an empty model)graphUri- the URI of the graph to which the UPDATE query should be applied ornull- Returns:
- The SPARQL UPDATE query
-
getUpdateQueriesFromDiff
public static final String[] getUpdateQueriesFromDiff(org.apache.jena.rdf.model.Model original, org.apache.jena.rdf.model.Model updated, String graphUri, int maxTriplesPerQuery) Generates one or several SPARQL UPDATE queries based on the differences between the two given models. Triples that are present in the original model but not in the updated model will be put into the DELETE part of the query. Triples that are present in the updated model but can not be found in the original model will be put into the INSERT part of the query. The changes will be carried out using multiple queries if a single query would hit the given maximum number of triples per query.- Parameters:
original- the original RDF model (nullis interpreted as an empty model)updated- the updated RDF model (nullis interpreted as an empty model)graphUri- the URI of the graph to which the UPDATE query should be applied ornullmaxTriplesPerQuery- the maximum number of triples a single query should contain- Returns:
- The SPARQL UPDATE query
-