SPARQL Queries useful for MICASheetEditor

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.

MICAModel

 \

  1. Sheets Queries concern MICASheets and/or LinkedSheets.
  2. FlowSheets Queries concern FlowSheets.
  3. Questions Queries concern Questions
  4. RelatedResources Queries concern relations between ressources (relatedTo relationship).

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.


Sheets Queries

These queries concern resources of type micamodel:Sheet , more precisely resources ofLinkedSheet or MICASheet type.

Creating a new Sheet

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

  • %1$s the sheet URI, for example https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e
  • %2$s the sheet type: MICASheet><> or <<<LinkedSheet
  • %3$s sheet title
  • %4$s sheet summary
  • %5$s one of the value for the enumerated class micamodel:ContentType. It can be
    • MethodsAndTools
    • Documentation
    • Legislation
    • Data
    • Portal
    • ArticlesAndReports
    • Other
  • %6$s publicURI of the sheet. For a sheet of type micamodel:MICASheet it is the PDF file URL, for a sheet of type LinkedSheet it is the URI of external resource.

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.

  • %7$s this parameter corresponds to the triple defining the privateURI attribute of the Sheet.\
    • If the resource is of type micamodel:MICASheet>>, its <<<privateURI attribute is the URL of the DOC file. In this case the parameter is of form micamodel:privateURI "someString"^^xsd.string;
    • If the resource is of type micamodel:LinkedSheet>>, it has no <<<privateURI attribute. In this case the parameter is an empty String.


    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 "";
        }
    
  • %8$s this parameter corresponds to the authors list.

    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();
        }
    
  • %9$s this parameter corresponds to the list of annotations that relate the Sheet to MicaOntology concepts.

    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();
        }
    
  • %10$s the submission date for the Sheet.

Deleting an existing sheet

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>.}
}
  • %1$s the sheet URI, for example https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e

Updating an existing sheet

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.

Retrieving a 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:

  • retrieve the URIs of those associated resources,
  • retrieve the labels of those associated resources.

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.

Retrieving a Sheet data and related resources URIs

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:

  • sheetURI is the URI identifying the sheet,
  • predicate is any property the sheetURI is subject of,
  • object is the value of the property.
    • If this value is a literal, it is retrieved as a String
    • If this value is another resource (e.g. a Person, another Sheet, a Concept ...), object value is this resource URI.

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:

  • %1$s the sheet URI, for example https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e

Request variables are :

  • ?title the sheet title
  • ?summary the sheet summary
  • ?submittedOn the submission date
  • ?sheetType the type of sheet: MICASheet or LinkedSheet
  • ?contentType the content type (one of the value for the enumerated class micamodel:ContentType : MethodsAndTools, Documentation, Legislation, Data...)
  • ?publicURI the sheet's public URI
  • ?privateURI the sheet's private URI if it exists
  • ?authors a String containing the list of authors of the sheet. Each author is represented by its URI, and URIs are separated by commas.
  • ?relatedURIs a String containing the list of resources the sheet is relatedTo. Each resource is represented by its URI, and URIs are separated by commas. An empty String if there is no related resource.
  • ?domains a String containing the list of Domain concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no Domain concept.
  • ?methods a String containing the list of Method concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts the sheet is annotated with. Each concept is represented by its URI, and URIs are separated by commas. An empty String if there is no ValueSupplyChain concept.
Retrieving a Sheet data and related resources labels

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:

  • sheetURI is the URI identifying the sheet,
  • predicate is any property the sheetURI is subject of,
  • object is the value of the property.
    • If this value is a literal, it is retrieved as a String
    • If this value is another resource (e.g. a Person, another Sheet, a Concept ...), object value is this resource label.

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:

  • %1$s the URI of sheet, for example https://w3id.org/mica/resource/45bc4f322c794ca6adbf521a3c64d45e

the query variables are:

  • ?title the title of sheet as string
  • ?summary the summary of sheet a string
  • ?submittedOn the date of submitted
  • ?typeSheet the type of sheet: MICASheet or LinkedSheet
  • ?contentType the type of Content
  • ?publicURI the public URI
  • ?privateURI the private URI if it exists
  • ?authors the authors of sheets as Name of person
  • ?relatedURIs the related resources as title for sheet, question for Question (if they exist)
  • ?domains the domain concepts as prefLabels if they exist
  • ?methods the method concepts as prefLabels if they exist
  • ?spatials the spatial concepts as prefLabels if they exist
  • ?temporals the temporal concepts as prefLabels if they exist
  • ?commodities the commodity concepts as prefLabels if they exist
  • ?datas the data concepts as prefLabels if they exist
  • ?valueSupplyChains the valueSupplyChain concepts as prefLabels if they exist

Get All sheets

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:

  • %s the filter text
  • first %d the offset
  • second %d the limit

Count Sheets

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") 
}
  • %s the text for filtering the title

    The following section has not been reviewed and verified

FlowSheets Queries

Create a New FlowSheet

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 ]) .  
            }

