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 queries presented here respect the new MICA data model. They are sorted according to the type of MICA resource to which they relate.

MICAModel

 
 

  1. MICASheets Queries concern MICASheets.
  2. LinkedSheets Queries concern LinkedSheets.
  3. MICAQuestions Queries concern MICAQuestions
  4. FlowSheets Queries concern FlowSheets.
  5. RelatedResources Queries concern relations between MICAResources (relatedTo relationship).

For better readability of the examples we use "explicit" strings for the local name of resource URIs. For example:

  • Cassard for a foaf:Person, (full URI is https://w3id.org/mica/resource/Cassard),
  • MS1 for a micamodel:MICASheet (full URI is https://w3id.org/mica/resource/MS1),
  • FS1 for a micamodel:FlowSheet (full URI is https://w3id.org/mica/resource/FS1),
  • etc.

The effective value of this local name can be different, according to the policy adopted for URI generation in the MICASheet Editor (for example using an UUID).

CAUTION: With Fuseki, SPARQL updates queries must be performed on the update SPARQL endpoint that has a different URL than the query endpoint. For example for the testMicaModel dataset on the LIG fuseki server:

  • URL of the SPARQL endpoint for UPDATE queries is
    http://lig-coin.imag.fr/fuseki/testMicaModel/update
  • URL of the SPARQL endpoint for SLECT and ASK queries is
    http://lig-coin.imag.fr/fuseki/testMicaModel/query

MICASheets Queries

These queries concern resources of type micamodel:MICASheet.

Creating a new MICASheet

This example shows a SPARQL query to create a new MICASheet whose URI is https://w3id.org/mica/resource/MS1 and with the following data:

  • title : MICA Sheet #1
  • summary : MICA Sheet #1 summary
  • publicURI : http://.../MICASheet1.pdf a URI where the public version (pdf) of the MICASheet can be retrieved. The form of the URI needs to be defined by GEUS (which manages the database).
  • privateURI : http://.../MICASheet1.docx a URI where the private (internal) version (docx) of the MICASheet can be retrieved. The form of the URI needs to be defined by GEUS (which manages the database).
  • contentType: in this example micamodel:ArticlesAndReports (reminder: this value should be one of the values for the enumerated class micamodel:ContentType. It can be : micamodel:MethodsAndTools, micamodel:Documentation, micamodel:Legislation,micamodel:Data, micamodel:Portal,micamodel:ArticlesAndReports or micamodel:Other).
  • two writers :
    • Daniel Cassard described by a RDF resource whose URI is https://w3id.org/mica/resource/Cassard
    • François Tertre described by a RDF resource whose URI is https://w3id.org/mica/resource/Tertre
  • This MicaSheet is annotated by 3 concepts from the MicaOntology:
    • two Domain concepts:
      • https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76 : biodiversity compensation (D6 sustainability of raw materials)
      • https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313 : environment health & safety policy (D5 raw materials policy & legal framework)
    • one Method concept
      • https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900 : risk assessment methods - MethodsScheme
  • This MicaSheet is related to three other MICAResources (the local names of these three resources are S1, S2 and S3).

To create such a MICASheet, the SPARQL Update query is the following:

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 

INSERT DATA {
<https://w3id.org/mica/resource/MS1>
                 a micamodel:MICASheet;
                 dcterms:title "MICA Sheet #1";
                 micamodel:summary "MICA Sheet #1 summary";
                 micamodel:publicURI  "MICASheet1.pdf";
                 micamodel:privateURI  "MICASheet1.docx";       
                 micamodel:hasContentType  micamodel:ArticlesAndReports;
                 micamodel:hasWriter
                         <https://w3id.org/mica/resource/Cassard>,
                         <https://w3id.org/mica/resource/Tertre>;
                 micamodel:hasDomainConcept
                         <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                         <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
                 micamodel:hasMethodConcept
                         <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
                 micamodel:relatedTo
                         <https://w3id.org/mica/resource/S1>,
                         <https://w3id.org/mica/resource/S2>,
                         <https://w3id.org/mica/resource/S3>;
                 
          }

Updating an existing MICASheet

To update an existing MICASheet, proceed in two steps:

  1. remove from the triplestore all triples having that sheet as subject.
  2. reinsert all the triples describing the MicaSheet using the same type of query as the one of the previous example (Creating a new MICASheet).
    • For data that have not changed, triples are the same as before deletion.
    • For data that have been modified, values for the triples are the new values.
    • For data that have been added, new triples are inserted.
    • For data that have been removed, the corresponding triples are no longer present in the query.

For example for update the MS1 MICASheet created in the previous example by changing its summary (replace "MICA Sheet #1 summary" by "MICA Sheet #1 new summary" and add a new related MICAResource (S4)

The queries will be:

  1. DELETE {  
     <https://w3id.org/mica/resource/MS1> ?p ?o.
    }
    WHERE { 
       <https://w3id.org/mica/resource/MS1> ?p ?o.
    } 
  2. PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    PREFIX dcterms: <http://purl.org/dc/terms/> 
    
    INSERT DATA {
    <https://w3id.org/mica/resource/MS1>
                     a micamodel:MICASheet;
                     dcterms:title "MICA Sheet #1";
                     micamodel:summary "MICA Sheet #1 new summary";
                     micamodel:publicURI  "MICASheet1.pdf";
                     micamodel:privateURI  "MICASheet1.docx";       
                     micamodel:hasContentType  micamodel:ArticlesAndReports;
                     micamodel:hasWriter
                             <https://w3id.org/mica/resource/Cassard>,
                             <https://w3id.org/mica/resource/Tertre>;
                     micamodel:hasDomainConcept
                             <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                             <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
                     micamodel:hasMethodConcept
                             <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
                     micamodel:relatedTo
                             <https://w3id.org/mica/resource/S1>,
                             <https://w3id.org/mica/resource/S2>,
                             <https://w3id.org/mica/resource/S3>,
                             <https://w3id.org/mica/resource/S4>;
                     
              }

Deleting an existing MICASheet

When a MICASheet is deleted all the triples with this MICASheet URI as subject or as object must be removed. from the MICA triple store. In addition to that, if the MICASheet is used in one or several flowsheets, it must be removed from the elements lists of these FlowSheets. All the triples defining the FlowSheetElements referencing the deleted MICASheet must be removed and the triples defining the elements listed of the FlowSheets must be updated.

For example to delete MS1 MICASheet, the query is:

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE
      {  
        <https://w3id.org/mica/resource/MS1> ?p ?o.
         ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/MS1>.
         ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/MS1>;
          micamodel:role ?role.
          ?node rdf:first ?element;
          rdf:rest ?rest.
          ?previousNode ?property ?node. 
     }
INSERT { ?previousNode ?property ?rest. } 
WHERE { 
      <https://w3id.org/mica/resource/MS1> ?p ?o;
      OPTIONAL {
                  ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/MS1>.
                }     
      OPTIONAL {
        ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/MS1>;
               micamodel:role ?role.
        ?node rdf:first ?element;
              rdf:rest ?rest.
       ?previousNode ?property ?node.
      }
} 

Retrieving a MICASheet

The following queries retrieve information associated to a given MICASheet. 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, the second option may be more appropriate than the first . This avoids making new queries using the related resources URIs to obtain displayable information.

Of course, according to the needs of the application, a combination of these two solutions can be performed.

Retrieving MICASheet 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 retrieves all the values of the triples <sheetURI predicate object> where:

  • sheetURI is the URI identifying the sheet,
  • predicate is any property of this given sheetURI ,
  • 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 ...), the 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 separated by a comma.

For example if the sheet has one title and multiple Domain concepts annotations 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

titledomains
"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 as in the following 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

titledomain
"Circular Economy defsheet"@enhttps://w3id.org/mica/ontology/MicaOntology/a0ecbc56233b4245b57aa997fe1ea1a1
"Circular Economy defsheet"@enhttps://w3id.org/mica/ontology/MicaOntology/20c7030f1bfd41508c57ebee0962caf2

For example, the complete query to get all the information associated to MS1 MICASheet is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 


 SELECT DISTINCT ?title  ?summary  ?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 { 
 <https://w3id.org/mica/resource/MS1> 
            a micamodel:MICASheet;
            dcterms:title ?title;
            micamodel:summary ?summary;      
            micamodel:publicURI ?publicURI;       
            micamodel:hasContentType ?contentType;     
            micamodel:privateURI ?privateURI;  
            micamodel:hasWriter ?author.  
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:relatedTo ?relatedURI. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasDomainConcept ?domain. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasMethodConcept ?method. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasSpatialConcept ?spatial. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasTemporalConcept ?temporal. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasCommodityConcept ?commodity. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasDataConcept ?data. }
            OPTIONAL{<https://w3id.org/mica/resource/MS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. }
      
    }
group by  ?title  ?summary  ?contentType ?publicURI ?privateURI 

Request variables are :

  • ?title the MICASheet title
  • ?summary the MICASheet summary
  • ?contentType the content type (one of the value for the enumerated class micamodel:ContentType : MethodsAndTools, Documentation, Legislation, Data...)
  • ?publicURI the MICASheet's public URI
  • ?privateURI the MICASheet's private URI
  • ?authors a String containing the list of authors as URIs of the MICASheet.
    Each author is represented by its URI, and URIs are separated by commas.
  • ?relatedURIs a String containing the list of resources as URIs that the MICASheet is relatedTo.
    Each resource is represented by its URI, and URIs are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as URIs that the MICASheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no ValueSupplyChain concept.
Retrieving MICASheet 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 retrieves 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 domain concepts the sheet is annotated with, the ResultSet will be of the following form

titledomains
"Circular Economy defsheet"@en"Circular economy,D7 International Reporting"

instead of

titledomains
"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 MS1 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 skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?title  ?summary  ?contentType ?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 { 
<https://w3id.org/mica/resource/MS1>
        a micamodel:MICASheet;
        dcterms:title ?title;
        micamodel:summary ?summary;    
        micamodel:publicURI ?publicURI;   
        micamodel:hasContentType ?contentType;  
        micamodel:privateURI ?privateURI;
        micamodel:hasWriter ?author.
        ?author foaf:givenName ?firstName;
        foaf:familyName ?lastName.
        bind(concat(?lastName," ",?firstName) as ?name)

            OPTIONAL{
                 <https://w3id.org/mica/resource/MS1> micamodel:relatedTo ?relatedURI. 
                OPTIONAL{?relatedURI dcterms:title ?relatedURILabel.} 
                OPTIONAL{?relatedURI micamodel:question ?relatedURILabel.}
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/MS1> micamodel:hasDomainConcept ?domain. 
               ?domain skos:prefLabel ?domainLabel. 
            }
            OPTIONAL{
              <https://w3id.org/mica/resource/MS1> micamodel:hasMethodConcept ?method. 
               ?method skos:prefLabel ?methodLabel.
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/MS1> micamodel:hasSpatialConcept ?spatial. 
               ?spatial skos:prefLabel ?spatialLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MS1> micamodel:hasTemporalConcept ?temporal. 
                ?temporal skos:prefLabel ?temporalLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MS1> micamodel:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MS1> micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
               ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
            }
       
     }
group by  ?title  ?summary  ?contentType ?publicURI ?privateURI 

Request variables are :

  • ?title the MICASheet title
  • ?summary the MICASheet summary
  • ?contentType the content type (one of the value for the enumerated class micamodel:ContentType : micamodel:MethodsAndTools, micamodel:Documentation, micamodel:Legislation, Data...)
  • ?publicURI the MICASheet's public URI
  • ?privateURI the MICASheet's private URI
  • ?authors a String containing the list of authors as labels of the MICASheet.
    Each author is represented by its name as (?lastName," ",?firstName) , and names are separated by commas.
  • ?relatedURIs a String containing the list of resources as labels that the MICASheet is relatedTo.
    Each resource is represented by its Label as title for micamodel:MICAKnowledgeElement
    or question for micamodel:MICAQuestion, and labels are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as labels that the MICASheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no ValueSupplyChain concept.

Get All MICASheets

The following query selects all MICASheets by filtering by a given title text. Each metadata is represented by its label.

  • filter text is ""
  • offset is 0
  • limit is 25
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?uri ?title  ?summary  ?contentType ?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 { 
    ?uri a micamodel:MICASheet;
        dcterms:title ?title;
        micamodel:summary ?summary;
        micamodel:publicURI ?publicURI;   
        micamodel:hasContentType ?contentType;  
        micamodel:privateURI ?privateURI;
        micamodel:hasWriter ?author. 
        ?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:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
                ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
        }

FILTER regex(str(?title), "", "i") }
GROUP BY ?uri ?title  ?summary  ?contentType ?publicURI ?privateURI 
ORDER BY ?title 
OFFSET 0 
LIMIT 25 

Request variables are :

Count MICASheets

The following query counts all MICASheets by filtering with a given title text.

  • filter text is ""
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 

SELECT (COUNT ( DISTINCT ?uri) AS ?nbresources) 

WHERE { 
    ?uri a micamodel:MICASheet;
         dcterms:title ?title.
    FILTER regex(str(?title), "", "i")    
}

Request variables are :

  • ?uri the MICASheet URI
  • ?title the MICASheet title
  • ?nbresources the number of selected MICASheets

LinkedSheets Queries

These queries concern resources of type micamodel:LinkedSheet.

Creating a new LinkedSheet

Creating a new LinkedSheet whose URI is https://w3id.org/mica/resource/LS1 and with the following data:

  • title : Linked Sheet #1
  • summary : Linked Sheet #1 summary
  • publicURI : www.Linked.fr
  • contentType: here micamodel:MethodsAndTools
  • two writers :
    • Daniel Cassard described by a RDF resource whose URI is https://w3id.org/mica/resource/Cassard
    • François Tertre described by a RDF resource whose URI is https://w3id.org/mica/resource/Tertre
  • This LinkedSheet is annotated by 3 concepts from the MicaOntology:
    • two Domain concepts:
      • https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76 : biodiversity compensation (D6 sustainability of raw materials)
      • https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313 : environment health & safety policy (D5 raw materials policy & legal framework)
    • one Method concept
      • https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900 : risk assessment methods - MethodsScheme
  • This LinkedSheet is related to three other MICAResources (the local names of three resources are S1, S2 and S3).
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
INSERT DATA {
<https://w3id.org/mica/resource/LS1>
        a micamodel:LinkedSheet;
        dcterms:title "Linked Sheet #1";
        micamodel:summary "Linked Sheet #1 summary";
        micamodel:publicURI  "www.Linked.fr";            
        micamodel:hasContentType  micamodel:MethodsAndTools;
        micamodel:hasMethodConcept
                        <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
        micamodel:hasDomainConcept
                        <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                        <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
        micamodel:hasWriter
                        <https://w3id.org/mica/resource/Cassard>,
                        <https://w3id.org/mica/resource/Tertre>;
        micamodel:relatedTo
                        <https://w3id.org/mica/resource/S1>,
                        <https://w3id.org/mica/resource/S2>,
                        <https://w3id.org/mica/resource/S3>;
}

Updating an existing LinkedSheet

To update an existing LinkedSheet, we proceed in two steps:

  1. we remove from the triplestore all triples having that sheet as subject.
  2. we reinsert all the triples describing the LinkedSheet using the same query as the one for (Creating a new LinkedSheet).
    • For data that have not changed, triples are the same as before deletion.
    • For data that have been modified, values for the triples are the new values.
    • For data that have been added, new triples are inserted.
    • For data that have been removed, the corresponding triples are no longer present in the query.

For example to update LS1) LinkedSheet created in the previous example by changing its title (replace "Linked Sheet #1" by "Linked Sheet New Title#1", removing one author (François Tertre) and by adding a new related MICAResource (S4)

The queries will be:

  1. DELETE {  
        <https://w3id.org/mica/resource/LS1> ?p ?o.
    }
    WHERE { 
       <https://w3id.org/mica/resource/LS1> ?p ?o.
    } 
  2. PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    PREFIX dcterms: <http://purl.org/dc/terms/> 
    INSERT DATA {
    <https://w3id.org/mica/resource/LS1>
            a micamodel:LinkedSheet;
            dcterms:title "Linked Sheet New Title #1";
            micamodel:summary "Linked Sheet #1 summary";
            micamodel:publicURI  "www.Linked.fr";            
            micamodel:hasContentType  micamodel:MethodsAndTools;
            micamodel:hasMethodConcept
                            <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
            micamodel:hasDomainConcept
                            <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                            <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
            micamodel:hasWriter
                            <https://w3id.org/mica/resource/Cassard>;
            micamodel:relatedTo
                            <https://w3id.org/mica/resource/S1>,
                            <https://w3id.org/mica/resource/S2>,
                            <https://w3id.org/mica/resource/S3>,
                            <https://w3id.org/mica/resource/S4>;
    }

Deleting an existing LinkedSheet

The following query removes a given LinkedSheet from the MICA triple store. Given the sheet URI, all the triples with this URI as subject or as object are removed. If the LinkedSheet belongs to one or several flowsheets, we remove from the elements lists of these FlowSheets the corresponding FlowSheetElements and delete all the triples defining the FlowSheetElement (role and knowledge element).

For example to delete LS1 LinkedSheet, the query is:

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE
      {  
        <https://w3id.org/mica/resource/LS1> ?p ?o.
         ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/LS1>.
         ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/LS1>;
          micamodel:role ?role.
          ?node rdf:first ?element;
          rdf:rest ?rest.
          ?previousNode ?property ?node. 
     }
INSERT { ?previousNode ?property ?rest. } 
WHERE { 
      <https://w3id.org/mica/resource/LS1> ?p ?o;
      OPTIONAL {
                  ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/LS1>.
                }     
      OPTIONAL {
        ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/LS1>;
               micamodel:role ?role.
        ?node rdf:first ?element;
              rdf:rest ?rest.
        ?previousNode ?property ?node.
      }
} 

Retrieving a LinkedSheet

As for MICASheets,two options are available for retrieving queries depending on the type of information retrieved from the resources associated with the LinkedSheet:

  • retrieve the URIs of those associated resources,
  • retrieve the labels of those associated resources.
Retrieving LinkedSheet data and related resources URIs

For example, the complete query to get all the information associated to LS1 LinkedSheet is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
 SELECT DISTINCT ?title  ?summary  ?contentType ?publicURI  
(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 { 
 <https://w3id.org/mica/resource/LS1> 
            a micamodel:LinkedSheet;
            dcterms:title ?title;
            micamodel:summary ?summary;      
            micamodel:publicURI ?publicURI;       
            micamodel:hasContentType ?contentType;     
            micamodel:hasWriter ?author.  
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:relatedTo ?relatedURI. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasDomainConcept ?domain. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasMethodConcept ?method. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasSpatialConcept ?spatial. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasTemporalConcept ?temporal. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasCommodityConcept ?commodity. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasDataConcept ?data. }
            OPTIONAL{<https://w3id.org/mica/resource/LS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. }
    }
group by  ?title  ?summary  ?contentType ?publicURI 

Request variables are :

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

The complete query to get all the information associated to LS1 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 skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?title  ?summary  ?contentType ?publicURI  
(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 { 
<https://w3id.org/mica/resource/LS1>
            a micamodel:LinkedSheet;
            dcterms:title ?title;
            micamodel:summary ?summary;    
            micamodel:publicURI ?publicURI;   
            micamodel:hasContentType ?contentType;  
            micamodel:hasWriter ?author.
            ?author foaf:givenName ?firstName;
                    foaf:familyName ?lastName.
            bind(concat(?lastName," ",?firstName) as ?name)

            OPTIONAL{
                 <https://w3id.org/mica/resource/LS1> micamodel:relatedTo ?relatedURI. 
                OPTIONAL{?relatedURI dcterms:title ?relatedURILabel.} 
                OPTIONAL{?relatedURI micamodel:question ?relatedURILabel.}
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/LS1> micamodel:hasDomainConcept ?domain. 
               ?domain skos:prefLabel ?domainLabel. 
            }
            OPTIONAL{
              <https://w3id.org/mica/resource/LS1> micamodel:hasMethodConcept ?method. 
               ?method skos:prefLabel ?methodLabel.
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/LS1> micamodel:hasSpatialConcept ?spatial. 
               ?spatial skos:prefLabel ?spatialLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/LS1> micamodel:hasTemporalConcept ?temporal. 
                ?temporal skos:prefLabel ?temporalLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/LS1> micamodel:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/LS1> micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/LS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
               ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
            }
       
     }
group by  ?title  ?summary  ?contentType ?publicURI 

Request variables are :

  • ?title the LinkedSheet title
  • ?summary the LinkedSheet summary
  • ?contentType the content type (one of the value for the enumerated class micamodel:ContentType : micamodel:MethodsAndTools, micamodel:Documentation, micamodel:Legislation, Data...)
  • ?publicURI the LinkedSheet's public URI
  • ?authors a String containing the list of authors as labels of the LinkedSheet.
    Each author is represented by its name as (?lastName," ",?firstName) , and names are separated by commas.
  • ?relatedURIs a String containing the list of resources as labels that the LinkedSheet is relatedTo.
    Each resource is represented by its Label as title for micamodel:MICAKnowledgeElement
    or question for micamodel:MICAQuestion, and labels are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as labels that the LinkedSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no ValueSupplyChain concept.

Get All LinkedSheets

The following query selects all LinkedSheets by filtering with a given title text. Each metadata is represented by its label.

  • filter text is ""
  • offset is 0
  • limit is 25
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT DISTINCT ?uri ?title  ?summary  ?contentType ?publicURI 
(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:LinkedSheet;
        dcterms:title ?title;
        micamodel:summary ?summary;
        micamodel:publicURI ?publicURI;   
        micamodel:hasContentType ?contentType;  
        micamodel:hasWriter ?author. 
  
        ?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:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
                ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
        }

FILTER regex(str(?title), "", "i") }
GROUP BY ?uri ?title  ?summary  ?contentType ?publicURI  
ORDER BY ?title 
OFFSET 0 
LIMIT 25 

Request variables are :

Count LinkedSheets

The following query counts all LinkedSheets by filtering with a given title text.

  • filter text is ""
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 

SELECT (COUNT ( DISTINCT ?uri) AS ?nbresources) 
WHERE { 
    ?uri a micamodel:LinkedSheet;
         dcterms:title ?title.
    FILTER regex(str(?title), "", "i")    
}

Request variables are :

  • ?uri the LinkedSheet URI
  • ?title the LinkedSheet title
  • ?nbresources the number of selected LinkedSheets

MICAQuestions Queries

These queries concern resources of type micamodel:MICAQuestion.

Creating a new MICAQuestion

Creating a new MICAQuestion whose URI is https://w3id.org/mica/resource/MQ1 and with the following data:

  • question : MICA Question #1
  • two writers :
    • Daniel Cassard described by a RDF resource whose URI is https://w3id.org/mica/resource/Cassard
    • François Tertre described by a RDF resource whose URI is https://w3id.org/mica/resource/Tertre
  • This MICAQuestion is annotated by 3 concepts from the MicaOntology:
    • two Domain concepts:
      • https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76 : biodiversity compensation (D6 sustainability of raw materials)
      • https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313 : environment health & safety policy (D5 raw materials policy & legal framework)
    • one Method concept
      • https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900 : risk assessment methods - MethodsScheme
  • This MICAQuestion is related to three other MICAResources (the local names of three resources are S1, S2 and S3).
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
INSERT DATA {
    <https://w3id.org/mica/resource/MQ1>
        a micamodel:MICAQuestion;
        micamodel:question  "MICA Question #1";
        micamodel:hasMethodConcept
                         <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
        micamodel:hasDomainConcept
                         <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                         <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
        micamodel:hasWriter
                         <https://w3id.org/mica/resource/Cassard>,
                         <https://w3id.org/mica/resource/Tertre>;
        micamodel:relatedTo
                         <https://w3id.org/mica/resource/S1>,
                         <https://w3id.org/mica/resource/S2>,
                         <https://w3id.org/mica/resource/S3>;
}

Updating an existing MICAQuestion

To update an existing MICAQuestion, we proceed in two steps:

  1. we remove from the triplestore all triples having that question as subject.
  2. we reinsert all the triples describing the MICAQuestion using the same query as the one for (Creating a new MICAQuestion).
    • For data that have not changed, triples are the same as before deletion.
    • For data that have been modified, values for the triples are the new values.
    • For data that have been added, new triples are inserted.
    • For data that have been removed, the corresponding triples are no longer present in the query.

For example to update MQ1) MICAQuestion created in the previous example by replacing the question text (replace "MICA Question #1" by "MICA New Question #1", removing one author (François Tertre) and by adding a new related MICAResource (S4)

The queries will be:

  1. DELETE {  
        <https://w3id.org/mica/resource/MQ1> ?p ?o.
    }
    WHERE { 
       <https://w3id.org/mica/resource/MQ1> ?p ?o.
    } 
  2. PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    INSERT DATA {
        <https://w3id.org/mica/resource/MQ1>
            a micamodel:MICAQuestion;
            micamodel:question  "MICA New Question #1";
            micamodel:hasMethodConcept
                             <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
            micamodel:hasDomainConcept
                             <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                             <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
            micamodel:hasWriter
                             <https://w3id.org/mica/resource/Cassard>;
            micamodel:relatedTo
                             <https://w3id.org/mica/resource/S1>,
                             <https://w3id.org/mica/resource/S2>,
                             <https://w3id.org/mica/resource/S3>,
                             <https://w3id.org/mica/resource/S4>;
    
    }

Deleting an existing MICAQuestion

The following query removes a given MICAQuestion from the MICA triple store. Given the question URI, all the triples with this URI as subject or as object are removed.

For example to delete MQ1 MICAQuestion, the query is:

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 

DELETE
 {  
        <https://w3id.org/mica/resource/MQ1> ?p ?o.
         ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/MQ1>.
 }
 WHERE { 
        <https://w3id.org/mica/resource/MQ1> ?p ?o;
        OPTIONAL {
            ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/MQ1>.
        } 
}

Retrieving a MICAQuestion

As for MICASheets,two options are available for retrieving queries depending on the type of information retrieved from the resources associated with the MICAQuestion:

  • retrieve the URIs of those associated resources,
  • retrieve the labels of those associated resources.
Retrieving MICAQuestion data and related resources URIs

For example, the complete query to get all the information associated to MQ1 MICAQuestion is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 

SELECT DISTINCT ?question  
(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 { 
        <https://w3id.org/mica/resource/MQ1>   
                    a micamodel:MICAQuestion;
                    micamodel:question ?question; 
                    micamodel:hasWriter ?author.  
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:relatedTo ?relatedURI. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasDomainConcept ?domain. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasMethodConcept ?method. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasSpatialConcept ?spatial. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasTemporalConcept ?temporal. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasCommodityConcept ?commodity. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasDataConcept ?data. }
        OPTIONAL{<https://w3id.org/mica/resource/MQ1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. }
}
group by  ?question 

Request variables are :

  • ?question the question string
  • ?authors a String containing the list of authors as URIs of the MICAQuestion.
    Each author is represented by its URI, and URIs are separated by commas.
  • ?relatedURIs a String containing the list of resources as URIs that the MICAQuestion is relatedTo.
    Each resource is represented by its URI, and URIs are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as URIs that the MICAQuestion is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no ValueSupplyChain concept.
Retrieving MICAQuestion data and related resources labels

The complete query to get all the information associated to MQ1 MICAQuestion, in a human readable form, is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?question  
(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 { 
 <https://w3id.org/mica/resource/MQ1>
            a micamodel:MICAQuestion;
            micamodel:question ?question; 
            micamodel:hasWriter ?author.
            ?author foaf:givenName ?firstName;
                     foaf:familyName ?lastName.
            bind(concat(?lastName," ",?firstName) as ?name)

            OPTIONAL{
                 <https://w3id.org/mica/resource/MQ1> micamodel:relatedTo ?relatedURI. 
                OPTIONAL{?relatedURI dcterms:title ?relatedURILabel.} 
                OPTIONAL{?relatedURI micamodel:question ?relatedURILabel.}
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/MQ1> micamodel:hasDomainConcept ?domain. 
               ?domain skos:prefLabel ?domainLabel. 
            }
            OPTIONAL{
              <https://w3id.org/mica/resource/MQ1> micamodel:hasMethodConcept ?method. 
               ?method skos:prefLabel ?methodLabel.
            }
            OPTIONAL{
               <https://w3id.org/mica/resource/MQ1> micamodel:hasSpatialConcept ?spatial. 
               ?spatial skos:prefLabel ?spatialLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MQ1> micamodel:hasTemporalConcept ?temporal. 
                ?temporal skos:prefLabel ?temporalLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MQ1> micamodel:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MQ1> micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel.
            }
            OPTIONAL{
                <https://w3id.org/mica/resource/MQ1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
               ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
            }
}
group by  ?question 

Request variables are :

  • ?question the question string
  • ?authors a String containing the list of authors as labels of the MICAQuestion.
    Each author is represented by its name as (?lastName," ",?firstName) , and names are separated by commas.
  • ?relatedURIs a String containing the list of resources as labels that the MICAQuestion is relatedTo.
    Each resource is represented by its Label as title for micamodel:MICAKnowledgeElement
    or question for micamodel:MICAQuestion, and labels are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as labels that the MICAQuestion is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no ValueSupplyChain concept.

Get All MICAQuestions

The following query selects all MICAQuestions by filtering with a given title text. Each metadata is represented by its label.

  • filter text is ""
  • offset is 0
  • limit is 25
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?uri ?question     
    
(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;  
        ?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:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
                ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
        }

FILTER regex(str(?question), "", "i") }
GROUP BY ?uri ?question  
ORDER BY ?question
OFFSET 0 
LIMIT 25 

Request variables are :

Count MICAQuestions

The following query counts all MICAQuestions by filtering with a given title text.

  • filter text is ""
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 

SELECT (COUNT ( DISTINCT ?uri) AS ?nbresources) 

WHERE { 
    ?uri a micamodel:MICAQuestion;
         micamodel:question ?question.
    FILTER regex(str(?question), "", "i")    
}

Request variables are :

  • ?uri the MICAQuestion URI
  • ?question the question text
  • ?nbresources the number of selected MICAQuestions

FlowSheets Queries

These queries concern resources of type micamodel:FlowSheet.

Creating a new FlowSheet

Creating a new FlowSheet whose URI is https://w3id.org/mica/resource/FS1 and with the following data:

  • title : Flow Sheet #1
  • summary : Flow Sheet #1 summary
  • two writers :
    • Daniel Cassard described by a RDF resource whose URI is https://w3id.org/mica/resource/Cassard
    • François Tertre described by a RDF resource whose URI is https://w3id.org/mica/resource/Tertre
  • This FlowSheet is annotated by 3 concepts from the MicaOntology:
    • two Domain concepts:
      • https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76 : biodiversity compensation (D6 sustainability of raw materials)
      • https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313 : environment health & safety policy (D5 raw materials policy & legal framework)
    • one Method concept
      • https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900 : risk assessment methods - MethodsScheme
  • This FlowSheet is related to three other MICAResources (the local names of three resources are S1, S2 and S3).
  • This FlowSheet is composed of an ordered list of three FlowSheetElements:
    1. another FlowSheet resource FS2 with role "role1".
    2. a LinkedSheet resource LS1 with role "role2".
    3. a MICASheet resource MS1 with role "role3".
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
INSERT DATA {
    <https://w3id.org/mica/resource/FS1>
        a micamodel:FlowSheet;
        dcterms:title "Flow Sheet #1";
        micamodel:summary "Flow Sheet #1 summary";
        micamodel:hasMethodConcept
                <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
        micamodel:hasDomainConcept
                <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>,
                <https://w3id.org/mica/ontology/MicaOntology/e2badc7277b344abb4b45d794c20a313>;
        micamodel:hasWriter
                <https://w3id.org/mica/resource/Cassard>,
                <https://w3id.org/mica/resource/Tertre>;
        micamodel:relatedTo
                <https://w3id.org/mica/resource/S1>,
                <https://w3id.org/mica/resource/S2>,
                <https://w3id.org/mica/resource/S3>;
        micamodel:hasElements (                 
                [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/FS2>; micamodel:role "role1"]
                [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/LS1>; micamodel:role "role2"]
                [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/MS1>; micamodel:role "role3"]
        ) .
}

Updating an existing FlowSheet

To update an existing flowSheet, we proceed in two steps:

  1. we remove from the triplestore all triples having that FlowSheet URI as subject. We remove also all the triples defining the list of FlowSheetElements.
  2. we reinsert all the triples describing the FlowSheet using the same query as the one for (Creating a new FlowSheet).
    • For data that have not changed, triples are the same as before deletion.
    • For data that have been modified, values for the triples are the new values.
    • For data that have been added, new triples are inserted.
    • For data that have been removed, the corresponding triples are no longer present in the query.

For example to update FS1) FlowSheet created in the previous example by changing its summary
(replace "Flow Sheet #1 summary" by "Flow Sheet #1 new summary", adding one author (Daniel),
removing one domain concept (e2badc7277b344abb4b45d794c20a313) and adding a new KnowledgeElement (ELT4 with role "role4") at the end of the list of KnowledgeElments.

The queries will be:

  1. PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    DELETE
    {  
            <https://w3id.org/mica/resource/FS1> ?p ?o.
            ?z rdf:first ?head ; rdf:rest ?tail . 
            ?head micamodel:role ?role;
                  micamodel:hasKnowledgeElement ?ke.
    }
    WHERE { 
            <https://w3id.org/mica/resource/FS1> ?p ?o;
                micamodel:hasElements ?list .
            ?list rdf:rest* ?z .
            ?z rdf:first ?head ;
                rdf:rest ?tail .
            ?head micamodel:role ?role;
                micamodel:hasKnowledgeElement ?ke.
    } 
  2. PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    PREFIX dcterms: <http://purl.org/dc/terms/> 
    INSERT DATA {
    <https://w3id.org/mica/resource/FS1>
                    a micamodel:FlowSheet;
                    dcterms:title "Flow Sheet #1";
                    micamodel:summary "Flow Sheet #1 new summary";
                    micamodel:hasMethodConcept
                             <https://w3id.org/mica/ontology/MicaOntology/12bebe7935734e829fa772a0c4162900>;
                    micamodel:hasDomainConcept
                             <https://w3id.org/mica/ontology/MicaOntology/32831dae9fc247f390f1362bee1dcd76>;
                    micamodel:hasWriter
                             <https://w3id.org/mica/resource/Cassard>,
                             <https://w3id.org/mica/resource/Tertre>,
                             <https://w3id.org/mica/resource/Daniel>;
                    micamodel:relatedTo
                             <https://w3id.org/mica/resource/S1>,
                             <https://w3id.org/mica/resource/S2>,
                             <https://w3id.org/mica/resource/S3>;
                     micamodel:hasElements (                        
                            [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/FS2>; micamodel:role "role1"]
                            [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/LS1>; micamodel:role "role2"]
                            [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/MS1>; micamodel:role "role3"]
                            [ micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/ELT4>; micamodel:role "role4"]
                    ) .}

Deleting an existing FlowSheet

The following query removes a given FlowSheet from the MICA triple store. Given the sheet URI, all the triples with this URI as subject or as object are removed.
All the triples defining the ordered list of FlowSheetElements of this FlowSheet are also removed form the triple store. If the deleted FlowSheet belongs to one or several other flowsheets:

  • the corresponding FlowSheetElement is removed from the elements lists of these FlowSheets,
  • all the triples defining the FlowSheetElement (role and knowledge element) are deleted.

    For example to delete FS1 FlowSheet, the query is:

    PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    DELETE
    {  
        <https://w3id.org/mica/resource/FS1> ?p ?o.
        ?z rdf:first ?head ; rdf:rest ?tail . 
        ?head micamodel:role ?role;
                micamodel:hasKnowledgeElement ?ke.
        ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/FS1>.
        ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/FS1>;
                micamodel:role ?role1.
        ?node rdf:first ?element;
                rdf:rest ?rest.
        ?previousNode ?property ?node.
    }
    INSERT
    {
        ?previousNode ?property ?rest.
    }
    WHERE { 
        <https://w3id.org/mica/resource/FS1> ?p ?o;
        micamodel:hasElements ?list .
        ?list rdf:rest* ?z .
        ?z rdf:first ?head ;
            rdf:rest ?tail .
        ?head micamodel:role ?role;
                micamodel:hasKnowledgeElement ?ke.
        OPTIONAL {
            ?otherResource micamodel:relatedTo <https://w3id.org/mica/resource/FS1>.
        }   
        OPTIONAL
        {
            ?element micamodel:hasKnowledgeElement <https://w3id.org/mica/resource/FS1>;
                   micamodel:role ?role1.
            ?node rdf:first ?element;
                 rdf:rest ?rest.
            ?previousNode ?property ?node.
        }
    } 

Retrieving a FlowSheet data

As for MICASheets,two options are available for retrieving queries depending on the type of information retrieved from the resources associated with the FlowSheet:

  • retrieve the URIs of those associated resources,
  • retrieve the labels of those associated resources.
Retrieving FlowSheet data and related resources URIs

For example, the complete query to get all the information associated to FS1 FlowSheet is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?title  ?summary   
(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 { 
        <https://w3id.org/mica/resource/FS1> 
                a micamodel:FlowSheet;
                dcterms:title ?title;
                micamodel:summary ?summary; 
                micamodel:hasWriter ?author;
                micamodel:hasElements/rdf:rest*/rdf:first ?element.
        ?element micamodel:role ?role;
                micamodel:hasKnowledgeElement ?micaKnowledgeElementURI.
        bind(concat( str(?micaKnowledgeElementURI),";",?role) as ?sheet)  
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:relatedTo ?relatedURI. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasDomainConcept ?domain. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasMethodConcept ?method. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasSpatialConcept ?spatial. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasTemporalConcept ?temporal. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasCommodityConcept ?commodity. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasDataConcept ?data. }
        OPTIONAL { <https://w3id.org/mica/resource/FS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. }
}
group by  ?title  ?summary 

Request variables are :

  • ?title the FlowSheet title
  • ?summary the FlowSheet summary
  • ?sheets a String containing the ordered list of KnowledgeElement as URIs.
    Each KnowledgeElement is represented by its elementURI and role separated by ";". KnowledgeElements are separated by commas.
  • ?authors a String containing the list of authors as URIs of the FlowSheet.
    Each author is represented by its URI, and URIs are separated by commas.
  • ?relatedURIs a String containing the list of resources as URIs that the FlowSheet is relatedTo.
    Each resource is represented by its URI, and URIs are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as URIs that the FlowSheet is annotated with.
    Each concept is represented by its URI, and URIs are separated by commas. The string is empty if there is no ValueSupplyChain concept.
Retrieving FlowSheet data and related resources labels

The complete query to get all the information associated to FS1 FlowSheet, in a human readable form, is as follows

PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?title  ?summary    
    (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 { 
   <https://w3id.org/mica/resource/FS1>  
            a micamodel:FlowSheet;
            dcterms:title ?title;
            micamodel:summary ?summary; 
            micamodel:hasWriter ?author;
            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{
                 <https://w3id.org/mica/resource/FS1> micamodel:relatedTo ?relatedURI. 
                OPTIONAL{?relatedURI dcterms:title ?relatedURILabel.} 
                OPTIONAL{?relatedURI micamodel:question ?relatedURILabel.}
            }
    OPTIONAL{
               <https://w3id.org/mica/resource/FS1> micamodel:hasDomainConcept ?domain. 
               ?domain skos:prefLabel ?domainLabel. 
            }
    OPTIONAL{
              <https://w3id.org/mica/resource/FS1> micamodel:hasMethodConcept ?method. 
               ?method skos:prefLabel ?methodLabel.
            }
    OPTIONAL{
               <https://w3id.org/mica/resource/FS1> micamodel:hasSpatialConcept ?spatial. 
               ?spatial skos:prefLabel ?spatialLabel.
            }
    OPTIONAL{
                <https://w3id.org/mica/resource/FS1> micamodel:hasTemporalConcept ?temporal. 
                ?temporal skos:prefLabel ?temporalLabel.
            }
    OPTIONAL{
                <https://w3id.org/mica/resource/FS1> micamodel:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
            }
    OPTIONAL{
                <https://w3id.org/mica/resource/FS1> micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel.
            }
    OPTIONAL{
                <https://w3id.org/mica/resource/FS1> micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
               ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
            }
            
 }
group by  ?title  ?summary 

Request variables are :

  • ?title the FlowSheet title
  • ?summary the FlowSheet summary
  • ?sheets a String containing the ordered list of KnowledgeElement as labels.
    Each KnowledgeElement is represented by its element's label and role separated by ";". KnowledgeElements are separated by commas.
  • ?authors a String containing the list of authors as labels of the FlowSheet.
    Each author is represented by its name as (?lastName," ",?firstName) , and names are separated by commas.
  • ?relatedURIs a String containing the list of resources as labels that the FlowSheet is relatedTo.
    Each resource is represented by its Label as title for micamodel:MICAKnowledgeElement
    or question for micamodel:MICAQuestion, and labels are separated by commas. The string is empty if there is no related resource.
  • ?domains a String containing the list of Domain concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Domain concept.
  • ?methods a String containing the list of Method concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no method concept.
  • ?spatials a String containing the list of Spatial concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Spatial concept.
  • ?temporals a String containing the list of Temporal concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Temporal concept.
  • ?commodities a String containing the list of Commodity concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Commodity concept.
  • ?datas a String containing the list of Data concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no Data concept.
  • ?valueSupplyChains a String containing the list of ValueSupplyChain concepts as labels that the FlowSheet is annotated with.
    Each concept is represented by its prefLabel, and prefLabels are separated by commas. The string is empty if there is no ValueSupplyChain concept.

Get All flowSheets

The following query selects all flowSheets by filtering by a given title text. Each metadata is represented by its label.

  • filter text is ""
  • offset is 0
  • limit is 25
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?uri ?title  ?summary    
(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: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:hasCommodityConcept ?commodity. 
                ?commodity skos:prefLabel ?commodityLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasDataConcept ?data. 
                ?data skos:prefLabel ?dataLabel. 
         }
        OPTIONAL{
                ?uri micamodel:hasValueSupplyChainConcept ?valueSupplyChain. 
                ?valueSupplyChain skos:prefLabel ?valueSupplyChainLabel.
        }

FILTER regex(str(?title), "", "i") }
GROUP BY ?uri ?title  ?summary   
ORDER BY ?title 
OFFSET 0 
LIMIT 25 

Request variables are :

Count FlowSheets

The following query counts all FlowSheets by filtering with a given title text.

  • filter text is ""
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 
PREFIX dcterms: <http://purl.org/dc/terms/> 

SELECT (COUNT ( DISTINCT ?uri) AS ?nbresources) 

WHERE { 
    ?uri a micamodel:FlowSheet;
         dcterms:title ?title.
    FILTER regex(str(?title), "", "i")    
}

Request variables are :

  • ?uri the flowSheet URI
  • ?title the flowSheet title
  • ?nbresources the number of selected FlowSheets

RelatedResources Queries

Create a relatedTo relation between two Resources

The following query creates a relatedTo relation between two Resources:

  • FS1 a FlowSheet
  • MQ1 a MICAQuestion
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 

INSERT DATA {
             
   <https://w3id.org/mica/resource/FS1> micamodel:relatedTo <https://w3id.org/mica/resource/MQ1>  .
  }

Remove a relatedTo relation between two Resources

The following query removes a relatedTo relation between two MICAResources :

  • FS1 a FlowSheet
  • MQ1 a MICAQuestion
PREFIX micamodel: <https://w3id.org/mica/ontology/MicaModel#> 

DELETE {
  <https://w3id.org/mica/resource/FS1> micamodel:relatedTo <https://w3id.org/mica/resource/MQ1> .
  <https://w3id.org/mica/resource/MQ1> micamodel:relatedTo  <https://w3id.org/mica/resource/FS1>. 
      }
WHERE {
   <https://w3id.org/mica/resource/FS1> micamodel:relatedTo <https://w3id.org/mica/resource/MQ1> .
     }

List of relatedTo

The following query get a list of relation relatedTo by filtering by a given text for label.

  • filter text is ""
  • offset is 0
  • limit is 25
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), "", "i") 

    OPTIONAL{?relatedURI dcterms:title ?relatedURILabel.} 
    OPTIONAL{?relatedURI micamodel:question ?relatedURILabel.} 
        }
 OFFSET 0 
 LIMIT 25

Request variables are :

  • ?uri the Resource URI
  • ?relatedURI the related Resource URI
  • ?uriLabel the label of uri
  • ?relatedURILabel the related Resource label

Count the relatedTo

The following query counts all relatedTo relation by filtering with a given text.

  • filter text is ""
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), "", "i") 
}

Request variables are :

  • ?uri the MICAResource URI