Holger Knublauch

Updated DDR upload constraints to depend on BAA and then PL

...@@ -69,47 +69,12 @@ ...@@ -69,47 +69,12 @@
69 sp:path2 <http://www.reportinghub.no/ep/schema/core#temporalPartOf> 69 sp:path2 <http://www.reportinghub.no/ep/schema/core#temporalPartOf>
70 ] ; 70 ] ;
71 sp:subject spin:_this 71 sp:subject spin:_this
72 - ] [ rdf:type sp:Bind ;
73 - sp:expression
74 - [ rdf:type rhspin:companyName
75 - ] ;
76 - sp:variable
77 - [ sp:varName "companyName"^^xsd:string
78 - ]
79 - ] [ rdf:type sp:Bind ;
80 - sp:expression
81 - [ rdf:type rhspin:companyWithName ;
82 - arg:name
83 - [ sp:varName "companyName"^^xsd:string
84 - ]
85 - ] ;
86 - sp:variable
87 - [ sp:varName "company"^^xsd:string
88 - ]
89 - ] [ rdf:type sp:Filter ;
90 - sp:expression
91 - [ rdf:type sp:bound ;
92 - sp:arg1 [ sp:varName "company"^^xsd:string
93 - ]
94 - ]
95 - ] [ rdf:type sp:Bind ;
96 - sp:expression
97 - [ rdf:type rhspin:licenceForWellBore ;
98 - arg:wellBore
99 - [ sp:varName "wellBore"^^xsd:string
100 - ]
101 - ] ;
102 - sp:variable
103 - [ sp:varName "licence"^^xsd:string
104 - ]
105 ] [ rdf:type sp:Filter ; 72 ] [ rdf:type sp:Filter ;
106 sp:expression 73 sp:expression
107 [ rdf:type sp:not ; 74 [ rdf:type sp:not ;
108 - sp:arg1 [ rdf:type rhspin:npdTripleExists ; 75 + sp:arg1 [ rdf:type rhspin:currentUserIsOperatorOfWellBore ;
109 - sp:arg1 [ sp:varName "licence"^^xsd:string 76 + arg:wellBore
110 - ] ; 77 + [ sp:varName "wellBore"^^xsd:string
111 - sp:arg2 <http://www.reportinghub.no/np/schema/npd#licenceOperator> ;
112 - sp:arg3 [ sp:varName "company"^^xsd:string
113 ] 78 ]
114 ] 79 ]
115 ] 80 ]
...@@ -141,15 +106,19 @@ ...@@ -141,15 +106,19 @@
141 ] 106 ]
142 ] [ rdf:type sp:Bind ; 107 ] [ rdf:type sp:Bind ;
143 sp:expression 108 sp:expression
109 + [ rdf:type rhspin:companyName
110 + ] ;
111 + sp:variable
112 + [ sp:varName "companyName"^^xsd:string
113 + ]
114 + ] [ rdf:type sp:Bind ;
115 + sp:expression
144 [ rdf:type fn:concat ; 116 [ rdf:type fn:concat ;
145 sp:arg1 "Your company (" ; 117 sp:arg1 "Your company (" ;
146 sp:arg2 [ sp:varName "companyName"^^xsd:string 118 sp:arg2 [ sp:varName "companyName"^^xsd:string
147 ] ; 119 ] ;
148 - sp:arg3 ") is not the operator of licence " ; 120 + sp:arg3 ") is not the operator of the BAA or licence associated with well bore " ;
149 - sp:arg4 [ sp:varName "licenceName"^^xsd:string 121 + sp:arg4 [ sp:varName "wellBoreName"^^xsd:string
150 - ] ;
151 - sp:arg5 " for well bore " ;
152 - sp:arg6 [ sp:varName "wellBoreName"^^xsd:string
153 ] 122 ]
154 ] ; 123 ] ;
155 sp:variable 124 sp:variable
......
...@@ -971,6 +971,70 @@ rhspin:currentUserIsOperatorOfOwner ...@@ -971,6 +971,70 @@ rhspin:currentUserIsOperatorOfOwner
971 ] ; 971 ] ;
972 spin:returnType xsd:boolean . 972 spin:returnType xsd:boolean .
973 973
974 +rhspin:currentUserIsOperatorOfWellBore
975 + rdf:type spin:Function ;
976 + 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 ;
977 + rdfs:label "current user is operator of well bore"^^xsd:string ;
978 + rdfs:subClassOf spin:Functions ;
979 + spin:body
980 + [ rdf:type sp:Ask ;
981 + sp:where ([ rdf:type sp:Bind ;
982 + sp:expression
983 + [ rdf:type sp:coalesce ;
984 + sp:arg1 [ rdf:type rhspin:wellBoreBAAOperator ;
985 + arg:wellBore
986 + [ sp:varName "wellBore"^^xsd:string
987 + ]
988 + ] ;
989 + sp:arg2 [ rdf:type rhspin:wellBoreLicenceOperator ;
990 + arg:wellBore
991 + [ sp:varName "wellBore"^^xsd:string
992 + ]
993 + ]
994 + ] ;
995 + sp:variable
996 + [ sp:varName "operator"^^xsd:string
997 + ]
998 + ] [ rdf:type sp:Filter ;
999 + sp:expression
1000 + [ rdf:type sp:bound ;
1001 + sp:arg1 [ sp:varName "operator"^^xsd:string
1002 + ]
1003 + ]
1004 + ] [ rdf:type sp:Bind ;
1005 + sp:expression
1006 + [ rdf:type rhspin:companyName
1007 + ] ;
1008 + sp:variable
1009 + [ sp:varName "companyName"^^xsd:string
1010 + ]
1011 + ] [ rdf:type sp:Bind ;
1012 + sp:expression
1013 + [ rdf:type rhspin:companyWithName ;
1014 + arg:name
1015 + [ sp:varName "companyName"^^xsd:string
1016 + ]
1017 + ] ;
1018 + sp:variable
1019 + [ sp:varName "company"^^xsd:string
1020 + ]
1021 + ] [ rdf:type sp:Filter ;
1022 + sp:expression
1023 + [ rdf:type sp:eq ;
1024 + sp:arg1 [ sp:varName "company"^^xsd:string
1025 + ] ;
1026 + sp:arg2 [ sp:varName "operator"^^xsd:string
1027 + ]
1028 + ]
1029 + ])
1030 + ] ;
1031 + spin:constraint
1032 + [ rdf:type spl:Argument ;
1033 + rdfs:comment "The well bore to check."^^xsd:string ;
1034 + spl:predicate arg:wellBore ;
1035 + spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
1036 + ] .
1037 +
974 rhspin:ddrActivityStartDate 1038 rhspin:ddrActivityStartDate
975 rdf:type spin:Function ; 1039 rdf:type spin:Function ;
976 rdfs:comment "Gets the declared start time of the activity in a DDR, as an xsd:date literal."^^xsd:string ; 1040 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 ...@@ -2149,6 +2213,57 @@ rhspin:userName
2149 rdfs:subClassOf spin:Functions ; 2213 rdfs:subClassOf spin:Functions ;
2150 spin:returnType xsd:string . 2214 spin:returnType xsd:string .
2151 2215
2216 +rhspin:wellBoreBAAOperator
2217 + rdf:type spin:Function ;
2218 + 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 ;
2219 + rdfs:label "well bore BAA operator"^^xsd:string ;
2220 + rdfs:subClassOf spin:Functions ;
2221 + spin:body
2222 + [ rdf:type sp:Select ;
2223 + sp:resultVariables ([ sp:varName "operator"^^xsd:string
2224 + ]) ;
2225 + sp:where ([ rdf:type sp:NamedGraph ;
2226 + sp:elements ([ sp:object
2227 + [ sp:varName "well"^^xsd:string
2228 + ] ;
2229 + sp:predicate <http://www.reportinghub.no/np/schema/npd#partOfWell> ;
2230 + sp:subject
2231 + [ sp:varName "wellBore"^^xsd:string
2232 + ]
2233 + ] [ sp:object
2234 + [ sp:varName "field"^^xsd:string
2235 + ] ;
2236 + sp:predicate <http://www.reportinghub.no/np/schema/npd#wellPartOfField> ;
2237 + sp:subject
2238 + [ sp:varName "well"^^xsd:string
2239 + ]
2240 + ] [ sp:object
2241 + [ sp:varName "owner"^^xsd:string
2242 + ] ;
2243 + sp:predicate <http://www.reportinghub.no/np/schema/npd#fieldOwner> ;
2244 + sp:subject
2245 + [ sp:varName "field"^^xsd:string
2246 + ]
2247 + ] [ sp:object
2248 + [ sp:varName "operator"^^xsd:string
2249 + ] ;
2250 + sp:predicate <http://www.reportinghub.no/np/schema/npd#baaOperator> ;
2251 + sp:subject
2252 + [ sp:varName "owner"^^xsd:string
2253 + ]
2254 + ]) ;
2255 + sp:graphNameNode npdata:npd
2256 + ])
2257 + ] ;
2258 + spin:constraint
2259 + [ rdf:type spl:Argument ;
2260 + rdfs:comment "The well bore to get the company of."^^xsd:string ;
2261 + spl:predicate arg:wellBore ;
2262 + spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
2263 + ] ;
2264 + spin:private "true"^^xsd:boolean ;
2265 + spin:returnType <http://www.reportinghub.no/ep/schema/organization#Company> .
2266 +
2152 rhspin:wellBoreById 2267 rhspin:wellBoreById
2153 rdf:type spin:Function ; 2268 rdf:type spin:Function ;
2154 rdfs:comment "Gets the URI resource of a well bore based on its NPD id."^^xsd:string ; 2269 rdfs:comment "Gets the URI resource of a well bore based on its NPD id."^^xsd:string ;
...@@ -2221,6 +2336,42 @@ rhspin:wellBoreByName ...@@ -2221,6 +2336,42 @@ rhspin:wellBoreByName
2221 ] ; 2336 ] ;
2222 spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> . 2337 spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> .
2223 2338
2339 +rhspin:wellBoreLicenceOperator
2340 + rdf:type spin:Function ;
2341 + rdfs:label "well bore licence operator"^^xsd:string ;
2342 + rdfs:subClassOf spin:Functions ;
2343 + spin:body
2344 + [ rdf:type sp:Select ;
2345 + sp:resultVariables ([ sp:varName "operator"^^xsd:string
2346 + ]) ;
2347 + sp:where ([ rdf:type sp:NamedGraph ;
2348 + sp:elements ([ sp:object
2349 + [ sp:varName "licence"^^xsd:string
2350 + ] ;
2351 + sp:predicate <http://www.reportinghub.no/np/schema/npd#drilledInProductionLicence> ;
2352 + sp:subject
2353 + [ sp:varName "wellBore"^^xsd:string
2354 + ]
2355 + ] [ sp:object
2356 + [ sp:varName "operator"^^xsd:string
2357 + ] ;
2358 + sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceOperator> ;
2359 + sp:subject
2360 + [ sp:varName "licence"^^xsd:string
2361 + ]
2362 + ]) ;
2363 + sp:graphNameNode npdata:npd
2364 + ])
2365 + ] ;
2366 + spin:constraint
2367 + [ rdf:type spl:Argument ;
2368 + rdfs:comment "The well bore to get the licence operator of."^^xsd:string ;
2369 + spl:predicate arg:wellBore ;
2370 + spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
2371 + ] ;
2372 + spin:private "true"^^xsd:boolean ;
2373 + spin:returnType <http://www.reportinghub.no/ep/schema/organization#Company> .
2374 +
2224 rhspin:wellByName 2375 rhspin:wellByName
2225 rdf:type spin:Function ; 2376 rdf:type spin:Function ;
2226 rdfs:comment "Gets the URI resource of a well based on its NPD name."^^xsd:string ; 2377 rdfs:comment "Gets the URI resource of a well based on its NPD name."^^xsd:string ;
...@@ -2250,12 +2401,12 @@ rhspin:wellByName ...@@ -2250,12 +2401,12 @@ rhspin:wellByName
2250 ] ; 2401 ] ;
2251 spin:returnType <http://www.reportinghub.no/ep/schema/well#Well> . 2402 spin:returnType <http://www.reportinghub.no/ep/schema/well#Well> .
2252 2403
2253 -_:b7 sp:varName "company"^^xsd:string . 2404 +_:b9 sp:varName "company"^^xsd:string .
2254 2405
2255 _:b11 2406 _:b11
2256 sp:varName "company"^^xsd:string . 2407 sp:varName "company"^^xsd:string .
2257 2408
2258 -_:b9 sp:varName "company"^^xsd:string . 2409 +_:b7 sp:varName "company"^^xsd:string .
2259 2410
2260 _:b10 2411 _:b10
2261 sp:varName "companyName"^^xsd:string . 2412 sp:varName "companyName"^^xsd:string .
...@@ -2308,11 +2459,11 @@ _:b6 sp:varName "well"^^xsd:string . ...@@ -2308,11 +2459,11 @@ _:b6 sp:varName "well"^^xsd:string .
2308 2459
2309 _:b8 sp:varName "wellBore"^^xsd:string . 2460 _:b8 sp:varName "wellBore"^^xsd:string .
2310 2461
2462 +_:b4 sp:varName "wellBore"^^xsd:string .
2463 +
2311 _:b12 2464 _:b12
2312 sp:varName "wellBore"^^xsd:string . 2465 sp:varName "wellBore"^^xsd:string .
2313 2466
2314 -_:b4 sp:varName "wellBore"^^xsd:string .
2315 -
2316 _:b3 sp:varName "wellBoreId"^^xsd:string . 2467 _:b3 sp:varName "wellBoreId"^^xsd:string .
2317 2468
2318 _:b2 sp:varName "wellBoreName"^^xsd:string . 2469 _:b2 sp:varName "wellBoreName"^^xsd:string .
......