This documentation presents various SPARQL queries that can be performed on the MICA triplestore in order to manage MICA resources. The purpose of this documentation is to provide elements that can facilitate the writing of the requests necessary to MICASheetsEditor tool.
All the presented queries respect the new MICA data model. They are sorted according to the type of MICA resource to which they relate.
\
In order to facilitate the writing of the MICASheetsEditor, all the queries are given in a generic form. We use the Java format string convention to represent the parameters of the query. These parameters must then be replaced by values (strings) from the user interface of the MICASheetEditor.
These queries concern resources of type micamodel:Sheet , more precisely resources ofLinkedSheet or MICASheet type.
The following query inserts a new sheet in the MICA triple store.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> INSERT DATA { <%1$s> a owl:NamedIndividual , micamodel:Sheet, micamodel:%2$s ; dcterms:title "%3$s"^^xsd:string; micamodel:summary "%4$s"^^xsd:string; micamodel:hasContentType micamodel:%5$s ; micamodel:publicURI "%6$s"^^xsd:string; %7$s %8$s %9$s micamodel:hasStatus ( [ a micamodel:Status; micamodel:submittedOn "%10$s"^^xsd:dateTime ]). }
explanation of the query parameters
For parameters %7$s%, %8$s% and %9$s%, the substition string represents some set of RDF triples whose size (number of triples) may vary according the elements the user provides in the MICASheetsEditor interface. To construct these strings we suggest some Java functions.
The following Java function can be used to generate this parameter:
/** * generate the string defining the privateURI attribute of a Sheet. * @param privateURI if the resource is a MICASheet, its privateURI * if the resource is a FactSheet an empty String * * @return the string defining the privateURI attribute of a MICASheet, an * empty string for a FactSheet. */ private static String generatePrivateURI(String privateURI) { if (privateURI != null && privateURI.isEmpty()) { return " micamodel:privateURI " + URI ^^xsd:string; "; } return ""; }
The following Java function creates the RDF representation of this list.
/** * generates the string defining the author attributes of a Sheet. * * @param authors arrays of URIs of the sheet's authors, * (example of such a URI https://w3id.org/mica/resource/c6bab58c791d41b3b81973636927ba7) * * @return the RDF (Turtle) string that defines the authors of the sheet. */ public static String generateAuthorsList(String[] authors) { StringBuilder sbAuthors = new StringBuilder(); for (String author : authors) { sbAuthors.append("micamodel:hasWriter <").append(author).append(">;"); } return sbAuthors.toString(); }
The following Java function creates the RDF representation of this list.
/** * generates the string defining annotations of the Sheet with MicaOntology concepts. * The property used to relate a concept to the Sheet depends on the concept Scheme * the concept belongs to (e.g. if the concepts belongs to DomainConceptScheme the * property used is mica:hasDomainConcept, if the concepts belongs do MethodsConceptScheme * the property is mica:hasMethodConcept). This function uses a map to associate concepts to their * scheme in order to facilitate RDF generation. * * @param concepts map defining the concepts that annotate the Sheet. * keys are the names of the ConceptsSchemes * values are arrays containing the concepts belonging to the key concept scheme * that annotate the Sheet. * * @return the RDF (Turtle) string that defines the concept annotations for the sheet. */ public static String generateConceptsAnnotations(Map<String, String[]> concepts) { StringBuilder sbConcepts = new StringBuilder(); for (Map.Entry<String, String[]> e : concepts.entrySet()) { String[] c = e.getValue(); for (String concept : c) { sbConcepts.append("micamodel:has").append(e.getKey().substring(0, 1) .toUpperCase()).append(e.getKey().substring(1)).append("Concept <").append(concept).append(">;"); } } return sbConcepts.toString(); }
The following query removes a given sheet from the MICA triple store. Given the sheet URI, all the triples with this URI as subject or as object are removed.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> DELETE { <%1$s> ?p ?o. ?s micamodel:relatedTo <%1$s>. } WHERE { <%1$s> a micamodel:Sheet; ?p ?o. optional{?s micamodel:relatedTo <%1$s>.} }
The following query updates a given sheet in triple store. First it removes all the triples having that sheet as subject, and then re-inserts all the triples with the new values extracted for the MICASheetsEditor user interface.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> DELETE {<%1$s> ?p ?o.} INSERT { <%1$s> a owl:NamedIndividual , micamodel:Sheet, micamodel:%2$s ; dcterms:title "%3$s"^^xsd:string; micamodel:summary "%4$s"^^xsd:string; micamodel:hasContentType micamodel:%5$s ; micamodel:publicURI "%6$s"^^xsd:string; %7$s %8$s %9$s micamodel:hasStatus ( [ a micamodel:Status; micamodel:submittedOn "%10$s"^^xsd:dateTime ]). } WHERE {<%1$s> ?p ?o.}
The query parameters are the same as those of the request to create a new Sheet.
The following queries retrieve information associated to a given sheet. Two options are available depending on the type of information retrieved from the resources associated with the sheet:
To display information in the UI, second option may be more appropriate than the first one. This avoids making new queries using the related resources URIs to obtain displayable information.
Of course, according the needs of the application, a mix between these two solutions can be performed.
The following query retrieves all the information directly associated to a given sheet identified by its URI. In other words it retreives all the values of the triples <sheetURI predicate object> where:
In order to facilitate its exploitation, the ResultSet contains only one line and when there are multiple values for a given predicate, they are concatenated into a String and separeted by a comma.
For example if the sheet has one title and multiple Domain concepts anotations the following query
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?title (group_concat(distinct ?domain; separator = ",") AS ?domains) WHERE { <https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e> dcterms:title ?title; micamodel:hasDomainConcept ?domain. } GROUP BY ?title
gives the ResultSet
--------------------------------------------------------------------------------------------------------------------------------- | title | domains | ================================================================================================================================= | "Circular Economy defsheet"@en | "https://w3id.org/mica/ontology/MicaOntology/a0ecbc56233b4245b57aa997fe1ea1a1, https://w3id.org/mica/ontology/MicaOntology/20c7030f1bfd41508c57ebee0962caf2" | ---------------------------------------------------------------------------------------------------------------------------------
The ?domains variable is a String concatenating all the domains Concepts URIs the Sheet is related to, separated by a ','. If we did not use a group_concat aggregation function we would obtain a multiple lines ResultSet like in the foloowing query.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?title ?domain WHERE { <https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e> dcterms:title ?title; micamodel:hasDomainConcept ?domain. }
the ResultSet
------------------------------------------------------------------------------------------------------------------- | title | domain | =================================================================================================================== | "Circular Economy defsheet"@en | <https://w3id.org/mica/ontology/MicaOntology/a0ecbc56233b4245b57aa997fe1ea1a1> | | "Circular Economy defsheet"@en | <https://w3id.org/mica/ontology/MicaOntology/20c7030f1bfd41508c57ebee0962caf2> | -------------------------------------------------------------------------------------------------------------------
The complete query to get all the information associated to a given Sheet is as follows
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT distinct ?title ?summary ?submittedOn ?typeSheet ?contentType ?publicURI ?privateURI (group_concat( distinct ?author; separator = ",") AS ?authors) (group_concat(distinct ?relatedURI; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domain; separator = ",") AS ?domains) (group_concat(distinct ?method; separator = ",") AS ?methods) (group_concat(distinct ?spatial; separator = ",") AS ?spatials) (group_concat(distinct ?temporal; separator = ",") AS ?temporals) (group_concat(distinct ?commodity; separator = ",") AS ?commodities) (group_concat(distinct ?data; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChain; separator = ",") AS ?valueSupplyChains) WHERE { ?sheetType rdfs:subClassOf micamodel:Sheet. <%1$s> a ?sheetType; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:publicURI ?publicURI; micamodel:hasContentType ?contentType; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ); optional{<%1$s> micamodel:privateURI ?privateURI. } optional{<%1$s> micamodel:relatedTo ?relatedURI. } optional{<%1$s> micamodel:hasDomainConcept ?domain. } optional{<%1$s> micamodel:hasMethodConcept ?method. } optional{<%1$s> micamodel:hasSpatialConcept ?spatial. } optional{<%1$s> micamodel:hasTemporalConcept ?temporal. } optional{<%1$s> micamodel:hasCommoditiesConcept ?commodity. } optional{<%1$s> micamodel:hasDataConcept ?data. } optional{<%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. } } group by ?title ?summary ?submittedOn ?contentType ?typeSheet ?publicURI ?privateURI;
Request parameters are:
Request variables are :
The following query retrieves all the information directly associated to a given sheet identified by its URI. In other words it retreives all the values of the triples <sheetURI predicate object> where:
If we consider the example above, retrieving a Sheet title and the the domain concepts the sheet is annotated with, the ResultSet will be of the following form
---------------------------------------------------------------------------------- | title | domains | ================================================================================== | "Circular Economy defsheet"@en | "Circular economy,D7 International Reporting" | ----------------------------------------------------------------------------------
instead of
--------------------------------------------------------------------------------------------------------------------------------- | title | domains | ================================================================================================================================= | "Circular Economy defsheet"@en | "https://w3id.org/mica/ontology/MicaOntology/a0ecbc56233b4245b57aa997fe1ea1a1, https://w3id.org/mica/ontology/MicaOntology/20c7030f1bfd41508c57ebee0962caf2" | --------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------
The complete query to get all the information associated to a given Sheet, in a human readable form, is as follows
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT distinct ?title ?summary ?submittedOn ?contentType ?typeSheet ?publicURI ?privateURI (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { ?typeSheet rdfs:subClassOf micamodel:Sheet. <%1$s> a ?typeSheet; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:publicURI ?publicURI; micamodel:hasContentType ?contentType; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ). ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{ <%1$s> micamodel:privateURI ?privateURI. } optional{ <%1$s> micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{ <%1$s> micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{ <%1$s> micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{ <%1$s> micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{ <%1$s> micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{ <%1$s> micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{ <%1$s> micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{ <%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } } group by ?title ?summary ?submittedOn ?contentType ?typeSheet ?publicURI ?privateURI ;
the query parameters are:
the query variables are:
the following query select all sheets by filtering by a given title text. we select all metadata as labels.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT distinct ?uri ?title ?summary ?submittedOn ?contentType ?typeSheet ?publicURI ?privateURI (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { ?typeSheet rdfs:subClassOf micamodel:Sheet. ?uri a ?typeSheet; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:publicURI ?publicURI; micamodel:hasContentType ?contentType; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ). ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{?uri micamodel:privateURI ?privateURI. } optional{?uri micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{?uri micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{?uri micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{?uri micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{?uri micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{?uri micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{?uri micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{?uri micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } FILTER regex(str(?title), "%s", "i") } group by ?uri ?title ?summary ?submittedOn ?contentType ?typeSheet ?publicURI ?privateURI order by ?title OFFSET %d LIMIT %d
query parameters are:
the following query count all sheets by filtering by a given title text.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT (count (distinct ?uri) as ?nbsheets) WHERE { ?typeSheet rdfs:subClassOf micamodel:Sheet. ?uri a ?typeSheet; dcterms:title ?title; FILTER regex(str(?title), "%s", "i") }
The following section has not been reviewed and verified
The following query insert a new flowSheet in triple store.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> INSERT DATA { <%1$s> a owl:NamedIndividual , micamodel:FlowSheet ; dcterms:title "%2$s"^^xsd:string; micamodel:summary "%3$s"^^xsd:string; %4$s %5$s %6$s micamodel:hasStatus ( [ a micamodel:Status; micamodel:submittedOn "%7$s"^^xsd:dateTime ]) . }
private static String sheetsText(Map<String, String> sheets) { StringBuilder sbSheets = new StringBuilder(); sbSheets.append(" micamodel:hasElements ( "); for (Map.Entry<String, String> e : sheets.entrySet()) { sbSheets.append(" [ micamodel:hasKnowledgeElement <") .append(e.getKey()) .append("> ; micamodel:role "").append(e.getValue()).append(""^^xsd:string ") .append(" ] ); } sbSheets.append(" ) ; "); return sbSheets.toString(); }
The following query update a given flowSheet in triple store.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> DELETE {<%1$s> ?p ?o.} INSERT { <%1$s> a owl:NamedIndividual , micamodel:FlowSheet; dcterms:title "%2$s"^^xsd:string; micamodel:summary "%3$s"^^xsd:string; %4$s %5$s %6$s micamodel:hasStatus ( [ a micamodel:Status; micamodel:submittedOn "%7$s"^^xsd:dateTime ]) . } WHERE { <%1$s> ?p ?o. }
To update the given flowSheet, we give the data to update: explanation of data flowsheet
the following query remove all triples for a given flowSheet URI.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> DELETE { <%1$s> ?p ?o. ?s micamodel:relatedTo <%1$s>. } WHERE {<%1$s> a micamodel:FlowSheet; ?p ?o. optional{?s micamodel:relatedTo <%1$s>.} }
The following query select (for a given URI of flowSheet): all metadata and concepts, authors, relatedURIs are presented as URIs like https://w3id.org/mica/resource/UUID for resources and https://w3id.org/mica/ontology/MicaOntology/UUID for concepts.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT distinct ?title ?summary ?submittedOn (group_concat(distinct ?sheet; separator = ",") AS ?sheets) (group_concat( distinct ?author; separator = ",") AS ?authors) (group_concat(distinct ?relatedURI; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domain; separator = ",") AS ?domains) (group_concat(distinct ?method; separator = ",") AS ?methods) (group_concat(distinct ?spatial; separator = ",") AS ?spatials) (group_concat(distinct ?temporal; separator = ",") AS ?temporals) (group_concat(distinct ?commodity; separator = ",") AS ?commodities) (group_concat(distinct ?data; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChain; separator = ",") AS ?valueSupplyChains) WHERE { <%1$s> a micamodel:FlowSheet; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ); micamodel:hasElements/rdf:rest*/rdf:first ?element. ?element micamodel:role ?role; micamodel:hasKnowledgeElement ?micaKnowledgeElementURI. bind(concat(?micaKnowledgeElementURI,";",?role) as ?sheet) optional{<%1$s> micamodel:relatedTo ?relatedURI. } optional{<%1$s> micamodel:hasDomainConcept ?domain. } optional{<%1$s> micamodel:hasMethodConcept ?method. } optional{<%1$s> micamodel:hasSpatialConcept ?spatial. } optional{<%1$s> micamodel:hasTemporalConcept ?temporal. } optional{<%1$s> micamodel:hasCommoditiesConcept ?commodity. } optional{<%1$s> micamodel:hasDataConcept ?data. } optional{<%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. } } group by ?title ?summary ?submittedOn
The following query select (for a given URI of flowSheet): all metadata of flowSheet and concepts, authors, relatedURIs are presented as labels.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT distinct ?title ?summary ?submittedOn (group_concat(distinct ?sheet; separator = ",") AS ?sheets) (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { <%1$s> a micamodel:FlowSheet; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ); micamodel:hasElements/rdf:rest*/rdf:first ?element. ?element micamodel:role ?role; micamodel:hasKnowledgeElement ?micaKnowledgeElementURI. optional{?micaKnowledgeElementURI dcterms:title ?micaKnowledgeElementURILabel.} optional{?micaKnowledgeElementURI micamodel:question ?micaKnowledgeElementURILabel.} bind(concat(?micaKnowledgeElementURILabel,";",?role) as ?sheet) ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{<%1$s> micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{<%1$s> micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{<%1$s> micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{<%1$s> micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{<%1$s> micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{<%1$s> micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{<%1$s> micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{<%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } } group by ?title ?summary ?submittedOn
the following query select all flowSheets by filtering by a given title text. we select all metadata as labels.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT distinct ?uri ?title ?summary ?submittedOn (group_concat(distinct ?sheet; separator = ",") AS ?sheets) (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { ?uri a micamodel:FlowSheet; dcterms:title ?title; micamodel:summary ?summary; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ); micamodel:hasElements/rdf:rest*/rdf:first ?element. ?element micamodel:role ?role; micamodel:hasKnowledgeElement ?micaKnowledgeElementURI. optional{?micaKnowledgeElementURI dcterms:title ?micaKnowledgeElementURILabel.} optional{?micaKnowledgeElementURI micamodel:question ?micaKnowledgeElementURILabel.} bind(concat(?micaKnowledgeElementURILabel,";",?role) as ?sheet) ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{?uri micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{?uri micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{?uri micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{?uri micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{?uri micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{?uri micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{?uri micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{?uri micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } FILTER regex(str(?title), "%s", "i") } group by ?uri ?title ?summary ?submittedOn order by ?title OFFSET %d LIMIT %d
the following query count all flowSheets by filtering by a given title text.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT (count (distinct ?uri) as ?nbsheets) WHERE { ?uri a micamodel:FlowSheet; dcterms:title ?title; FILTER regex(str(?title), "%s", "i") }
The following query insert a new question in triple store.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> INSERT DATA{ <%1$s> a owl:NamedIndividual ,micamodel:MICAQuestion ; micamodel:question "%2$s"^^xsd:string; %3$s %4$s micamodel:hasStatus ([ a micamodel:Status; micamodel:submittedOn "%5$s"^^xsd:dateTime ]) ; }
The following query update a given question in triple store.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX owl: <http://www.w3.org/2002/07/owl#> DELETE {<%1$s> ?p ?o.} INSERT { <%1$s> a owl:NamedIndividual ,micamodel:MICAQuestion ; micamodel:question "%2$s"^^xsd:string; %3$s %4$s micamodel:hasStatus ([ a micamodel:Status; micamodel:submittedOn "%5$s"^^xsd:dateTime ]) ; } WHERE { <%1$s> ?p ?o. }
To update the given question, we give the data to update: explanation of data question
the following query remove all triples for a given question URI.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> DELETE { <%1$s> ?p ?o. ?s micamodel:relatedTo <%1$s>. } WHERE {<%1$s> a micamodel:MICAQuestion; ?p ?o. optional{?s micamodel:relatedTo <%1$s>.} }
The following query select (for a given URI of question): all metadata and concepts, authors, relatedURIs are presented as URIs like https://w3id.org/mica/resource/UUID for resources and https://w3id.org/mica/ontology/MicaOntology/UUID for concepts.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT distinct ?question ?submittedOn (group_concat( distinct ?author; separator = ",") AS ?authors) (group_concat(distinct ?relatedURI; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domain; separator = ",") AS ?domains) (group_concat(distinct ?method; separator = ",") AS ?methods) (group_concat(distinct ?spatial; separator = ",") AS ?spatials) (group_concat(distinct ?temporal; separator = ",") AS ?temporals) (group_concat(distinct ?commodity; separator = ",") AS ?commodities) (group_concat(distinct ?data; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChain; separator = ",") AS ?valueSupplyChains) WHERE { <%1$s> a micamodel:MICAQuestion ; micamodel:question ?question; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ); optional{<%1$s> micamodel:relatedTo ?relatedURI. } optional{<%1$s> micamodel:hasDomainConcept ?domain. } optional{<%1$s> micamodel:hasMethodConcept ?method. } optional{<%1$s> micamodel:hasSpatialConcept ?spatial. } optional{<%1$s> micamodel:hasTemporalConcept ?temporal. } optional{<%1$s> micamodel:hasCommoditiesConcept ?commodity. } optional{<%1$s> micamodel:hasDataConcept ?data. } optional{<%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. } } group by ?question ?submittedOn
The following query select (for a given URI of question): all metadata of question and concepts, authors, relatedURIs are presented as labels.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT distinct ?question ?submittedOn (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { <%1$s> a micamodel:MICAQuestion ; micamodel:question ?question; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ). ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{<%1$s> micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{<%1$s> micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{<%1$s> micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{<%1$s> micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{<%1$s> micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{<%1$s> micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{<%1$s> micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{<%1$s> micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } } group by ?question ?submittedOn
the following query select all questions by filtering by a given question text. we select all metadata as labels.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> SELECT distinct ?uri ?question ?submittedOn (group_concat( distinct ?name; separator = ",") AS ?authors) (group_concat(distinct ?relatedURILabel; separator = ",") AS ?relatedURIs) (group_concat(distinct ?domainLabel; separator = ",") AS ?domains) (group_concat(distinct ?methodLabel; separator = ",") AS ?methods) (group_concat(distinct ?spatialLabel; separator = ",") AS ?spatials) (group_concat(distinct ?temporalLabel; separator = ",") AS ?temporals) (group_concat(distinct ?commodityLabel; separator = ",") AS ?commodities) (group_concat(distinct ?dataLabel; separator = ",") AS ?datas) (group_concat(distinct ?valueSupplyChainLabel; separator = ",") AS ?valueSupplyChains) WHERE { ?uri a micamodel:MICAQuestion ; micamodel:question ?question; micamodel:hasWriter ?author; micamodel:hasStatus ( [ micamodel:submittedOn ?submittedOn ] ). ?author foaf:givenName ?firstName; foaf:familyName ?lastName. bind(concat(?lastName," ",?firstName) as ?name) optional{?uri micamodel:relatedTo ?relatedURI. optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } optional{?uri micamodel:hasDomainConcept ?domain. ?domain skos:prefLabel ?domainLabel. } optional{?uri micamodel:hasMethodConcept ?method. ?method skos:prefLabel ?methodLabel. } optional{?uri micamodel:hasSpatialConcept ?spatial. ?spatial skos:prefLabel ?spatialLabel. } optional{?uri micamodel:hasTemporalConcept ?temporal. ?temporal skos:prefLabel ?temporalLabel. } optional{?uri micamodel:hasCommoditiesConcept ?commodity. ?commodity skos:prefLabel ?commodityLabel. } optional{?uri micamodel:hasDataConcept ?data. ?data skos:prefLabel ?dataLabel. } optional{?uri micamodel:ValueSupplyChainConcept ?valueSupplyChain. ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel. } FILTER regex(str(?question), "%s", "i") } group by ?uri ?question ?submittedOn order by ?question OFFSET %d LIMIT %d
the following query count all questions by filtering by a given question text.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> SELECT (count (distinct ?uri) as ?nbsheets) WHERE { ?uri a micamodel:MICAQuestion ; micamodel:question ?question; FILTER regex(str(?question), "%s", "i") }
The following query create a relatedTo relation between two Resources .
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> INSERT DATA { <%1$s> micamodel:relatedTo <%2$s> . <%2$s> micamodel:relatedTo <%1$s>. }
The following query remove a relatedTo relation between two Resources .
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> DELETE { <%1$s> micamodel:relatedTo <%2$s> . <%2$s> micamodel:relatedTo <%1$s>. } WHERE { <%1$s> micamodel:relatedTo <%2$s> . }
The following query get a list of relation relatedTo by filtering by a given text for label. we select the following data:
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT ?uri ?relatedURI ?uriLabel ?relatedURILabel WHERE { ?uri micamodel:relatedTo ?relatedURI. optional{?uri dcterms:title ?uriLabel.} optional{?uri micamodel:question ?uriLabel.} FILTER regex(str(?uriLabel), "%s", "i") optional{?relatedURI dcterms:title ?relatedURILabel.} optional{?relatedURI micamodel:question ?relatedURILabel.} } OFFSET %d LIMIT %d
the following query count all relatedTo by filtering by a given text.
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> PREFIX dcterms: <http://purl.org/dc/terms/> SELECT (count (distinct ?uri) as ?nbRelatedTos) WHERE { ?uri micamodel:relatedTo ?relatedURI. optional{?uri dcterms:title ?uriLabel.} optional{?uri micamodel:question ?uriLabel.} FILTER regex(str(?uriLabel), "%s", "i") }