You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Andrew Reslan <an...@mac.com> on 2013/08/29 15:28:08 UTC

Getting custom property functions to work with Fuseki

I have three custom property functions, that I have been using in Jena for some time.

I have been using these through Java code, and manually register the function factory before queries are processed.

I want to use these property functions via Fuseki, but at the moment it looks as though they are being bypassed and the query gets send through to the backing store (in this case D2RQ).

I have added the following line to my config file in the server definition to load a class that registers the property functions in a static block.

[] ja:loadClass "foo.bar.MyClass"

If I use the wrong class name then I see a ClassNotFoundError, so it appears that the class is correctly located.

In the class I have added a static block:

{
	PropertyFunctionRegistry.get().put("FUNCTION1 URI", new FunctionFactory());
	PropertyFunctionRegistry.get().put("FUNCTION2 URI", new FunctionFactory());
	PropertyFunctionRegistry.get().put("FUNCTION3 URI", new FunctionFactory());
}

I have added System.err debug messages to the static block and the function classes, but I see none of these, does fuseki redirect System.err?

Andy



Re: Getting custom property functions to work with Fuseki

Posted by Andy Seaborne <an...@apache.org>.
On 30/08/13 13:29, Andrew Reslan wrote:
> I  have written a bootstrap class that registers the function factory for each custom function, and then calls the main() method on the FusekiCmd class passing in any command line args.
>
> I can now see the log4j debug messages from the factory code, but I still cannot call the functions using the mapped ontology URI's when they were registered.
>
> I'm guessing this is because I register the functions, then start the fuseki server, and this is using a different context or is re-initialising the property function map?
>
> I have a way forward if I use direct java: URI's, but I still can not use the mapped ontology URI's to access the property functions.
>
>
> Andy
>
> On 30 Aug 2013, at 11:29, Andrew Reslan <an...@mac.com> wrote:
>
>> I have now made some progress
>>
>> If I call the custom functions using the java:  URI directly to the class, then the functions are run against the in memory dataset.
>>
>> The immediate issue is how to register the mappings from the ontology to the property function Factory, I need to do this as the factory injects config into the function instances for accessing an external query service.
>>
>> Andy
>>
>> On 30 Aug 2013, at 10:58, Andrew Reslan <an...@mac.com> wrote:
>>
>

Could you provide a complete, minimal example?

Also ... what specific additional functionality do you ant to add? 
Maybe there is another way.

	Andy

Re: Getting custom property functions to work with Fuseki

Posted by Andrew Reslan <an...@mac.com>.
I  have written a bootstrap class that registers the function factory for each custom function, and then calls the main() method on the FusekiCmd class passing in any command line args.

I can now see the log4j debug messages from the factory code, but I still cannot call the functions using the mapped ontology URI's when they were registered.

I'm guessing this is because I register the functions, then start the fuseki server, and this is using a different context or is re-initialising the property function map?

I have a way forward if I use direct java: URI's, but I still can not use the mapped ontology URI's to access the property functions.


Andy

On 30 Aug 2013, at 11:29, Andrew Reslan <an...@mac.com> wrote:

> I have now made some progress
> 
> If I call the custom functions using the java:  URI directly to the class, then the functions are run against the in memory dataset.
> 
> The immediate issue is how to register the mappings from the ontology to the property function Factory, I need to do this as the factory injects config into the function instances for accessing an external query service.
> 
> Andy
> 
> On 30 Aug 2013, at 10:58, Andrew Reslan <an...@mac.com> wrote:
> 


Re: Getting custom property functions to work with Fuseki

Posted by Andrew Reslan <an...@mac.com>.
I have now made some progress

If I call the custom functions using the java:  URI directly to the class, then the functions are run against the in memory dataset.

The immediate issue is how to register the mappings from the ontology to the property function Factory, I need to do this as the factory injects config into the function instances for accessing an external query service.

Andy

On 30 Aug 2013, at 10:58, Andrew Reslan <an...@mac.com> wrote:

