Holger Knublauch

Introduced metaclass for report types, simplified autocomplete code

......@@ -274,7 +274,7 @@ app:AbstractSubject
app:AutoComplete
rdf:type ui:NodeClass ;
rdfs:label "Auto complete"^^xsd:string ;
rdfs:subClassOf app:Elements ;
rdfs:subClassOf app:AutoCompleteElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The id of the HTML input element."^^xsd:string ;
......@@ -299,12 +299,6 @@ app:AutoComplete
arg:type
[ sp:varName "type"^^xsd:string
] ;
let:displayId
[ rdf:type fn:concat ;
sp:arg1 [ sp:varName "id"^^xsd:string
] ;
sp:arg2 "-field"
] ;
ui:child
[ rdf:type html:Input ;
html:id [ sp:varName "id"^^xsd:string
......@@ -321,38 +315,207 @@ app:AutoComplete
ui:childIndex 0
] ;
ui:child
[ rdf:type html:Input ;
html:class "appAutoComplete"^^xsd:string ;
html:id [ sp:varName "displayId"^^xsd:string
] ;
html:value
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "initialValue"^^xsd:string
]
[ rdf:type ui:group ;
let:displayId
[ rdf:type ui:concat ;
sp:arg1 [ sp:varName "id"^^xsd:string
] ;
sp:arg2 "-field"^^xsd:string
] ;
ui:childIndex 1
] ;
ui:child
[ rdf:type app:WidgetInitializer ;
arg:script
[ rdf:type fn:concat ;
sp:arg1 "appInitAutoComplete('" ;
sp:arg2 [ sp:varName "displayId"^^xsd:string
ui:child
[ rdf:type html:Input ;
html:class "appAutoComplete"^^xsd:string ;
html:id [ sp:varName "displayId"^^xsd:string
] ;
sp:arg3 "', '" ;
sp:arg4 [ sp:varName "id"^^xsd:string
html:value
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "initialValue"^^xsd:string
]
] ;
sp:arg5 "', '" ;
sp:arg6 [ sp:varName "link"^^xsd:string
ui:childIndex 0
] ;
ui:child
[ rdf:type app:WidgetInitializer ;
arg:script
[ rdf:type ui:concat ;
sp:arg1 "appInitAutoComplete('"^^xsd:string ;
sp:arg2 [ sp:varName "displayId"^^xsd:string
] ;
sp:arg3 "', '"^^xsd:string ;
sp:arg4 [ sp:varName "id"^^xsd:string
] ;
sp:arg5 "', '"^^xsd:string ;
sp:arg6 [ sp:varName "link"^^xsd:string
] ;
sp:arg7 "')"^^xsd:string
] ;
sp:arg7 "')"
ui:childIndex 1
] ;
ui:childIndex 2
ui:childIndex 1
] ;
ui:format "json"^^xsd:string ;
ui:sendQueryGraph "true"^^xsd:boolean ;
ui:servlet "imports/autoCompleteCallback.json.swp"^^xsd:string
ui:snippet "true"^^xsd:string ;
ui:viewClass app:AutoCompleteCallback
] .
app:AutoCompleteCallback
rdf:type ui:NodeClass ;
rdfs:comment "Internally used by the AutoComplete widget to fetch the matching resources."^^xsd:string ;
rdfs:label "Auto complete callback"^^xsd:string ;
rdfs:subClassOf app:AutoCompleteElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The start of the name as entered by the user."^^xsd:string ;
spl:predicate arg:term ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The type of resource to get matching instances of."^^xsd:string ;
spl:predicate arg:type ;
spl:valueType rdfs:Class
] ;
ui:private "true"^^xsd:boolean ;
ui:prototype
[ rdf:type ui:group ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text """
[
"""^^xsd:string
] ;
ui:child
[ rdf:type ui:forEach ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text """{
\"label\" : \""""^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 1 ;
ui:text [ sp:varName "label"^^xsd:string
]
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 2 ;
ui:text """\",
\"resource\" : \""""^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 3 ;
ui:text [ rdf:type ui:encodeNode ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
]
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 4 ;
ui:text """\",
\"value\" : \""""^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 5 ;
ui:text [ sp:varName "label"^^xsd:string
]
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 6 ;
ui:text """\"
}"""^^xsd:string
] ;
ui:childIndex 1 ;
ui:resultSet
[ rdf:type sp:Select ;
sp:resultVariables ([ sp:varName "resource"^^xsd:string
] [ sp:varName "label"^^xsd:string
]) ;
sp:where ([ sp:object
[ sp:varName "type"^^xsd:string
] ;
sp:predicate rdf:first ;
sp:subject
[ sp:varName "?0"^^xsd:string
]
] [ sp:object
[ sp:varName "?1"^^xsd:string
] ;
sp:predicate rdf:rest ;
sp:subject
[ sp:varName "?0"^^xsd:string
]
] [ sp:object
[ sp:varName "term"^^xsd:string
] ;
sp:predicate rdf:first ;
sp:subject
[ sp:varName "?1"^^xsd:string
]
] [ sp:object () ;
sp:predicate rdf:rest ;
sp:subject
[ sp:varName "?1"^^xsd:string
]
] [ sp:object
[ sp:varName "?2"^^xsd:string
] ;
sp:predicate ui:autoComplete ;
sp:subject
[ sp:varName "?0"^^xsd:string
]
] [ sp:object
[ sp:varName "resource"^^xsd:string
] ;
sp:predicate rdf:first ;
sp:subject
[ sp:varName "?2"^^xsd:string
]
] [ sp:object
[ sp:varName "?3"^^xsd:string
] ;
sp:predicate rdf:rest ;
sp:subject
[ sp:varName "?2"^^xsd:string
]
] [ sp:object
[ sp:varName "label"^^xsd:string
] ;
sp:predicate rdf:first ;
sp:subject
[ sp:varName "?3"^^xsd:string
]
] [ sp:object () ;
sp:predicate rdf:rest ;
sp:subject
[ sp:varName "?3"^^xsd:string
]
])
] ;
ui:separator ","^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 2 ;
ui:text """
]
"""^^xsd:string
]
] .
app:AutoCompleteElements
rdf:type ui:NodeClass ;
rdfs:label "Auto complete elements"^^xsd:string ;
rdfs:subClassOf app:Elements ;
ui:abstract "true"^^xsd:boolean .
app:BNodeViewer
rdf:type app:ObjectViewerClass ;
rdfs:label "BNode viewer"^^xsd:string ;
......@@ -7502,6 +7665,11 @@ arg:targetId
rdfs:label "target id"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
arg:term
rdf:type rdf:Property ;
rdfs:label "term"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
arg:toggleFunctionCall
rdf:type rdf:Property ;
rdfs:label "toggle function call"^^xsd:string ;
......
<ui:group
let:type="{= ui:param('type', rdfs:Class) }"
let:prefix="{= ui:param('term') }">
[
<ui:forEach ui:resultSet="{#
SELECT ?resource ?label
WHERE {
(?type ?prefix) ui:autoComplete (?resource ?label) .
}
}" ui:indexVar="index">
<ui:if ui:condition="{= ?index &gt; 0 }">,</ui:if>
{
"label" : "{= ?label }",
"resource" : "{= ui:encodeNode(?resource) }",
"value" : "{= ?label }"
}
</ui:forEach>
]
</ui:group>
\ No newline at end of file
......@@ -140,7 +140,7 @@ log:reportType
rdf:type owl:ObjectProperty ;
rdfs:domain log:ReportEvent ;
rdfs:label "report type"^^xsd:string ;
rdfs:range rdfs:Class .
rdfs:range <http://www.reportinghub.no/system/schema/reporting#ReportClass> .
log:url
rdf:type owl:DatatypeProperty ;
......
......@@ -21,7 +21,7 @@ sioc:id
owl:versionInfo "0.2.0"^^xsd:string .
report:AbstractDR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:comment "Abstract base class for various types of daily reports."^^xsd:string ;
rdfs:label "Daily report"^^xsd:string ;
rdfs:subClassOf foaf:Document ;
......@@ -57,12 +57,12 @@ report:AbstractDR
] .
report:AbstractMPR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:label "Abstract MPR"^^xsd:string ;
rdfs:subClassOf foaf:Document .
report:DDR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:comment "The metadata about a Daily Drilling Report."^^xsd:string ;
rdfs:label "DDR"^^xsd:string ;
rdfs:subClassOf report:AbstractDR ;
......@@ -78,7 +78,7 @@ report:DDR
] .
report:DPR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:comment "The metadata about a Daily Production Report."^^xsd:string ;
rdfs:label "DPR"^^xsd:string ;
rdfs:subClassOf report:AbstractDR ;
......@@ -98,22 +98,22 @@ report:HTMLFormat
rdfs:label "HTMLFormat"^^xsd:string .
report:MPRD
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:label "MPRD"^^xsd:string ;
rdfs:subClassOf report:AbstractMPR .
report:MPRG
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:label "MPRG"^^xsd:string ;
rdfs:subClassOf report:AbstractMPR .
report:MPRP
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:label "MPRP"^^xsd:string ;
rdfs:subClassOf report:AbstractMPR .
report:NPTR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:comment "Metadata about a Non-Productive Time Report."^^xsd:string ;
rdfs:label "NPTR"^^xsd:string ;
rdfs:subClassOf foaf:Document .
......@@ -122,8 +122,14 @@ report:PDFFormat
rdf:type report:Format ;
rdfs:label "PDFFormat"^^xsd:string .
report:ReportClass
rdf:type rdfs:Class ;
rdfs:comment "Metaclass for the various report types."^^xsd:string ;
rdfs:label "Report class"^^xsd:string ;
rdfs:subClassOf owl:Class .
report:WDR
rdf:type owl:Class ;
rdf:type report:ReportClass ;
rdfs:comment "Metadata about a Weekly Drilling Report"^^xsd:string ;
rdfs:label "WDR"^^xsd:string ;
rdfs:subClassOf foaf:Document .
......