SPIN_EP-REPORT-constraints.spin.ttl 7.17 KB
# baseURI: http://www.reportinghub.no/ep/spin/report-constraints
# imports: http://spinrdf.org/spin
# imports: http://www.reportinghub.no/ep/schema/1.0/activity
# imports: http://www.reportinghub.no/ep/schema/1.0/core
# imports: http://www.reportinghub.no/ep/schema/1.0/equipment
# imports: http://www.reportinghub.no/ep/schema/1.0/facility
# imports: http://www.reportinghub.no/ep/schema/1.0/organization
# imports: http://www.reportinghub.no/ep/schema/1.0/report
# imports: http://www.reportinghub.no/ep/schema/1.0/well
# imports: http://www.reportinghub.no/np/schema/1.0/npd
# imports: http://www.reportinghub.no/spin/rh

@prefix :        <http://www.reportinghub.no/ep/spin/report-constraints#> .
@prefix arg:     <http://spinrdf.org/arg#> .
@prefix fn:      <http://www.w3.org/2005/xpath-functions#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rhspin:  <http://www.reportinghub.no/spin/rh#> .
@prefix sp:      <http://spinrdf.org/sp#> .
@prefix spin:    <http://spinrdf.org/spin#> .
@prefix spl:     <http://spinrdf.org/spl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .

<http://www.reportinghub.no/ep/schema/report#FinalDailyDrillingReport>
      rdfs:subClassOf :DDRSuperclass .

<http://www.reportinghub.no/ep/schema/report#NormalDailyDrillingReport>
      rdfs:subClassOf :DDRSuperclass .

<http://www.reportinghub.no/ep/schema/report#PreliminaryDailyDrillingReport>
      rdfs:subClassOf :DDRSuperclass .

<http://www.reportinghub.no/ep/spin/report-constraints>
      rdf:type owl:Ontology ;
      rdfs:comment "Constraints that need to be executed after ep-report:Report generation (without SXML triples)."^^xsd:string ;
      owl:imports <http://spinrdf.org/spin> , <http://www.reportinghub.no/ep/schema/1.0/activity> , <http://www.reportinghub.no/ep/schema/1.0/core> , <http://www.reportinghub.no/ep/schema/1.0/equipment> , <http://www.reportinghub.no/ep/schema/1.0/facility> , <http://www.reportinghub.no/ep/schema/1.0/organization> , <http://www.reportinghub.no/ep/schema/1.0/report> , <http://www.reportinghub.no/ep/schema/1.0/well> , <http://www.reportinghub.no/np/schema/1.0/npd> , <http://www.reportinghub.no/spin/rh> ;
      owl:versionInfo "0.1.0"^^xsd:string .

:DDRSuperclass
      rdf:type owl:Class ;
      rdfs:comment "Abstract superclass to make sure that constraints are only reported on the subclasses of DDR."^^xsd:string ;
      rdfs:label "DDRSuperclass"^^xsd:string ;
      rdfs:subClassOf owl:Thing ;
      spin:constraint
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object spin:ConstraintViolation ;
                            sp:predicate rdf:type ;
                            sp:subject _:b1
                          ] [ sp:object spin:_this ;
                            sp:predicate spin:violationRoot ;
                            sp:subject _:b1
                          ] [ sp:object
                                    [ sp:varName "message"^^xsd:string
                                    ] ;
                            sp:predicate rdfs:label ;
                            sp:subject _:b1
                          ]) ;
                sp:where ([ rdf:type sp:TriplePath ;
                            sp:object
                                    [ sp:varName "wellBore"^^xsd:string
                                    ] ;
                            sp:path [ rdf:type sp:SeqPath ;
                                      sp:path1
                                              [ rdf:type sp:SeqPath ;
                                                sp:path1 <http://www.reportinghub.no/ep/schema/report#reportOn> ;
                                                sp:path2 <http://www.reportinghub.no/ep/schema/activity#onWellBore>
                                              ] ;
                                      sp:path2 <http://www.reportinghub.no/ep/schema/core#temporalPartOf>
                                    ] ;
                            sp:subject spin:_this
                          ] [ rdf:type sp:Filter ;
                            sp:expression
                                    [ rdf:type sp:not ;
                                      sp:arg1 [ rdf:type rhspin:currentUserIsOperatorOfWellBore ;
                                                arg:wellBore
                                                        [ sp:varName "wellBore"^^xsd:string
                                                        ]
                                              ]
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type sp:coalesce ;
                                      sp:arg1 [ rdf:type rhspin:npdName ;
                                                arg:resource
                                                        [ sp:varName "wellBore"^^xsd:string
                                                        ]
                                              ] ;
                                      sp:arg2 "Unknown well bore"
                                    ] ;
                            sp:variable
                                    [ sp:varName "wellBoreName"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type sp:coalesce ;
                                      sp:arg1 [ rdf:type rhspin:npdName ;
                                                arg:resource
                                                        [ sp:varName "licence"^^xsd:string
                                                        ]
                                              ] ;
                                      sp:arg2 "Unknown licence"
                                    ] ;
                            sp:variable
                                    [ sp:varName "licenceName"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type rhspin:companyName
                                    ] ;
                            sp:variable
                                    [ sp:varName "companyName"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type fn:concat ;
                                      sp:arg1 "[RH-11] Your company (" ;
                                      sp:arg2 [ sp:varName "companyName"^^xsd:string
                                              ] ;
                                      sp:arg3 ") is not the operator of the BAA or licence associated with well bore " ;
                                      sp:arg4 [ sp:varName "wellBoreName"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "message"^^xsd:string
                                    ]
                          ])
              ] .