Search in sources :

Example 1 with FunctionRegistry

use of org.apache.jena.sparql.function.FunctionRegistry in project jena by apache.

the class E_Function method functionFactory.

private FunctionFactory functionFactory(Context cxt) {
    FunctionRegistry registry = chooseRegistry(cxt);
    FunctionFactory ff = registry.get(functionIRI);
    return ff;
}
Also used : FunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry) FunctionFactory(org.apache.jena.sparql.function.FunctionFactory)

Example 2 with FunctionRegistry

use of org.apache.jena.sparql.function.FunctionRegistry in project jena by apache.

the class GeoSPARQLConfig method loadFunctions.

public static final void loadFunctions() {
    // Only register functions once.
    if (!IS_FUNCTIONS_REGISTERED) {
        // loading is actually idempotent.
        IS_FUNCTIONS_REGISTERED = true;
        /*
             * If jul-to-slf4j SLF4JBridgeHandler has not been setup,
             * then this can generate a warning via java.util.logging.
             *
             *   Dec 28, 2021 10:56:27 AM org.apache.sis.referencing.factory.sql.EPSGFactory <init>
             *   WARNING: The “SIS_DATA” environment variable is not set.
             */
        // Setup Default Coordinate Reference Systems
        SRSRegistry.setupDefaultSRS();
        // Register GeometryDatatypes with the TypeMapper.
        GeometryDatatype.registerDatatypes();
        // Register Property and Filter functions.
        PropertyFunctionRegistry propertyRegistry = PropertyFunctionRegistry.get();
        FunctionRegistry functionRegistry = FunctionRegistry.get();
        NonTopological.loadFilterFunctions(functionRegistry);
        functionRegistry.put(Geo.RELATE_NAME, RelateFF.class);
        SimpleFeatures.loadPropertyFunctions(propertyRegistry);
        SimpleFeatures.loadFilterFunctions(functionRegistry);
        Egenhofer.loadPropertyFunctions(propertyRegistry);
        Egenhofer.loadFilterFunctions(functionRegistry);
        RCC8.loadPropertyFunctions(propertyRegistry);
        RCC8.loadFilterFunctions(functionRegistry);
        Relate.loadRelateFunction(functionRegistry);
        GeometryProperty.loadPropertyFunctions(propertyRegistry);
        GeometryProperty.loadFilterFunctions(functionRegistry);
        Spatial.loadPropertyFunctions(propertyRegistry);
        Spatial.loadFilterFunctions(functionRegistry);
    }
}
Also used : PropertyFunctionRegistry(org.apache.jena.sparql.pfunction.PropertyFunctionRegistry) FunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry) PropertyFunctionRegistry(org.apache.jena.sparql.pfunction.PropertyFunctionRegistry)

Example 3 with FunctionRegistry

use of org.apache.jena.sparql.function.FunctionRegistry in project jena by apache.

the class ExFuseki_05_CustomFunction method main.

public static void main(String... a) {
    FusekiLogging.setLogging();
    // ---- Register the function
    FunctionRegistry ref = FunctionRegistry.get();
    ref.put("http://my/num", MyFunction.class);
    // ---- Show it can be used
    // -- Start a server
    int PORT = WebLib.choosePort();
    // Some empty dataset
    DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
    FusekiServer server = FusekiServer.create().port(PORT).add("/ds", dsg).build();
    server.start();
    // -- Call the server
    String queryString = StrUtils.strjoinNL("SELECT * { ", "  VALUES ?Z { 123 'abc'}", "  BIND (<http://my/num>(?Z) AS ?X )", "}");
    try {
        String url = "http://localhost:" + PORT + "/ds";
        // Connect to the server and execute the query.
        try (RDFConnection conn = RDFConnection.connect(url)) {
            conn.queryResultSet(queryString, ResultSetFormatter::out);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        server.stop();
    }
}
Also used : FunctionRegistry(org.apache.jena.sparql.function.FunctionRegistry) ResultSetFormatter(org.apache.jena.query.ResultSetFormatter) RDFConnection(org.apache.jena.rdfconnection.RDFConnection) FusekiServer(org.apache.jena.fuseki.main.FusekiServer) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph)

Aggregations

FunctionRegistry (org.apache.jena.sparql.function.FunctionRegistry)3 FusekiServer (org.apache.jena.fuseki.main.FusekiServer)1 ResultSetFormatter (org.apache.jena.query.ResultSetFormatter)1 RDFConnection (org.apache.jena.rdfconnection.RDFConnection)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 FunctionFactory (org.apache.jena.sparql.function.FunctionFactory)1 PropertyFunctionRegistry (org.apache.jena.sparql.pfunction.PropertyFunctionRegistry)1