Holger Knublauch

More utility functions

......@@ -50,6 +50,11 @@
rdfs:label "well"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
<http://spinrdf.org/arg#wellBore>
rdf:type rdf:Property ;
rdfs:label "well bore"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
<http://spinrdf.org/arg#wellBoreName>
rdf:type rdf:Property ;
rdfs:label "well bore name"^^xsd:string ;
......@@ -77,14 +82,14 @@
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The property that must be used in the result resource."^^xsd:string ;
spl:predicate <http://topbraid.org/spin/spinmapl#predicate> ;
spl:valueType rdf:Property
rdfs:comment "The value to match against."^^xsd:string ;
spl:predicate sp:arg1
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The value to match against."^^xsd:string ;
spl:predicate sp:arg1
rdfs:comment "The property that must be used in the result resource."^^xsd:string ;
spl:predicate <http://topbraid.org/spin/spinmapl#predicate> ;
spl:valueType rdf:Property
] ;
spin:returnType rdfs:Resource .
......@@ -198,6 +203,34 @@ rhspin:companyById
spl:valueType xsd:string
] .
rhspin:companyHasLicence
rdf:type spin:MagicProperty ;
rdfs:comment "A magic property that defines a relationship between companies (left side) and licenses (right side). It matches those licenses that the company currently holds. The query is optimized for the direction when the company is given and the licenses variable."^^xsd:string ;
rdfs:label "company has licence"^^xsd:string ;
rdfs:subClassOf spin:MagicProperties ;
spin:body
[ rdf:type sp:Select ;
sp:distinct "true"^^xsd:boolean ;
sp:resultVariables (_:b5) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object spin:_arg1 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#shareHolder> ;
sp:subject _:b6
] [ sp:object _:b5 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceShared> ;
sp:subject _:b6
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The Company to match."^^xsd:string ;
spl:predicate sp:arg1 ;
spl:valueType <http://www.reportinghub.no/ep/schema/organization#Company>
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> .
rhspin:companyHasLicenceForWellBore
rdf:type spin:MagicProperty ;
rdfs:comment "A magic property that defines a relationship between companies (left side) and well bores (right side). It matches those well bores that the company currently holds a licence for. The query is optimized for the direction when the company is given and the well bores variable."^^xsd:string ;
......@@ -206,50 +239,22 @@ rhspin:companyHasLicenceForWellBore
spin:body
[ rdf:type sp:Select ;
sp:distinct "true"^^xsd:boolean ;
sp:resultVariables (_:b5) ;
sp:where ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type xsd:date ;
sp:arg1 [ rdf:type fn:substring ;
sp:arg1 [ rdf:type xsd:string ;
sp:arg1 [ rdf:type sp:now
]
] ;
sp:arg2 1 ;
sp:arg3 10
]
] ;
sp:variable _:b6
] [ sp:object spin:_arg1 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#shareHolder> ;
sp:subject _:b7
] [ sp:object _:b8 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceShared> ;
sp:subject _:b7
] [ sp:object <http://www.reportinghub.no/np/schema/npd#LS_Active> ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceStatus> ;
sp:subject _:b8
] [ sp:object _:b9 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#startDate> ;
sp:subject _:b8
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:le ;
sp:arg1 _:b9 ;
sp:arg2 _:b6
]
] [ sp:object _:b10 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#endDate> ;
sp:subject _:b8
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:gt ;
sp:arg1 _:b10 ;
sp:arg2 _:b6
]
] [ sp:object _:b8 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#drilledInProductionLicence> ;
sp:subject _:b5
sp:resultVariables (_:b7) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object spin:_arg1 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#shareHolder> ;
sp:subject _:b8
] [ sp:object _:b9 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceShared> ;
sp:subject _:b8
] [ sp:object <http://www.reportinghub.no/np/schema/npd#LS_Active> ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#licenceStatus> ;
sp:subject _:b9
] [ sp:object _:b9 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#drilledInProductionLicence> ;
sp:subject _:b7
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
......@@ -258,7 +263,8 @@ rhspin:companyHasLicenceForWellBore
spl:predicate sp:arg1 ;
spl:valueType <http://www.reportinghub.no/ep/schema/organization#Company>
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> .
spin:returnType <http://www.reportinghub.no/ep/schema/well#WellBore> ;
owl:versionInfo "Note: the algorithm isn't clear - it could be that the date checks are not needed."^^xsd:string .
rhspin:companyName
rdf:type spin:Function ;
......@@ -267,6 +273,35 @@ rhspin:companyName
rdfs:subClassOf spin:Functions ;
spin:returnType xsd:string .
rhspin:companyWithName
rdf:type spin:Function ;
rdfs:comment "Gets a Company with a given name from the NPD graph."^^xsd:string ;
rdfs:label "company with name"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b10) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object
[ sp:varName "name"^^xsd:string
] ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#name> ;
sp:subject _:b10
] [ sp:object <http://www.reportinghub.no/np/schema/npd#OperatingCompany> ;
sp:predicate rdf:type ;
sp:subject _:b10
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The name of the Company to get."^^xsd:string ;
spl:predicate <http://spinrdf.org/arg#name> ;
spl:valueType xsd:string
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/organization#Company> .
rhspin:discoveryById
rdf:type spin:Function ;
rdfs:label "discovery by id"^^xsd:string ;
......@@ -307,15 +342,15 @@ rhspin:dtypeValue
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The subject of the value."^^xsd:string ;
spl:predicate sp:arg1 ;
spl:valueType rdfs:Resource
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The predicate that points to the reified value."^^xsd:string ;
spl:predicate sp:arg2 ;
spl:valueType rdf:Property
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The subject of the value."^^xsd:string ;
spl:predicate sp:arg1 ;
spl:valueType rdfs:Resource
] .
rhspin:facilityById
......@@ -385,6 +420,32 @@ rhspin:licenceById
] ;
spin:returnType <http://www.reportinghub.no/np/schema/npd#Licence> .
rhspin:licenceForWellBore
rdf:type spin:Function ;
rdfs:comment "Gets the licence associated with a given well bore."^^xsd:string ;
rdfs:label "licence for well bore"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b13) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object _:b13 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#drilledInProductionLicence> ;
sp:subject
[ sp:varName "wellBore"^^xsd:string
]
]) ;
sp:graphNameNode npdata:npd
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The WellBore to get the licence of."^^xsd:string ;
spl:predicate <http://spinrdf.org/arg#wellBore> ;
spl:valueType <http://www.reportinghub.no/ep/schema/well#WellBore>
] ;
spin:returnType <http://www.reportinghub.no/np/schema/npd#Licence> .
rhspin:normalizeString
rdf:type spin:Function ;
rdfs:comment "Takes a raw string and \"normalizes\" it, replacing special characters so that they can be used in URIs."^^xsd:string ;
......@@ -392,7 +453,7 @@ rhspin:normalizeString
rdfs:subClassOf spl:StringFunctions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b13) ;
sp:resultVariables (_:b14) ;
sp:where ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
......@@ -400,67 +461,67 @@ rhspin:normalizeString
sp:arg2 "\\((.*)\\)" ;
sp:arg3 ""
] ;
sp:variable _:b14
sp:variable _:b15
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:trim ;
sp:arg1 _:b14
sp:arg1 _:b15
] ;
sp:variable _:b15
sp:variable _:b16
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:encodeURL ;
sp:arg1 _:b15
sp:arg1 _:b16
] ;
sp:variable _:b16
sp:variable _:b17
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
sp:arg1 _:b16 ;
sp:arg1 _:b17 ;
sp:arg2 "%2F" ;
sp:arg3 "_"
] ;
sp:variable _:b17
sp:variable _:b18
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
sp:arg1 _:b17 ;
sp:arg1 _:b18 ;
sp:arg2 "%[0-9A-F][0-9A-F]" ;
sp:arg3 ""
] ;
sp:variable _:b18
sp:variable _:b19
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
sp:arg1 _:b18 ;
sp:arg1 _:b19 ;
sp:arg2 "\\+" ;
sp:arg3 "_"
] ;
sp:variable _:b19
sp:variable _:b20
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
sp:arg1 _:b19 ;
sp:arg1 _:b20 ;
sp:arg2 "_+" ;
sp:arg3 "_"
] ;
sp:variable _:b20
sp:variable _:b21
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:regex ;
sp:arg1 _:b20 ;
sp:arg1 _:b21 ;
sp:arg2 "\\*" ;
sp:arg3 ""
] ;
sp:variable _:b21
sp:variable _:b22
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type xsd:string ;
sp:arg1 [ rdf:type spif:upperCase ;
sp:arg1 _:b21
sp:arg1 _:b22
]
] ;
sp:variable _:b13
sp:variable _:b14
])
] ;
spin:constraint
......@@ -477,9 +538,9 @@ rhspin:npdId
rdfs:subClassOf spl:StringFunctions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b22) ;
sp:resultVariables (_:b23) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object _:b22 ;
sp:elements ([ sp:object _:b23 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#id> ;
sp:subject
[ sp:varName "resource"^^xsd:string
......@@ -502,9 +563,9 @@ rhspin:npdName
rdfs:subClassOf spl:StringFunctions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b23) ;
sp:resultVariables (_:b24) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ sp:object _:b23 ;
sp:elements ([ sp:object _:b24 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#name> ;
sp:subject
[ sp:varName "resource"^^xsd:string
......@@ -616,27 +677,27 @@ rhspin:wellBoreByName
rdfs:subClassOf spl:URIFunctions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables (_:b24) ;
sp:resultVariables (_:b25) ;
sp:where ([ rdf:type sp:NamedGraph ;
sp:elements ([ rdf:type sp:Union ;
sp:elements (([ sp:object _:b25 ;
sp:elements (([ sp:object _:b26 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#name> ;
sp:subject _:b24
sp:subject _:b25
]) ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:replaceAll ;
sp:arg1 _:b25 ;
sp:arg1 _:b26 ;
sp:arg2 "/0" ;
sp:arg3 "/"
] ;
sp:variable _:b26
] [ sp:object _:b26 ;
sp:variable _:b27
] [ sp:object _:b27 ;
sp:predicate <http://www.reportinghub.no/np/schema/npd#name> ;
sp:subject _:b24
sp:subject _:b25
]))
] [ sp:object <http://www.reportinghub.no/ep/schema/well#WellBore> ;
sp:predicate rdf:type ;
sp:subject _:b24
sp:subject _:b25
]) ;
sp:graphNameNode npdata:npd
])
......@@ -675,48 +736,49 @@ rhspin:wellByName
] ;
spin:returnType <http://www.reportinghub.no/ep/schema/well#Well> .
_:b1 sp:varName "subject"^^xsd:string .
_:b13
sp:varName "licence"^^xsd:string .
_:b26
_:b27
sp:varName "str"^^xsd:string .
_:b25
_:b26
sp:varName "wellBoreName"^^xsd:string .
_:b24
_:b25
sp:varName "wellBore"^^xsd:string .
_:b23
_:b24
sp:varName "name"^^xsd:string .
_:b22
_:b23
sp:varName "id"^^xsd:string .
_:b21
_:b22
sp:varName "t4"^^xsd:string .
_:b20
_:b21
sp:varName "t3"^^xsd:string .
_:b19
_:b20
sp:varName "t2"^^xsd:string .
_:b18
_:b19
sp:varName "t1"^^xsd:string .
_:b17
_:b18
sp:varName "t0b"^^xsd:string .
_:b16
_:b17
sp:varName "t0a"^^xsd:string .
_:b15
_:b16
sp:varName "s2"^^xsd:string .
_:b14
_:b15
sp:varName "s1"^^xsd:string .
_:b13
_:b14
sp:varName "normalizedStr"^^xsd:string .
_:b12
......@@ -726,20 +788,22 @@ _:b11
sp:varName "value"^^xsd:string .
_:b10
sp:varName "endDate"^^xsd:string .
sp:varName "company"^^xsd:string .
_:b9 sp:varName "startDate"^^xsd:string .
_:b9 sp:varName "licence"^^xsd:string .
_:b8 sp:varName "licence"^^xsd:string .
_:b8 sp:varName "share"^^xsd:string .
_:b7 sp:varName "share"^^xsd:string .
_:b7 sp:varName "wellBore"^^xsd:string .
_:b6 sp:varName "nowDate"^^xsd:string .
_:b6 sp:varName "share"^^xsd:string .
_:b5 sp:varName "wellBore"^^xsd:string .
_:b5 sp:varName "licence"^^xsd:string .
_:b4 sp:varName "wellBore"^^xsd:string .
_:b3 sp:varName "wellBoreId"^^xsd:string .
_:b2 sp:varName "wellBoreName"^^xsd:string .
_:b1 sp:varName "subject"^^xsd:string .
......