All Downloads are FREE. Search and download functionalities are using the official Maven repository.

webapp.data.demo.system.server.rq Maven / Gradle / Ivy

Go to download

Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1 Query and Update.

The newest version!
#
# Server Event Function
# Current graph is SPARQL endpoint graph
# SPARQLRestAPI getVisitor().beforeRequest() and afterRequest()
# Use with -param file with: [] cos:function [ cos:load  ]
#
#

prefix fun: 
prefix ff1:  
prefix ff:  

#@public @import  

#
# @init function called by Parameter after Parameter graph load processing
# We can set application specific parameters
# PRAGMA: for this @init function the current graph is the Parameter graph
# whereas for other @event function it is the current graph of the query at stake
#
@public @initParam
function us:initParam() {
    xt:print("@initParam");
    us:initialize()
}

@public @initServer
function us:initServer(url) {
    xt:print("@initServer", url);
    #xt:print(xt:graph())
}


# current graph is Parameter graph
@public 
function us:initialize() {
    #xt:print(xt:turtle(xt:graph()));
    let (select * where { [] cos:load ?name }) {
        xt:print("load:", ?name)
    }
}



@public @insert
function us:insert(path, atriple) {
	xt:print("@insert", atriple);
}



@public @beforeRequest
function us:beforeRequest(dt:HttpServletRequest request, q) {
    xt:print("\n@beforeRequest");
    xt:print(request);
    us:trace(request);
    xt:print("query:\n", q)
}

@public @afterRequest
function us:afterRequest(dt:HttpServletRequest request, dt:Response resp, q, amap, res) {
    xt:print("\n@afterRequest");
    xt:print(resp);
    us:traceResponce(resp);
    xt:print("result:", amap);
    xt:print(res)
}


@public
function us:trace(dt:HttpServletRequest request) {
    for (name in fun:list(java:getHeaderNames(request))) {
        xt:print("header:", name, "=", java:getHeader(request, name));
    } ;
    for (name in fun:list(java:getParameterNames(request))) {
        xt:print("param:", name, "=", java:getParameter(request, name));
    } ;
    xt:print("path:", java:getContextPath(request));
    xt:print("method:", java:getMethod(request));
}


@public
function us:traceResponce(dt:Response resp) {
    xt:print(java:getStringHeaders(resp))
}



@public
function us:tracemore(dt:HttpServletRequest request) {
    for (name in fun:list(java:getAttributeNames(request))) {
        xt:print("attribute:", name, "=", java:getAttribute(request, name));
    } ;
    for (name in coalesce(fun:list(java:getCookies(request)), xt:list())) {
        xt:print("cookie:", name);
    } ;
    let (cn = java:getServletContext(request)) {
        for (name in fun:list(java:getAttributeNames(cn))) {
            xt:print("context:", name, "=", java:getAttribute(cn, name));
        }
    }
}










© 2015 - 2025 Weber Informatics LLC | Privacy Policy