Holger Knublauch

Updated DDR upload constraints to depend on BAA and then PL

......@@ -69,47 +69,12 @@
sp:path2 <http://www.reportinghub.no/ep/schema/core#temporalPartOf>
] ;
sp:subject spin:_this
] [ 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 rhspin:companyWithName ;
arg:name
[ sp:varName "companyName"^^xsd:string
]
] ;
sp:variable
[ sp:varName "company"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:bound ;
sp:arg1 [ sp:varName "company"^^xsd:string
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type rhspin:licenceForWellBore ;
arg:wellBore
[ sp:varName "wellBore"^^xsd:string
]
] ;
sp:variable
[ sp:varName "licence"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type rhspin:npdTripleExists ;
sp:arg1 [ sp:varName "licence"^^xsd:string
] ;
sp:arg2 <http://www.reportinghub.no/np/schema/npd#licenceOperator> ;
sp:arg3 [ sp:varName "company"^^xsd:string
sp:arg1 [ rdf:type rhspin:currentUserIsOperatorOfWellBore ;
arg:wellBore
[ sp:varName "wellBore"^^xsd:string
]
]
]
......@@ -141,15 +106,19 @@
]
] [ 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 "Your company (" ;
sp:arg2 [ sp:varName "companyName"^^xsd:string
] ;
sp:arg3 ") is not the operator of licence " ;
sp:arg4 [ sp:varName "licenceName"^^xsd:string
] ;
sp:arg5 " for well bore " ;
sp:arg6 [ sp:varName "wellBoreName"^^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
......
......@@ -971,6 +971,70 @@ rhspin:currentUserIsOperatorOfOwner
] ;
spin:returnType xsd:boolean .
rhspin:currentUserIsOperatorOfWellBore
rdf:type spin:Function ;
rdfs:comment "Checks if the currently logged in user works for a company that is the operator of a given well bore. If the well bore is part of a field that is managed by a BAA, then the company must be the operator of the BAA. Otherwise it will check the operator of the production licence attached to the well bore. This function is used to verify whether the current user can upload DDRs for the given well bore."^^xsd:string ;
rdfs:label "current user is operator of well bore"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Ask ;
sp:where ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type sp:coalesce ;
sp:arg1 [ rdf:type rhspin:wellBoreBAAOperator ;
arg:wellBore
[ sp:varName "wellBore"^^xsd:string
]
] ;
sp:arg2 [ rdf:type rhspin:wellBoreLicenceOperator ;
arg:wellBore
[ sp:varName "wellBore"^^xsd:string
]
]
] ;
sp:variable
[ sp:varName "operator"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:bound ;
sp:arg1 [ sp:varName "operator"^^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 rhspin:companyWithName ;
arg:name
[ sp:varName "companyName"^^xsd:string
]
] ;
sp:variable
[ sp:varName "company"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:eq ;
sp:arg1 [ sp:varName "company"^^xsd:string
] ;
sp:arg2 [ sp:varName "operator"^^xsd:string
]
]
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The well bore to check."^^xsd:string ;
spl:predicate arg:wellBore ;
spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
] .
rhspin:ddrActivityStartDate
rdf:type spin:Function ;
rdfs:comment "Gets the declared start time of the activity in a DDR, as an xsd:date literal."^^xsd:string ;
......@@ -2149,6 +2213,57 @@ rhspin:userName
rdfs:subClassOf spin:Functions ;
spin:returnType xsd:string .
rhspin:wellBoreBAAOperator
rdf:type spin:Function ;
rdfs:comment "If a given well bore is part of a field that has a BAA as its owner, then this function returns the company operating the BAA. Otherwise returns nothing."^^xsd:string ;
rdfs:label "well bore BAA operator"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables ([ sp:varName "operator"^^xsd:string
]) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object
[ sp:varName "well"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#partOfWell> ;
sp:subject
[ sp:varName "wellBore"^^xsd:string
]
] [ sp:object
[ sp:varName "field"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#wellPartOfField> ;
sp:subject
[ sp:varName "well"^^xsd:string
]
] [ sp:object
[ sp:varName "owner"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#fieldOwner> ;
sp:subject
[ sp:varName "field"^^xsd:string
]
] [ sp:object
[ sp:varName "operator"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#baaOperator> ;
sp:subject
[ sp:varName "owner"^^xsd:string
]
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The well bore to get the company of."^^xsd:string ;
spl:predicate arg:wellBore ;
spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
] ;
spin:private "true"^^xsd:boolean ;
spin:returnType <http://www.reportinghub.no/ep/schema/organization#Company> .
rhspin:wellBoreById
rdf:type spin:Function ;
rdfs:comment "Gets the URI resource of a well bore based on its NPD id."^^xsd:string ;
......@@ -2221,6 +2336,42 @@ rhspin:wellBoreByName
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> .
rhspin:wellBoreLicenceOperator
rdf:type spin:Function ;
rdfs:label "well bore licence operator"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables ([ sp:varName "operator"^^xsd:string
]) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object
[ sp:varName "licence"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#drilledInProductionLicence> ;
sp:subject
[ sp:varName "wellBore"^^xsd:string
]
] [ sp:object
[ sp:varName "operator"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceOperator> ;
sp:subject
[ sp:varName "licence"^^xsd:string
]
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The well bore to get the licence operator of."^^xsd:string ;
spl:predicate arg:wellBore ;
spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
] ;
spin:private "true"^^xsd:boolean ;
spin:returnType <http://www.reportinghub.no/ep/schema/organization#Company> .
rhspin:wellByName
rdf:type spin:Function ;
rdfs:comment "Gets the URI resource of a well based on its NPD name."^^xsd:string ;
......@@ -2250,12 +2401,12 @@ rhspin:wellByName
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/well#Well> .
_:b7 sp:varName "company"^^xsd:string .
_:b9 sp:varName "company"^^xsd:string .
_:b11
sp:varName "company"^^xsd:string .
_:b9 sp:varName "company"^^xsd:string .
_:b7 sp:varName "company"^^xsd:string .
_:b10
sp:varName "companyName"^^xsd:string .
......@@ -2308,11 +2459,11 @@ _:b6 sp:varName "well"^^xsd:string .
_:b8 sp:varName "wellBore"^^xsd:string .
_:b4 sp:varName "wellBore"^^xsd:string .
_:b12
sp:varName "wellBore"^^xsd:string .
_:b4 sp:varName "wellBore"^^xsd:string .
_:b3 sp:varName "wellBoreId"^^xsd:string .
_:b2 sp:varName "wellBoreName"^^xsd:string .
......