MICA FlowSheet

This document shows some example of managing a flowSheet.

A flowsheet is an ordered list of Sheets.

Create a Flowsheet

Given that a flowsheet is a sheet, it must contain the same elements as a sheet such the title, description, status and author.

In addition of these elements, A FlowSheet contains an ordered list of sheets. An ordered list is describe as follows:

 micaresource:FlowSheetValueAdded rdf:type micamodel:FlowSheet;
                                  .........................
                                 micamodel:content ( micaresource:FactSheetMineClosure 
                                                    micaresource:DocSheetStocksInUse 
                                                    micaresource:DefSheetCircularEconomy
                                                    micaresource:WebDocumentResourceWebsite 
                                                    micaresource:MicaDataResourceGlassWaste ).      

The RDF code above shows the simple way to create a flowsheet. But this is equivalent to the following graph and RDF code.

Create a FlowSheet.
 micaresource:FlowSheetValueAdded micamodel:content _:b0 .
_:b0  rdf:first micaresource:FactSheetMineClosure.
_:b0  rdf:rest   _:b1 .
_:b1  rdf:first micaresource:DocSheetStocksInUse.
_:b1  rdf:rest   _:b2 .
_:b2  rdf:first micaresource:DefSheetCircularEconomy.
_:b2  rdf:rest   _:b3 .
_:b3  rdf:first micaresource:WebDocumentResourceWebsite .
_:b3  rdf:rest   _:b4 .
_:b4  rdf:first  micaresource:MicaDataResourceGlassWaste .
_:b4  rdf:rest   rdf:nil.     

Select one or several sheets

Select the first Sheet

Select the first Sheet.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT  ?firstSheet 
      
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content ?list .
  ?list rdf:first ?firstSheet .
} 

Select a NTh element

Select a third member from flowSheet

Select the third Sheet.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?sheet
WHERE {
  micaresource:FlowSheetValueAdded micamodel:content/rdf:rest{2}/rdf:first ?sheet.
}

Select the last element

Select the last Sheet.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?lastSheet 
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content ?list .
  ?list rdf:rest+ ?lastlist .
  ?lastlist rdf:rest rdf:nil .
  ?lastlist  rdf:first ?lastSheet .
}

Select all elements

Select all Sheets.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?sheet
WHERE {
  micaresource:FlowSheetValueAdded micamodel:content/rdf:rest*/rdf:first ?sheet
}

Insert a given sheet in a flowsheet

Insert a sheet at the first position

Insert at the first position.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE { micaresource:FlowSheetValueAdded micamodel:content ?list }
INSERT { micaresource:FlowSheetValueAdded micamodel:content [ rdf:first micaresource:FactSheetABM ; 
                 rdf:rest ?list ]
       }
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content  ?list .
}

Insert a sheet at the specific position in FlowSheet

Insert at the third position.

Insert a third member

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

DELETE {
  ?insertionPoint rdf:rest ?rest . 
}
INSERT {
  _:b1 rdf:first micaresource:FactSheetABM ; rdf:rest ?rest . 
  ?insertionPoint rdf:rest _:b1 . 
}
WHERE {
   micaresource:FlowSheetValueAdded micamodel:content/rdf:rest{2}/rdf:first ?item .
  ?insertionPoint rdf:first ?item ; rdf:rest ?rest . 
}

Insert a sheet to the end of FlowSheet

Insert at the end position.

The order here is important.

If the elements in list are more than one ( list of length >= 1)

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

DELETE { ?lastSheet rdf:rest rdf:nil }
INSERT { ?lastSheet rdf:rest [ rdf:first micaresource:FactSheetABM ; rdf:rest rdf:nil ] }
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content ?list .
  ?list rdf:rest+ ?lastSheet .
  ?lastSheet rdf:rest rdf:nil .
};

If the elements in list are zero ( list of length = 0 )

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

DELETE { micaresource:FlowSheetValueAdded micamodel:content rdf:nil . }
INSERT { micaresource:FlowSheetValueAdded micamodel:content [ rdf:first micaresource:FactSheetABM ; rdf:rest rdf:nil ] }
WHERE
{
   micaresource:FlowSheetValueAdded micamodel:content rdf:nil .
}

Delete a given sheet in a flowsheet

Delete a sheet to the start of FlowSheet

delete a sheet.

List of length 1

Do before other lists.

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

DELETE { micaresource:FlowSheetValueAdded micamodel:content ?firstSheet .
         ?firstSheet  rdf:first ?v .
         ?firstSheet  rdf:rest  rdf:nil .
       }
INSERT { micaresource:FlowSheetValueAdded micamodel:content rdf:nil . }
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content ?firstSheet .
  ?firstSheet rdf:first ?v ;
       rdf:rest rdf:nil .
} ;
delete a sheet.

List of length >= 2

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

DELETE { ?elt1 rdf:rest ?elt .
         ?elt  rdf:first ?v .
         ?elt  rdf:rest  rdf:nil .
       }
INSERT { ?elt1 rdf:rest rdf:nil }
WHERE
{
  micaresource:FlowSheetValueAdded micamodel:content ?list .
  ?list rdf:rest* ?elt1 .

  # Second to end.
  ?elt1 rdf:rest ?elt .
  # End.
  ?elt rdf:first ?v ;
       rdf:rest rdf:nil .
}

Delete a sheet at the specific position in FlowSheet

delete a sheet.
prefix micaresource: <https://w3id.org/mica/resource/> 
prefix micamodel: <https://w3id.org/mica/ontology/MicaModel#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

DELETE {
  ?previousMember rdf:rest ?deletionPoint .
  ?deletionPoint rdf:rest ?rest . 
  ?s ?p ?item   . 
  ?item ?s ?p . 
}
INSERT {
  ?previousMember rdf:rest ?rest.
}
WHERE {
  micaresource:FlowSheetValueAdded micamodel:content/rdf:rest/rdf:rest/rdf:first ?item .
  ?deletionPoint rdf:first ?item ;  rdf:rest ?rest . 
  ?previousMember rdf:rest ?deletionPoint .
  ?s ?p ?item . 
  OPTIONAL { ?item ?s ?o . }
}