Holger Knublauch

Fixed resource search, added index

......@@ -72,6 +72,158 @@ app:PropertyWidgetGroupFilterFunctions
] ;
spin:returnType xsd:boolean .
app:ResourcesWithLetter
rdf:type spin:SelectTemplate ;
rdfs:comment "Gets an ordered list of all instances of a given class that start with a given letter."^^xsd:string ;
rdfs:label "Resources with letter"^^xsd:string ;
rdfs:subClassOf spin:SelectTemplates ;
spin:body
[ rdf:type sp:Select ;
sp:distinct "true"^^xsd:boolean ;
sp:orderBy ([ rdf:type fn:lower-case ;
sp:arg1 [ sp:varName "label"^^xsd:string
]
]) ;
sp:resultVariables ([ sp:varName "resource"^^xsd:string
]) ;
sp:where ([ rdf:type sp:TriplePath ;
sp:object
[ sp:varName "resourceType"^^xsd:string
] ;
sp:path [ rdf:type sp:ModPath ;
sp:modMax -2 ;
sp:modMin 0 ;
sp:subPath rdfs:subClassOf
] ;
sp:subject
[ sp:varName "type"^^xsd:string
]
] [ sp:object
[ sp:varName "type"^^xsd:string
] ;
sp:predicate rdf:type ;
sp:subject
[ sp:varName "resource"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:isIRI ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
] ;
sp:variable
[ sp:varName "label"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type fn:starts-with ;
sp:arg1 [ rdf:type fn:upper-case ;
sp:arg1 [ sp:varName "label"^^xsd:string
]
] ;
sp:arg2 [ sp:varName "letter"^^xsd:string
]
]
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The (uppercase) letter to match."^^xsd:string ;
spl:predicate arg:letter ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The resource type."^^xsd:string ;
spl:predicate arg:resourceType ;
spl:valueType rdfs:Class
] .
app:ResourcesWithNonLetter
rdf:type spin:SelectTemplate ;
rdfs:comment "Gets an ordered list of all instances of a given type that do not start with a letter from A-Z."^^xsd:string ;
rdfs:label "Resources with non letter"^^xsd:string ;
rdfs:subClassOf spin:SelectTemplates ;
spin:body
[ rdf:type sp:Select ;
sp:distinct "true"^^xsd:boolean ;
sp:orderBy ([ rdf:type fn:lower-case ;
sp:arg1 [ sp:varName "label"^^xsd:string
]
]) ;
sp:resultVariables ([ sp:varName "resource"^^xsd:string
]) ;
sp:where ([ rdf:type sp:TriplePath ;
sp:object
[ sp:varName "resourceType"^^xsd:string
] ;
sp:path [ rdf:type sp:ModPath ;
sp:modMax -2 ;
sp:modMin 0 ;
sp:subPath rdfs:subClassOf
] ;
sp:subject
[ sp:varName "type"^^xsd:string
]
] [ sp:object
[ sp:varName "type"^^xsd:string
] ;
sp:predicate rdf:type ;
sp:subject
[ sp:varName "resource"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:isIRI ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type ui:label ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
] ;
sp:variable
[ sp:varName "label"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:upper-case ;
sp:arg1 [ rdf:type fn:substring ;
sp:arg1 [ sp:varName "label"^^xsd:string
] ;
sp:arg2 1 ;
sp:arg3 1
]
] ;
sp:variable
[ sp:varName "first"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:not ;
sp:arg1 [ rdf:type fn:contains ;
sp:arg1 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
sp:arg2 [ sp:varName "first"^^xsd:string
]
]
]
])
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The type of resources to match (will include subclasses of the type)."^^xsd:string ;
spl:predicate arg:resourceType ;
spl:valueType rdfs:Class
] .
app:allValuesFromFunctor
rdf:type spin:Function ;
rdfs:comment "Can be used in conjunction with spif:walkObjects to get the \"first\" declared owl:allValuesFrom restriction of a given property (?property) at a given class (?class)."^^xsd:string ;
......@@ -809,6 +961,76 @@ app:isSingle
spin:private "true"^^xsd:boolean ;
spin:returnType xsd:boolean .
app:letters
rdf:type spin:MagicProperty ;
rdfs:comment "Binds the variable on the left with all letters from A-Z, and then *."^^xsd:string ;
rdfs:label "letters"^^xsd:string ;
rdfs:subClassOf spin:MagicProperties ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables ([ sp:varName "letter"^^xsd:string
]) ;
sp:where ([ rdf:type sp:Bind ;
sp:expression "ABCDEFGHIJKLMNOPQRSTUVXYZ*" ;
sp:variable
[ sp:varName "str"^^xsd:string
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:string-length ;
sp:arg1 [ sp:varName "str"^^xsd:string
]
] ;
sp:variable
[ sp:varName "length"^^xsd:string
]
] [ sp:object
[ sp:varName "?0"^^xsd:string
] ;
sp:predicate spif:for ;
sp:subject
[ sp:varName "x"^^xsd:string
]
] [ sp:object 1 ;
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 "length"^^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
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type fn:substring ;
sp:arg1 [ sp:varName "str"^^xsd:string
] ;
sp:arg2 [ sp:varName "x"^^xsd:string
] ;
sp:arg3 1
] ;
sp:variable
[ sp:varName "letter"^^xsd:string
]
])
] ;
spin:returnType xsd:string .
app:localDomain
rdf:type spin:Function ;
rdfs:comment "Gets the \"domain\" of a property at an object. This is used to narrow down the Subjects widgets at edit time. Currently only uses rdfs:domain of the property, but future versions should also look at restrictions and spl:Arguments."^^xsd:string ;
......@@ -1268,6 +1490,11 @@ arg:class
rdfs:label "class"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
arg:letter
rdf:type rdf:Property ;
rdfs:label "letter"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
arg:node
rdf:type rdf:Property ;
rdfs:label "node"^^xsd:string ;
......
......@@ -2101,6 +2101,180 @@ app:ImageResourceViewer
]
] .
app:Index
rdf:type ui:NodeClass ;
rdfs:comment "Displays a list of hyperlinks A B C ... Z * where each letter opens a dialog with all resources starting with that letter."^^xsd:string ;
rdfs:label "Index"^^xsd:string ;
rdfs:subClassOf app:IndexElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The JavaScript code that will be called if the user has selected a resource. The variable resource will point to the URI of the selected resource."^^xsd:string ;
spl:predicate arg:onSelect ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The type of instances to index."^^xsd:string ;
spl:predicate arg:resourceType ;
spl:valueType rdfs:Resource
] ;
ui:prototype
[ rdf:type html:Div ;
html:class "appIndex"^^xsd:string ;
ui:child
[ rdf:type ui:forEach ;
ui:child
[ rdf:type html:A ;
html:href "javascript:void(0)"^^xsd:string ;
html:onclick
[ rdf:type ui:concat ;
sp:arg1 "appOpenIndexLetterDialog('appIndexLetterDialog', '"^^xsd:string ;
sp:arg2 [ sp:varName "letter"^^xsd:string
] ;
sp:arg3 "')"^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text [ sp:varName "letter"^^xsd:string
]
] ;
ui:childIndex 0
] ;
ui:childIndex 0 ;
ui:resultSet
[ rdf:type sp:Select ;
sp:where ([ sp:object
[ sp:varName "letter"^^xsd:string
] ;
sp:predicate app:letters ;
sp:subject ()
])
] ;
ui:separator " "^^xsd:string
] ;
ui:child
[ rdf:type app:IndexLetterDialog ;
arg:onSelect
[ sp:varName "onSelect"^^xsd:string
] ;
arg:resourceType
[ sp:varName "resourceType"^^xsd:string
] ;
ui:childIndex 1
]
] .
app:IndexElements
rdf:type ui:NodeClass ;
rdfs:label "Index elements"^^xsd:string ;
rdfs:subClassOf app:Elements ;
ui:abstract "true"^^xsd:boolean .
app:IndexLetterDialog
rdf:type ui:NodeClass ;
rdfs:comment "A dialog that displays a sorted list of all resources starting with a given letter."^^xsd:string ;
rdfs:label "Index letter dialog"^^xsd:string ;
rdfs:subClassOf app:IndexElements ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The JavaScript that will be called."^^xsd:string ;
spl:predicate arg:onSelect ;
spl:valueType xsd:string
] ;
spin:constraint
[ rdf:type spl:Argument ;
rdfs:comment "The type of instances to display."^^xsd:string ;
spl:predicate arg:resourceType ;
spl:valueType rdfs:Resource
] ;
ui:prototype
[ rdf:type ui:loadable ;
html:style "display: none"^^xsd:string ;
ui:child
[ rdf:type ui:if ;
ui:child
[ rdf:type ui:call ;
arg:letter
[ sp:varName "letter"^^xsd:string
] ;
arg:resourceType
[ sp:varName "resourceType"^^xsd:string
] ;
ui:child
[ rdf:type html:Div ;
html:id "div-appIndexLetterDialog"^^xsd:string ;
html:title
[ rdf:type ui:concat ;
sp:arg1 "Resources starting with "^^xsd:string ;
sp:arg2 [ sp:varName "letter"^^xsd:string
] ;
sp:arg3 " ("^^xsd:string ;
sp:arg4 [ rdf:type spr:rowCount ;
sp:arg1 [ sp:varName "rs"^^xsd:string
]
] ;
sp:arg5 ")"^^xsd:string
] ;
ui:child
[ rdf:type ui:forEach ;
ui:child
[ rdf:type html:Div ;
html:class "appIndexSummary"^^xsd:string ;
ui:child
[ rdf:type html:A ;
html:href "javascript:void(0)"^^xsd:string ;
html:onclick
[ rdf:type ui:concat ;
sp:arg1 "var resource = '"^^xsd:string ;
sp:arg2 [ sp:varName "resource"^^xsd:string
] ;
sp:arg3 "';"^^xsd:string ;
sp:arg4 [ sp:varName "onSelect"^^xsd:string
] ;
sp:arg5 ";appCloseDialog('appIndexLetterDialog');"^^xsd:string
] ;
ui:child
[ rdf:type ui:TextNode ;
ui:childIndex 0 ;
ui:text [ rdf:type ui:label ;
sp:arg1 [ sp:varName "resource"^^xsd:string
]
]
] ;
ui:childIndex 0
] ;
ui:childIndex 0
] ;
ui:childIndex 0 ;
ui:resultSet
[ sp:varName "rs"^^xsd:string
]
] ;
ui:childIndex 0
] ;
ui:childIndex 0 ;
ui:template
[ rdf:type sp:if ;
sp:arg1 [ rdf:type sp:eq ;
sp:arg1 [ sp:varName "letter"^^xsd:string
] ;
sp:arg2 "*"
] ;
sp:arg2 app:ResourcesWithNonLetter ;
sp:arg3 app:ResourcesWithLetter
]
] ;
ui:childIndex 0 ;
ui:condition
[ rdf:type sp:bound ;
sp:arg1 [ sp:varName "letter"^^xsd:string
]
]
] ;
ui:loadId "appIndexLetterDialog"^^xsd:string
] .
app:Label
rdf:type ui:NodeClass ;
rdfs:label "Label"^^xsd:string ;
......@@ -3866,7 +4040,7 @@ app:ResourceFacet
] ;
ui:prototype
[ rdf:type app:AutoComplete ;
arg:id [ rdf:type fn:concat ;
arg:id [ rdf:type ui:concat ;
sp:arg1 "value"^^xsd:string ;
sp:arg2 [ sp:varName "uid"^^xsd:string
]
......@@ -4084,8 +4258,8 @@ app:ResourceViewDialog
]
] ;
ui:childIndex 0 ;
ui:varName "noLinks"^^xsd:string ;
ui:varValue "true"^^xsd:boolean
ui:varName "createLinkFunction"^^xsd:string ;
ui:varValue app:noLink
] ;
ui:childIndex 0
] ;
......@@ -6962,29 +7136,6 @@ app:createLink
sp:where ([ rdf:type sp:Bind ;
sp:expression
[ rdf:type ui:contextValue ;
sp:arg1 "noLinks"
] ;
sp:variable
[ sp:varName "noLinks"^^xsd:string
]
] [ rdf:type sp:Filter ;
sp:expression
[ rdf:type sp:or ;
sp:arg1 [ rdf:type sp:not ;
sp:arg1 [ rdf:type sp:bound ;
sp:arg1 [ sp:varName "noLinks"^^xsd:string
]
]
] ;
sp:arg2 [ rdf:type sp:ne ;
sp:arg1 [ sp:varName "noLinks"^^xsd:string
] ;
sp:arg2 "true"^^xsd:boolean
]
]
] [ rdf:type sp:Bind ;
sp:expression
[ rdf:type ui:contextValue ;
sp:arg1 "createLinkFunction"
] ;
sp:variable
......@@ -7409,6 +7560,18 @@ app:modeProperty
spl:valueType rdf:Property
] .
app:noLink
rdf:type spin:Function ;
rdfs:comment "A dummy function that returns nothing, suppressing any links."^^xsd:string ;
rdfs:label "no link"^^xsd:string ;
rdfs:subClassOf app:CreateLinkFunctions ;
spin:body
[ rdf:type sp:Select ;
sp:resultVariables ([ sp:varName "nothing"^^xsd:string
]) ;
sp:where ()
] .
app:objectWidgetClass
rdf:type rdf:Property ;
rdfs:domain app:Mode ;
......@@ -7497,6 +7660,11 @@ app:weight
rdfs:range xsd:integer ;
rdfs:subPropertyOf app:systemProperty .
arg:callback
rdf:type rdf:Property ;
rdfs:label "callback"^^xsd:string ;
rdfs:subPropertyOf sp:arg .
arg:child
rdf:type rdf:Property ;
rdfs:label "child"^^xsd:string ;
......
......@@ -29,6 +29,15 @@ body {
display: inline-block !important;
}
.appIndex {
font-size: 12px;
text-align: right;
}
.appIndexSummary {
font-size: 12px;
}
.appLabeledObjectsBodyTD {
padding: 0px 0px 1px 0px;
}
......
......@@ -73,6 +73,18 @@ function appAddRow(id, single) {
/**
* Programmatically closes and destroys the elements of a dialog that was previously
* loaded through a ui:loadable.
* @param loadId the id of the loadable surrounding the dialog
*/
function appCloseDialog(loadId) {
var div = $('#div-' + loadId);
div.dialog("destroy");
div.remove();
}
/**
* Called when the user clicks delete to delete a row from a widget.
* This completely deletes the element with the given id.
* The hidden fields to instruct the server that the given object
......@@ -108,7 +120,7 @@ function appInitAutoComplete(id, hiddenId, link) {
return item.label;
},
select : function(event, ui) {
$('#' + hiddenId).val(ui.item.resource);
$('#' + hiddenId).val('<' + ui.item.resource + '>');
}
});
}
......@@ -312,6 +324,22 @@ function appNavigateToInTab(resourceURI, queryGraphURI) {
}
// Private
function appOpenIndexLetterDialog(loadId, letter) {
appLoad(loadId, { letter: '"' + letter + '"' }, function() {
var div = $('#div-' + loadId);
var title = div.attr('title');
var options = {
modal: true,
title: title,
width: 500,
height: 400
};
div.dialog(options);
});
}
/**
* Loads and then opens a dialog that was inserted into the current
* document using app:ResourceViewDialog.
......
......@@ -82,8 +82,8 @@ rhswp:AGResourceViewDialog
]
] ;
ui:childIndex 0 ;
ui:varName "noLinks"^^xsd:string ;
ui:varValue "true"^^xsd:boolean
ui:varName "createLinkFunction"^^xsd:string ;
ui:varValue <http://appschema.org/noLink>
] ;
ui:childIndex 0
] ;
......