explanation of data flowsheet

  • %1$s the URI of flowSheet, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05
  • %2$s the title of flowSheet as a String
  • %3$s the summary of flowSheet as a String
  • %4$s the sheets text, as a flowSheet is a ordered list of KnowledgeElements( sheet or flowsheet). we use the following function in order to get rdf text of flowSheet. Map.Entry e e has two elements, e.key is an URI of sheet, e.value is a role.
        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();
        }
    
    
  • %5$s the authors text
  • %6$s the concepts text
  • %7$s the submittedOn date as date

Update a existing flowSheet

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

Delete a existing 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>.}
      }
  • %1$s the URI of flowSheet, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05

Get a flowSheet

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.

  • ?title the title of sheet as string
  • ?summary the summary of sheet a string
  • ?submittedOn the date of submitted
  • ?sheets the sheets list as URIs and role
  • ?authors the authors of sheets as URIs
  • ?relatedURIs the related resources as URIs if they exist
  • ?domains the domain concepts as URIs if they exist
  • ?methods the method concepts as URIs if they exist
  • ?spatials the spatial concepts as URIs if they exist
  • ?temporals the temporal concepts as URIs if they exist
  • ?commodities the commodity concepts as URIs if they exist
  • ?datas the data concepts as URIs if they exist
  • ?valueSupplyChains the valueSupplyChain concepts as URIs if they exist
 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  

  • %1$s the URI of flowSheet, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05

Get a flowSheet by label

The following query select (for a given URI of flowSheet): all metadata of flowSheet and concepts, authors, relatedURIs are presented as labels.

  • ?title the title of flowsheet as string
  • ?summary the summary of flowsheet a string
  • ?submittedOn the date of submitted
  • ?sheets the sheets list as title and role
  • ?authors the authors of flowSheet as Name of person
  • ?relatedURIs the related resources as title for sheet, question for Question (if they exist)
  • ?domains the domain concepts as prefLabels if they exist
  • ?methods the method concepts as prefLabels if they exist
  • ?spatials the spatial concepts as prefLabels if they exist
  • ?temporals the temporal concepts as prefLabels if they exist
  • ?commodities the commodity concepts as prefLabels if they exist
  • ?datas the data concepts as prefLabels if they exist
  • ?valueSupplyChains the valueSupplyChain concepts as prefLabels if they exist
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  
  • %1$s the URI of flowSheet, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05

Get All flowSheets

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 
  • %s the text for filter the title
  • %d the offset (the first one)
  • %d the limit (the second one)

Count flowSheets

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") 
     }
  • %s the text for filter the title

Questions Queries

Create a New Question

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 ]) ;  
}

explanation of data question

  • %1$s the URI of question, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e
  • %2$s the question as a String
  • %3$s the authors text
  • %4$s the concepts text
  • %5$s the submittedOn date as date

Update a existing Question

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

Delete a existing 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>.}
      }
  • %1$s the URI of question, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e

Get a Question

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.

  • ?question the question
  • ?submittedOn the date of submitted
  • ?authors the authors of sheets as URIs
  • ?relatedURIs the related resources as URIs if they exist
  • ?domains the domain concepts as URIs if they exist
  • ?methods the method concepts as URIs if they exist
  • ?spatials the spatial concepts as URIs if they exist
  • ?temporals the temporal concepts as URIs if they exist
  • ?commodities the commodity concepts as URIs if they exist
  • ?datas the data concepts as URIs if they exist
  • ?valueSupplyChains the valueSupplyChain concepts as URIs if they exist
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   
  • %1$s the URI of question, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e

Get a Question by label

The following query select (for a given URI of question): all metadata of question and concepts, authors, relatedURIs are presented as labels.

  • ?question the question
  • ?submittedOn the date of submitted
  • ?authors the authors of question as Name of person
  • ?relatedURIs the related resources as title for sheet, question for Question (if they exist)
  • ?domains the domain concepts as prefLabels if they exist
  • ?methods the method concepts as prefLabels if they exist
  • ?spatials the spatial concepts as prefLabels if they exist
  • ?temporals the temporal concepts as prefLabels if they exist
  • ?commodities the commodity concepts as prefLabels if they exist
  • ?datas the data concepts as prefLabels if they exist
  • ?valueSupplyChains the valueSupplyChain concepts as prefLabels if they exist
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  
  • %1$s the URI of question, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e

Get All Questions

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 
  • %s the text for filter the question
  • %d the offset (the first one)
  • %d the limit (the second one)

Count Questions

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") 
}
  • %s the text for filter the question

RelatedResources Queries

Create a relatedTo relation between two Resources

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>.  
            }
  • %1$s the URI of resource, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e
  • %2$s the URI of resource, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05

Remove a relatedTo relation between two Resources

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> .
     }
  • %1$s the URI of resource, for example https://w3id.org/mica/resource/1bfc399dfc314a8b81f50cfdf119cc9e
  • %2$s the URI of resource, for example https://w3id.org/mica/resource/4a76c1f420224d298709316db776dc05

List of relatedTo

The following query get a list of relation relatedTo by filtering by a given text for label. we select the following data:

  • ?uri the URI of Resource
  • ?relatedURI the URI of related Resource
  • ?uriLabel the label of uri
  • ?relatedURILabel the label of related Resource
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 
  • %s the text for filter the label
  • %d the offset (the first one)
  • %d the limit (the second one)

Count the relatedTo

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") 
}
  • %s the text to filter the label