> You are right, the query is passed to D2RQ for processing, so it treats the property function just like any other predicate.
> 
> I have now setup an in memory dataset to test the functions, but the custom property functions still do not appear to get registered or used.
> 
> I have now added the public static void init()" method around the static block and changed debug to use log4j, I have the default log level set to DEBUG and my logging is set at INFO, but still no output.
> 
> In my configuration file, do I need to initialise the factory after loading the class?
> 
> On starting Fuseki I see the following:
> 
> symbol:http://jena.hpl.hp.cpm/ARQ#enablePropertyFunctions = true
> 
> So it looks like property functions are enabled by default.
> 
> 
> 
> Andy
> 
> On 29 Aug 2013, at 18:09, Andy Seaborne <an...@apache.org> wrote:
> 
>> On 29/08/13 14:28, Andrew Reslan wrote:
>>> I have three custom property functions, that I have been using in Jena for some time.
>>> 
>>> I have been using these through Java code, and manually register the function factory before queries are processed.
>>> 
>>> I want to use these property functions via Fuseki, but at the moment it looks as though they are being bypassed and the query gets send through to the backing store (in this case D2RQ).
>>> 
>>> I have added the following line to my config file in the server definition to load a class that registers the property functions in a static block.
>>> 
>>> [] ja:loadClass "foo.bar.MyClass"
>>> 
>>> If I use the wrong class name then I see a ClassNotFoundError, so it appears that the class is correctly located.
>>> 
>>> In the class I have added a static block:
>>> 
>>> {
>>> 	PropertyFunctionRegistry.get().put("FUNCTION1 URI", new FunctionFactory());
>>> 	PropertyFunctionRegistry.get().put("FUNCTION2 URI", new FunctionFactory());
>>> 	PropertyFunctionRegistry.get().put("FUNCTION3 URI", new FunctionFactory());
>>> }
>>> 
>>> I have added System.err debug messages to the static block and the function classes, but I see none of these, does fuseki redirect System.err?
>> 
>> Depends how you run fuseki.  I think the script 'fuseki' send output to log/stderrout.log, 'fuseki-server' does not -- where does your normal output go?
>> 
>> Does the class have a "public static void init()" method?  That is what is called by  [] ja:loadClass "foo.bar.MyClass"  No init() and the class is only loaded which I think means no calling static blocks.
>> 
>> (can't remember how D2RQ works)
>> 
>> It's the particular query engine that provides property functions.  If the query goes to D2RQ, then property functions will only work if D2RQ provides then.
>> 
>> If it's a single graph in a general dataset then the query engine is the general one and they will work.
>> 
>> 	Andy
>> 
>> 
>> 
>>> 
>>> Andy
>>> 
>>> 
>> 
> 


Re: Getting custom property functions to work with Fuseki

Posted by Andrew Reslan <an...@mac.com>.
You are right, the query is passed to D2RQ for processing, so it treats the property function just like any other predicate.

I have now setup an in memory dataset to test the functions, but the custom property functions still do not appear to get registered or used.

I have now added the public static void init()" method around the static block and changed debug to use log4j, I have the default log level set to DEBUG and my logging is set at INFO, but still no output.

In my configuration file, do I need to initialise the factory after loading the class?

On starting Fuseki I see the following:

symbol:http://jena.hpl.hp.cpm/ARQ#enablePropertyFunctions = true

So it looks like property functions are enabled by default.



Andy

On 29 Aug 2013, at 18:09, Andy Seaborne <an...@apache.org> wrote:

> On 29/08/13 14:28, Andrew Reslan wrote:
>> I have three custom property functions, that I have been using in Jena for some time.
>> 
>> I have been using these through Java code, and manually register the function factory before queries are processed.
>> 
>> I want to use these property functions via Fuseki, but at the moment it looks as though they are being bypassed and the query gets send through to the backing store (in this case D2RQ).
>> 
>> I have added the following line to my config file in the server definition to load a class that registers the property functions in a static block.
>> 
>> [] ja:loadClass "foo.bar.MyClass"
>> 
>> If I use the wrong class name then I see a ClassNotFoundError, so it appears that the class is correctly located.
>> 
>> In the class I have added a static block:
>> 
>> {
>> 	PropertyFunctionRegistry.get().put("FUNCTION1 URI", new FunctionFactory());
>> 	PropertyFunctionRegistry.get().put("FUNCTION2 URI", new FunctionFactory());
>> 	PropertyFunctionRegistry.get().put("FUNCTION3 URI", new FunctionFactory());
>> }
>> 
>> I have added System.err debug messages to the static block and the function classes, but I see none of these, does fuseki redirect System.err?
> 
> Depends how you run fuseki.  I think the script 'fuseki' send output to log/stderrout.log, 'fuseki-server' does not -- where does your normal output go?
> 
> Does the class have a "public static void init()" method?  That is what is called by  [] ja:loadClass "foo.bar.MyClass"  No init() and the class is only loaded which I think means no calling static blocks.
> 
> (can't remember how D2RQ works)
> 
> It's the particular query engine that provides property functions.  If the query goes to D2RQ, then property functions will only work if D2RQ provides then.
> 
> If it's a single graph in a general dataset then the query engine is the general one and they will work.
> 
> 	Andy
> 
> 
> 
>> 
>> Andy
>> 
>> 
> 


Re: Getting custom property functions to work with Fuseki

Posted by Andy Seaborne <an...@apache.org>.
On 29/08/13 14:28, Andrew Reslan wrote:
> I have three custom property functions, that I have been using in Jena for some time.
>
> I have been using these through Java code, and manually register the function factory before queries are processed.
>
> I want to use these property functions via Fuseki, but at the moment it looks as though they are being bypassed and the query gets send through to the backing store (in this case D2RQ).
>
> I have added the following line to my config file in the server definition to load a class that registers the property functions in a static block.
>
> [] ja:loadClass "foo.bar.MyClass"
>
> If I use the wrong class name then I see a ClassNotFoundError, so it appears that the class is correctly located.
>
> In the class I have added a static block:
>
> {
> 	PropertyFunctionRegistry.get().put("FUNCTION1 URI", new FunctionFactory());
> 	PropertyFunctionRegistry.get().put("FUNCTION2 URI", new FunctionFactory());
> 	PropertyFunctionRegistry.get().put("FUNCTION3 URI", new FunctionFactory());
> }
>
> I have added System.err debug messages to the static block and the function classes, but I see none of these, does fuseki redirect System.err?

Depends how you run fuseki.  I think the script 'fuseki' send output to 
log/stderrout.log, 'fuseki-server' does not -- where does your normal 
output go?

Does the class have a "public static void init()" method?  That is what 
is called by  [] ja:loadClass "foo.bar.MyClass"  No init() and the class 
is only loaded which I think means no calling static blocks.

(can't remember how D2RQ works)

It's the particular query engine that provides property functions.  If 
the query goes to D2RQ, then property functions will only work if D2RQ 
provides then.

If it's a single graph in a general dataset then the query engine is the 
general one and they will work.

	Andy



>
> Andy
>
>