Holger Knublauch

Added rhspin:normalizeWellBoreName with C# algorithm (issue #77)

......@@ -8,6 +8,7 @@
# imports: http://www.reportinghub.no/ep/schema/1.0/report
# imports: http://www.reportinghub.no/np/schema/1.0/npd
@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 npdata: <http://www.reportinghub.no/np/data/> .
......@@ -217,6 +218,42 @@ rhspin:TableTemplates
rdfs:subClassOf spin:SelectTemplates ;
spin:abstract "true"^^xsd:boolean .
rhspin:Test-normalizeWellBoreName-1
rdf:type spl:TestCase ;
rdfs:label "Test-normalize well bore name-1"^^xsd:string ;
spl:testExpression
[ rdf:type rhspin:normalizeWellBoreName ;
sp:arg1 "31/2-L12 Y1H"
] ;
spl:testResult "31/2-L12 Y1H"^^xsd:string .
rhspin:Test-normalizeWellBoreName-2
rdf:type spl:TestCase ;
rdfs:label "Test-normalize well bore name-2"^^xsd:string ;
spl:testExpression
[ rdf:type rhspin:normalizeWellBoreName ;
sp:arg1 "31/2-L12 T2"
] ;
spl:testResult "31/2-L12"^^xsd:string .
rhspin:Test-normalizeWellBoreName-3
rdf:type spl:TestCase ;
rdfs:label "Test-normalize well bore name-3"^^xsd:string ;
spl:testExpression
[ rdf:type rhspin:normalizeWellBoreName ;
sp:arg1 "31/2-L12 Q1"
] ;
spl:testResult "31/2-L12"^^xsd:string .
rhspin:Test-normalizeWellBoreName-4
rdf:type spl:TestCase ;
rdfs:label "Test-normalize well bore name-4"^^xsd:string ;
spl:testExpression
[ rdf:type rhspin:normalizeWellBoreName ;
sp:arg1 "31/2-'L12',"
] ;
spl:testResult "31/2-L12"^^xsd:string .
rhspin:baaById
rdf:type spin:Function ;
rdfs:label "baa by id"^^xsd:string ;
......@@ -834,6 +871,219 @@ rhspin:normalizeString
] ;
spin:returnType xsd:string .
rhspin:normalizeWellBoreName
rdf:type spin:Function ;
rdfs:comment """Applies the following C# algorithm to a given well bore name:
public static string removeTrackFromWellboreAlias(string wellboreAlias) {
wellboreAlias = wellboreAlias.Replace(\"'\", \"\").TrimEnd();
if (wellboreAlias.Substring(wellboreAlias.Length - 1, 1) == \",\")
wellboreAlias = wellboreAlias.Substring(0, wellboreAlias.Length - 1);
if (wellboreAlias.IndexOf(\" \") > 0 && wellboreAlias.LastIndexOf(\"T\") > wellboreAlias.IndexOf(\" \"))
{
wellboreAlias = wellboreAlias.Remove(wellboreAlias.LastIndexOf(\"T\"));
}
if (wellboreAlias.IndexOf(\" \") > 0 && wellboreAlias.LastIndexOf(\"Q\") > wellboreAlias.IndexOf(\" \"))
{
wellboreAlias = wellboreAlias.Remove(wellboreAlias.LastIndexOf(\"Q\"));
}
return wellboreAlias.TrimEnd();
}"""^^xsd:string ;
rdfs:label "normalize well bore name"^^xsd:string ;
rdfs:subClassOf spin:Functions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables ([ rdf:type xsd:string ;
sp:arg1 [ rdf:type spif:trim ;
sp:arg1 [ sp:varName "result"^^xsd:string
]
]
]) ;
sp:where ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:trim ;
sp:arg1 [ rdf:type spif:replaceAll ;
sp:arg1 spin:_arg1 ;
sp:arg2 "'" ;
sp:arg3 ""
]
] ;
sp:variable
[ sp:varName "a"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type sp:if ;
sp:arg1 [ rdf:type sp:eq ;
sp:arg1 [ rdf:type afn:substr ;
sp:arg1 [ sp:varName "a"^^xsd:string
] ;
sp:arg2 [ rdf:type sp:sub ;
sp:arg1 [ rdf:type fn:string-length ;
sp:arg1 [ sp:varName "a"^^xsd:string
]
] ;
sp:arg2 1
] ;
sp:arg3 [ rdf:type fn:string-length ;
sp:arg1 [ sp:varName "a"^^xsd:string
]
]
] ;
sp:arg2 ","
] ;
sp:arg2 [ rdf:type afn:substr ;
sp:arg1 [ sp:varName "a"^^xsd:string
] ;
sp:arg2 0 ;
sp:arg3 [ rdf:type sp:sub ;
sp:arg1 [ rdf:type fn:string-length ;
sp:arg1 [ sp:varName "a"^^xsd:string
]
] ;
sp:arg2 1
]
] ;
sp:arg3 [ sp:varName "a"^^xsd:string
]
] ;
sp:variable
[ sp:varName "b"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:lastIndexOf ;
sp:arg1 [ sp:varName "b"^^xsd:string
] ;
sp:arg2 "T"
] ;
sp:variable
[ sp:varName "t"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:lastIndexOf ;
sp:arg1 [ sp:varName "b"^^xsd:string
] ;
sp:arg2 " "
] ;
sp:variable
[ sp:varName "s1"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type sp:if ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "s1"^^xsd:string
]
] ;
sp:arg2 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "t"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type sp:gt ;
sp:arg1 [ sp:varName "s1"^^xsd:string
] ;
sp:arg2 0
]
] ;
sp:arg2 [ rdf:type sp:gt ;
sp:arg1 [ sp:varName "t"^^xsd:string
] ;
sp:arg2 [ sp:varName "s1"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type afn:substr ;
sp:arg1 [ sp:varName "b"^^xsd:string
] ;
sp:arg2 0 ;
sp:arg3 [ sp:varName "t"^^xsd:string
]
] ;
sp:arg3 [ sp:varName "b"^^xsd:string
]
] ;
sp:variable
[ sp:varName "c"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:lastIndexOf ;
sp:arg1 [ sp:varName "c"^^xsd:string
] ;
sp:arg2 "Q"
] ;
sp:variable
[ sp:varName "q"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type spif:lastIndexOf ;
sp:arg1 [ sp:varName "c"^^xsd:string
] ;
sp:arg2 " "
] ;
sp:variable
[ sp:varName "s2"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type sp:if ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:and ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "s2"^^xsd:string
]
] ;
sp:arg2 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "q"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type sp:gt ;
sp:arg1 [ sp:varName "s2"^^xsd:string
] ;
sp:arg2 0
]
] ;
sp:arg2 [ rdf:type sp:gt ;
sp:arg1 [ sp:varName "q"^^xsd:string
] ;
sp:arg2 [ sp:varName "s2"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type afn:substr ;
sp:arg1 [ sp:varName "c"^^xsd:string
] ;
sp:arg2 0 ;
sp:arg3 [ sp:varName "q"^^xsd:string
]
] ;
sp:arg3 [ sp:varName "c"^^xsd:string
]
] ;
sp:variable
[ sp:varName "result"^^xsd:string
]
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The raw input name."^^xsd:string ;
spl:predicate sp:arg1 ;
spl:valueType xsd:string
] ;
spin:returnType xsd:string .
rhspin:npdId
rdf:type spin:Function ;
rdfs:comment "Gets the NPD id of a given NPD resource."^^xsd:string ;
......