Holger Knublauch

First version of MPR SPIN constraints

# baseURI: null
@prefix composite: <http://www.topbraid.org/2007/05/composite.owl#> .
@prefix forms: <http://www.topbraid.org/2007/01/forms.owl#> .
@prefix inference: <http://www.topbraid.org/2007/06/inference.owl#> .
@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 visual: <http://topbraid.org/visual#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[] rdf:type inference:Configuration ;
composite:child
[ rdf:type <http://spinrdf.org/spin#TopSPIN> ;
composite:index "0"^^xsd:int
] .
# baseURI: http://www.reportinghub.no/ep/spin/mpr-proxy-constraints
# imports: http://spinrdf.org/spin
# imports: http://www.epim.no/schemas/mprml/1
# imports: http://www.reportinghub.no/spin/rh
@prefix afn: <http://jena.hpl.hp.com/ARQ/function#> .
@prefix arg: <http://spinrdf.org/arg#> .
@prefix fn: <http://www.w3.org/2005/xpath-functions#> .
@prefix mpr-proxy-constraints: <http://www.reportinghub.no/ep/spin/mpr-proxy-constraints#> .
@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#> .
arg:kindRef
rdf:type rdf:Property ;
rdfs:label "kind ref"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
<http://www.epim.no/schemas/mprml/1#Cs_businessAssociate>
spin:constraint
[ rdf:type sp:Construct ;
sp:templates ([ sp:object spin:ConstraintViolation ;
sp:predicate rdf:type ;
sp:subject _:b1
] [ sp:object
[ sp:varName "message"^^xsd:string
] ;
sp:predicate rdfs:label ;
sp:subject _:b1
]) ;
sp:where ([ sp:object
[ sp:varName "name"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#name> ;
sp:subject spin:_this
] [ rdf:type sp:TriplePath ;
sp:object "Operating Company" ;
sp:path [ rdf:type sp:SeqPath ;
sp:path1 <http://www.epim.no/schemas/mprml/1#roleRef> ;
sp:path2 <http://www.linkedmodel.org/schema/dtype#value>
] ;
sp:subject spin:_this
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:companyWithName ;
arg:name
[ sp:varName "name"^^xsd:string
]
] ;
sp:variable
[ sp:varName "company"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "company"^^xsd:string
]
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:concat ;
sp:arg1 "Invalid company name " ;
sp:arg2 [ sp:varName "name"^^xsd:string
]
] ;
sp:variable
[ sp:varName "message"^^xsd:string
]
])
] .
<http://www.epim.no/schemas/mprml/1#FacilityIdentifierStruct>
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckId ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_terminal> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Facility>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckId ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_field> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Field>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckId ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_field> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Field>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckId ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_platform> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Platform>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckId ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_wellbore> ;
arg:type <http://www.reportinghub.no/ep/schema/well#WellBore>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckName ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_terminal> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Facility>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckName ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_platform> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Platform>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckName ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_wellbore> ;
arg:type <http://www.reportinghub.no/ep/schema/well#WellBore>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckIdAndNameMatch ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_terminal> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Facility>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckIdAndNameMatch ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_field> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Field>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckIdAndNameMatch ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_platform> ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Platform>
] ;
spin:constraint
[ rdf:type mpr-proxy-constraints:CheckIdAndNameMatch ;
arg:kindRef <http://www.epim.no/schemas/mprml/1#RF_wellbore> ;
arg:type <http://www.reportinghub.no/ep/schema/well#WellBore>
] .
<http://www.epim.no/schemas/mprml/1#Obj_productVolume>
spin:constraint
[ rdf:type sp:Construct ;
sp:templates ([ sp:object spin:ConstraintViolation ;
sp:predicate rdf:type ;
sp:subject _:b2
] [ sp:object
[ sp:varName "message"^^xsd:string
] ;
sp:predicate rdfs:label ;
sp:subject _:b2
]) ;
sp:where ([ rdf:type sp:TriplePath ;
sp:object
[ sp:varName "name"^^xsd:string
] ;
sp:path [ rdf:type sp:SeqPath ;
sp:path1 <http://www.epim.no/schemas/mprml/1#nameRef> ;
sp:path2 <http://www.linkedmodel.org/schema/dtype#value>
] ;
sp:subject spin:_this
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:npdIndividualByName ;
arg:name
[ sp:varName "name"^^xsd:string
] ;
arg:type <http://www.reportinghub.no/ep/schema/facility#Field>
] ;
sp:variable
[ sp:varName "field"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "field"^^xsd:string
]
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:concat ;
sp:arg1 "Invalid Field name " ;
sp:arg2 [ sp:varName "name"^^xsd:string
]
] ;
sp:variable
[ sp:varName "message"^^xsd:string
]
])
] .
<http://www.reportinghub.no/ep/spin/mpr-proxy-constraints>
rdf:type owl:Ontology ;
rdfs:comment "Collection of constraints that are executed on the SXML proxy ontology for MPR schema based reports."^^xsd:string ;
owl:imports <http://spinrdf.org/spin> , <http://www.epim.no/schemas/mprml/1> , <http://www.reportinghub.no/spin/rh> ;
owl:versionInfo "0.1.0"^^xsd:string .
mpr-proxy-constraints:CheckId
rdf:type spin:ConstructTemplate ;
rdfs:label "Check id"^^xsd:string ;
rdfs:subClassOf mpr-proxy-constraints:ConstraintTemplates ;
spin:body
[ rdf:type sp:Construct ;
sp:templates ([ sp:object spin:ConstraintViolation ;
sp:predicate rdf:type ;
sp:subject _:b3
] [ sp:object
[ sp:varName "message"^^xsd:string
] ;
sp:predicate rdfs:label ;
sp:subject _:b3
]) ;
sp:where ([ sp:object
[ sp:varName "kindRef"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#kindRef> ;
sp:subject spin:_this
] [ sp:object "NPD" ;
sp:predicate <http://www.epim.no/schemas/mprml/1#namingSystem> ;
sp:subject spin:_this
] [ sp:object
[ sp:varName "id"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#uidRefValue> ;
sp:subject spin:_this
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:npdIndividualById ;
arg:id [ sp:varName "id"^^xsd:string
] ;
arg:type
[ sp:varName "type"^^xsd:string
]
] ;
sp:variable
[ sp:varName "npd"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "npd"^^xsd:string
]
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:concat ;
sp:arg1 "[RH-19] Invalid " ;
sp:arg2 [ rdf:type afn:localname ;
sp:arg1 [ sp:varName "type"^^xsd:string
]
] ;
sp:arg3 " id " ;
sp:arg4 [ sp:varName "id"^^xsd:string
]
] ;
sp:variable
[ sp:varName "message"^^xsd:string
]
])
] ;
spin:labelTemplate "Must be NPD id of {?type}/{?kindRef}"^^xsd:string .
mpr-proxy-constraints:CheckIdAndNameMatch
rdf:type spin:ConstructTemplate ;
rdfs:label "NPD id and name must match"^^xsd:string ;
rdfs:subClassOf mpr-proxy-constraints:ConstraintTemplates ;
spin:body
[ rdf:type sp:Construct ;
sp:templates ([ sp:object spin:ConstraintViolation ;
sp:predicate rdf:type ;
sp:subject _:b4
] [ sp:object
[ sp:varName "message"^^xsd:string
] ;
sp:predicate rdfs:label ;
sp:subject _:b4
]) ;
sp:where ([ sp:object
[ sp:varName "kindRef"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#kindRef> ;
sp:subject spin:_this
] [ sp:object "NPD" ;
sp:predicate <http://www.epim.no/schemas/mprml/1#namingSystem> ;
sp:subject spin:_this
] [ sp:object
[ sp:varName "name"^^xsd:string
] ;
sp:predicate <http://www.linkedmodel.org/schema/dtype#value> ;
sp:subject spin:_this
] [ sp:object
[ sp:varName "id"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#uidRefValue> ;
sp:subject spin:_this
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:npdIndividualById ;
arg:id [ sp:varName "id"^^xsd:string
] ;
arg:type
[ sp:varName "type"^^xsd:string
]
] ;
sp:variable
[ sp:varName "byId"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:npdIndividualByName ;
arg:name
[ sp:varName "name"^^xsd:string
] ;
arg:type
[ sp:varName "type"^^xsd:string
]
] ;
sp:variable
[ sp:varName "byName"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:or ;
sp:arg1 [ rdf:type sp:or ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "byId"^^xsd:string
]
] ;
sp:arg2 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "byName"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type sp:ne ;
sp:arg1 [ sp:varName "byId"^^xsd:string
] ;
sp:arg2 [ sp:varName "byName"^^xsd:string
]
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:concat ;
sp:arg1 "[RH-19] Mismatching " ;
sp:arg2 [ rdf:type afn:localname ;
sp:arg1 [ sp:varName "type"^^xsd:string
]
] ;
sp:arg3 " id: " ;
sp:arg4 [ sp:varName "id"^^xsd:string
] ;
sp:arg5 " is not the NPD id of " ;
sp:arg6 [ sp:varName "name"^^xsd:string
]
] ;
sp:variable
[ sp:varName "message"^^xsd:string
]
])
] ;
spin:labelTemplate "NPD name and id of {?type}/{?kindRef} must match"^^xsd:string .
mpr-proxy-constraints:CheckName
rdf:type spin:ConstructTemplate ;
rdfs:label "Check name"^^xsd:string ;
rdfs:subClassOf mpr-proxy-constraints:ConstraintTemplates ;
spin:body
[ rdf:type sp:Construct ;
sp:templates ([ sp:object spin:ConstraintViolation ;
sp:predicate rdf:type ;
sp:subject _:b5
] [ sp:object
[ sp:varName "message"^^xsd:string
] ;
sp:predicate rdfs:label ;
sp:subject _:b5
]) ;
sp:where ([ sp:object
[ sp:varName "kindRef"^^xsd:string
] ;
sp:predicate <http://www.epim.no/schemas/mprml/1#kindRef> ;
sp:subject spin:_this
] [ sp:object "NPD" ;
sp:predicate <http://www.epim.no/schemas/mprml/1#namingSystem> ;
sp:subject spin:_this
] [ sp:object
[ sp:varName "name"^^xsd:string
] ;
sp:predicate <http://www.linkedmodel.org/schema/dtype#value> ;
sp:subject spin:_this
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:npdIndividualByName ;
arg:name
[ sp:varName "name"^^xsd:string
] ;
arg:type
[ sp:varName "type"^^xsd:string
]
] ;
sp:variable
[ sp:varName "npd"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "npd"^^xsd:string
]
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:concat ;
sp:arg1 [ rdf:type sp:add ;
sp:arg1 "[RH-19] Invalid " ;
sp:arg2 [ rdf:type afn:localname ;
sp:arg1 [ sp:varName "type"^^xsd:string
]
]
] ;
sp:arg2 " name " ;
sp:arg3 [ sp:varName "name"^^xsd:string
]
] ;
sp:variable
[ sp:varName "message"^^xsd:string
]
])
] ;
spin:labelTemplate "Must be NPD name of {?type}/{?kindRef}"^^xsd:string .
mpr-proxy-constraints:ConstraintTemplates
rdf:type spin:ConstructTemplate ;
rdfs:label "Constraint templates"^^xsd:string ;
rdfs:subClassOf spin:ConstructTemplates ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The kind reference value."^^xsd:string ;
spl:predicate arg:kindRef ;
spl:valueType <http://www.epim.no/schemas/mprml/1#ReportingFacility>
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The NPD type that the individual needs to have."^^xsd:string ;
spl:predicate arg:type ;
spl:valueType rdfs:Class
] .