
webapp.data.query.function.rq Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of corese-server Show documentation
Show all versions of corese-server Show documentation
Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1
Query and Update.
The newest version!
#
# Functions shared by server STTL transformations
# javascript:trans() defined in webapp/js/server.js
#
@public {
function st:setclass(s, cl) {
st:cset(st:class, s, cl)
}
function st:setclass(s, cl, g) {
st:setclass(s, cl) ;
st:setgroup(s, g)
}
function st:getclass(s) {
st:cget(st:class, s)
}
function st:setgroup(s, cl) {
st:cset(st:group, s, cl)
}
function st:getgroup(s) {
st:cget(st:group, s)
}
function st:setimg(s, i) {
st:cset(st:img, s, i)
}
# for D3 nodes.rq
# server URL interpreted by javascript:trans(URL)
# LOD URL interpreted by window.open(URL)
function st:setlink(s, link) {
if (contains(link, "?uri=") || contains(link, "param="),
# server URL
st:cset(st:link, s, link),
# LOD URL
st:cset(st:url, s, link))
}
function st:isAjax(){
st:get(st:protocol, st:ajax)
}
function st:protocol(url) {
if (st:isAjax()) {
concat("javascript:trans(\"", str(url), "\")")
}
else { str(url) }
}
# take st:include (("mode" st:mode)) into account
# to generate hyperlink
# &mode= st:get(st:mode)
function st:link(url) {
concat(
st:get(st:service),
"?uri=", encode_for_uri(url),
if (coalesce(isURI(st:get(st:profile)), false),
concat("&profile=", st:qname(st:get(st:profile))),
if (coalesce(isURI(st:get(st:transform)), false),
concat("&transform=", st:qname(st:get(st:transform))),
"") ),
st:include()
)
}
function st:link123(url) {
concat(
st:get(st:service),
"?uri=", encode_for_uri(url),
coalesce(
concat("&profile=", st:qname(st:get(st:profile))),
concat("&transform=", st:qname(st:get(st:transform))),
""),
st:include()
)
}
# take st:include (("mode" st:mode)) into account
# to generate hyperlink
# &mode= st:get(st:mode)
function st:link(url, profile) {
concat(st:get(st:service),
"?uri=", encode_for_uri(url),
"&profile=", st:qname(profile)
,st:include()
)
}
function st:plink(url) {
st:protocol(st:link(url))
}
function st:plink(url, profile) {
st:protocol(st:link(url, profile))
}
#
# try to get specific profile for uri from profile.ttl
# st:lodprofile (( st:dbpedia ))
# otherwise use st:profile
#
function st:pplink(url) {
st:plink(url, coalesce(st:getprofile(url), st:get(st:profile)))
}
# pplink without java:trans()
function st:hlink(url) {
let (profile = coalesce(st:getprofile(url), st:get(st:profile))) {
if (profile = st:lod, url, st:link(url, profile))
}
}
function st:hlink(url, profile) {
st:link(url, profile)
}
function st:qname(url){
kg:qname(url)
}
#
# st:param [ st:include (("mode" st:mode)) ]
# "&mode=" st:get(st:mode)
#
function st:include(){
coalesce(
reduce(rq:concat, maplist(
lambda((name, val)) {
coalesce(let (value = st:get(val)) {
concat("&", name, "=",
if (isURI(value), st:qname(value), value))
}, "")
},
st:get(st:include))),
"")
}
#
# take st:lodprofile into account
# st:lodprofile (( st:jdev) ("*" st:lod))
# if getprofile(x) = st:lod, return uri as is, otherwise return pplink
#
function st:url(x) {
if (coalesce(st:getprofile(x) = st:lod, false), x, st:pplink(x))
}
# arg = st:mode
function st:include(arg){
coalesce(
let (m = st:get(arg)) { bound(m) } &&
mapany (rq:equal, arg, st:get(st:include)),
false)
}
# search list st:lodprofile ((namespace profile))
function st:getprofile(url){
let ((ns, prof) = mapfind(st:match, url, st:get(st:lodprofile)))
{ prof }
}
# decl = (namespace profile)
function st:match(x, decl){
let ((ns) = decl){
strstarts(x, ns) || coalesce(ns = "*", false)
}
}
# ____________________________________________________
#
# Record country locations from Mappings into st:set(st:location)
# as a list of (country lat lon)
# used by st:navlab#map
#
function st:location(location, lat, lon) {
if (st:cget(st:country, location, location)) {}
else {
st:cset(st:country, location, location) ;
st:set(st:location,
xt:cons(xt:list(location, lat, lon),
coalesce(st:get(st:location), xt:list() ) ) )
}
}
function st:location(amap) {
let (list = xt:list(), table = xt:map()) {
for ((country lat lon) in amap) {
if (! xt:member(country, table) && bound(lat)) {
xt:add(list, xt:list(country, lat, lon)) ;
xt:set(table, country, country)
}
} ;
st:set(st:location, list) ;
xt:print('list', list)
}
}
###
function st:head(){
return ("")
}
function st:tail(){
return ("")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy