SPIN_EP-DDR-constraints.spin.ttl 7.9 KB
# baseURI: http://www.reportinghub.no/ep/spin/ddr-constraints
# imports: http://spinrdf.org/spin
# imports: http://topbraid.org/sxml
# imports: http://www.reportinghub.no/np/schema/1.0/npd
# imports: http://www.reportinghub.no/spin/rh
# imports: http://www.witsml.org/schemas/1series

@prefix :        <http://www.reportinghub.no/ep/spin/ddr-constraints#> .
@prefix arg:     <http://spinrdf.org/arg#> .
@prefix ddr:     <http://www.witsml.org/schemas/1series#> .
@prefix fn:      <http://www.w3.org/2005/xpath-functions#> .
@prefix normalization:  <http://www.reportinghub.no/ep/transform/1.1/normalization#> .
@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/spin/ddr-constraints>
      rdf:type owl:Ontology ;
      rdfs:comment "Constraints that need to be executed immediately after SXML import, i.e. not on the inferred triples."^^xsd:string ;
      owl:imports <http://spinrdf.org/spin> , <http://topbraid.org/sxml> , <http://www.reportinghub.no/np/schema/1.0/npd> , <http://www.reportinghub.no/spin/rh> , <http://www.witsml.org/schemas/1series> ;
      owl:versionInfo "0.2.0"^^xsd:string .

ddr:Obj_drillReport
      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 ddr:nameWellbore ;
                            sp:predicate spin:violationPath ;
                            sp:subject _:b1
                          ] [ sp:object
                                    [ sp:varName "message"^^xsd:string
                                    ] ;
                            sp:predicate rdfs:label ;
                            sp:subject _:b1
                          ]) ;
                sp:where ([ sp:object
                                    [ sp:varName "wellBoreName"^^xsd:string
                                    ] ;
                            sp:predicate <http://www.reportinghub.no/ep/spin/lib#nameWellbore> ;
                            sp:subject spin:_this
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type rhspin:wellBoreByName ;
                                      arg:wellBoreName
                                              [ sp:varName "wellBoreName"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "wellBore"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Filter ;
                            sp:expression
                                    [ rdf:type sp:not ;
                                      sp:arg1 [ rdf:type sp:bound ;
                                                sp:arg1 [ sp:varName "wellBore"^^xsd:string
                                                        ]
                                              ]
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type fn:concat ;
                                      sp:arg1 "Unregistered well bore name " ;
                                      sp:arg2 [ sp:varName "wellBoreName"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "message"^^xsd:string
                                    ]
                          ])
              ] ;
      spin:constraint
              [ rdf:type sp:Ask ;
                rdfs:comment "DDRs can only be submitted if a user is logged in"^^xsd:string ;
                sp:where ([ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type rhspin:companyName
                                    ] ;
                            sp:variable
                                    [ sp:varName "companyName"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Filter ;
                            sp:expression
                                    [ rdf:type sp:not ;
                                      sp:arg1 [ rdf:type sp:bound ;
                                                sp:arg1 [ sp:varName "companyName"^^xsd:string
                                                        ]
                                              ]
                                    ]
                          ])
              ] ;
      spin:constraint
              [ rdf:type sp:Construct ;
                sp:templates ([ sp:object spin:ConstraintViolation ;
                            sp:predicate rdf:type ;
                            sp:subject _:b2
                          ] [ sp:object spin:_this ;
                            sp:predicate spin:violationRoot ;
                            sp:subject _:b2
                          ] [ sp:object ddr:nameWell ;
                            sp:predicate spin:violationPath ;
                            sp:subject _:b2
                          ] [ sp:object
                                    [ sp:varName "message"^^xsd:string
                                    ] ;
                            sp:predicate rdfs:label ;
                            sp:subject _:b2
                          ]) ;
                sp:where ([ sp:object
                                    [ sp:varName "wellName"^^xsd:string
                                    ] ;
                            sp:predicate ddr:nameWell ;
                            sp:subject spin:_this
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type rhspin:wellByName ;
                                      arg:wellName
                                              [ sp:varName "wellName"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "well"^^xsd:string
                                    ]
                          ] [ rdf:type sp:Filter ;
                            sp:expression
                                    [ rdf:type sp:not ;
                                      sp:arg1 [ rdf:type rhspin:npdTripleExists ;
                                                sp:arg1 [ sp:varName "well"^^xsd:string
                                                        ] ;
                                                sp:arg2 rdf:type ;
                                                sp:arg3 <http://www.reportinghub.no/ep/schema/well#Well>
                                              ]
                                    ]
                          ] [ rdf:type sp:Bind ;
                            sp:expression
                                    [ rdf:type fn:concat ;
                                      sp:arg1 "Unregistered well name " ;
                                      sp:arg2 [ sp:varName "wellName"^^xsd:string
                                              ]
                                    ] ;
                            sp:variable
                                    [ sp:varName "message"^^xsd:string
                                    ]
                          ])
              ] .