You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Nouwt, B. (Barry)" <ba...@tno.nl> on 2017/12/12 10:36:42 UTC

RE: Assembler for GenericRuleEngine Custom Builtin

Thanks for your reply. I have a follow up question.

I've successfully created a CustomBuiltinAssembler that 'opens' the custom builtin's and loads them into the BuiltinRegistry. So, if I use the statement:

Assembler.general.open(truckRoot);

to explicitly open those resources (and load them in the BuiltinRegistry) from the Assembler specs, it works like expected.

However, in Apache Jena Fuseki the custom builtin's do not get loaded from a configuration file. I suspect this happens because Fuseki only tries to open 'services' and everything related to them and does not try to load any dangling resources (like my CustomBuiltin's). Because I rather not extend the existing InfModelAssembler of Apache Jena, I have no way of connect my CustomBuiltin's to the services resource. My current Assembler specs can be found below.

Am I right that my CustomBuiltin's need to be connected to a Fuseki service to get loaded? And is there some way to achieve this without extending some existing Assember?

Kind regards,

Barry Nouwt


@prefix : <http://www.example.org/tno#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .

tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
tdb:GraphTDB rdfs:subClassOf ja:Model .

:CustomBuiltin rdfs:subClassOf ja:Object ;
	ja:assembler "nl.tno.ds.cb.CustomBuiltinAssembler" .

:shipCustom a :CustomBuiltin ;
	:hasClass "nl.tno.ds.cb.FirstBuiltin" .
	
:truckCustom a :CustomBuiltin ;
	:hasClass "nl.tno.ds.cb.SecondBuiltin" .

:dataset rdf:type ja:RDFDataset ;
	ja:defaultGraph <#infGraph> .

<#infGraph>  rdf:type ja:InfModel ;
             ja:reasoner [ ja:rulesFrom <file:src/test/resources/et.rules> ; ] ;
             ja:content <#test-inf> .

<#test-inf> ja:externalContent <src/test/resources/data.ttl> .

-----Original Message-----
From: ajs6f [mailto:ajs6f@apache.org] 
Sent: zaterdag 25 november 2017 15:45
To: users@jena.apache.org
Subject: Re: Assembler for GenericRuleEngine Custom Builtin

I'm not too familiar with the rules system, so I may be wrong, but I think the answer is simply no, we don't have that feature right now. It does sound quite useful. If you write this code for yourself please do open a ticket (actually, that would be nice in any event) and send a PR!

For anyone who may be wondering about programmatic use of custom built-ins, there is a test case here:

org.apache.jena.reasoner.rulesys.test.TestGenericRuleReasonerConfig.testRuleLoadingWithOverridenBuiltins()


ajs6f

> On Nov 24, 2017, at 11:26 AM, Nouwt, B. (Barry) <ba...@tno.nl> wrote:
> 
> Hi all,
> 
> Does anyone know whether there is an Assember to load a custom Builtin (for usage in rules for the GenericRuleEngine) using a Fuseki configuration .ttl file. I assume not, because I cannot find it in: https://github.com/apache/jena/tree/master/jena-core/src/main/java/org/apache/jena/assembler/assemblers
> 
> I do see a RuleSetAssembler and a ReasonerFactory, but they do not seem to have a Builtin load option. Also, via code I use the BuiltinRegistry class, so it would probably be not too difficult to add this feature myself.
> 
> Any pointers?
> 
> Regards, Barry
> 
> 
> 
> 
> This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.


RE: Assembler for GenericRuleEngine Custom Builtin

Posted by "Nouwt, B. (Barry)" <ba...@tno.nl>.
Hi all,

I can confirm that the method described in my previous mail indeed works. You do not need an Assembler to load Custom Builtin Functions, you can load them using the ja:loadClass property:

[] ja:loadClass "nl.tno.ds.cb.FirstBuiltin" ;
 ja:loadClass "nl.tno.ds.cb.SecondBuiltin" .

Regards, Barry


-----Original Message-----
From: Nouwt, B. (Barry) [mailto:barry.nouwt@tno.nl] 
Sent: dinsdag 12 december 2017 13:20
To: users@jena.apache.org
Subject: RE: Assembler for GenericRuleEngine Custom Builtin

Hi Rob, thanks!

I was not aware of this ja:loadClass usage. But if the static initializer blocks get executed, I could of course just replace my CustomBuiltinAssembler with a class that registers the required Builtin's in such a initializer block. I would not have to write an Assembler at all for my use case (of loading a custom builtin function). Is that correct?

I'll test this and confirm whether this actually works or not.

Regards, Barry

-----Original Message-----
From: Rob Vesse [mailto:rvesse@dotnetrdf.org] 
Sent: dinsdag 12 december 2017 12:00
To: users@jena.apache.org
Subject: Re: Assembler for GenericRuleEngine Custom Builtin

See the documentation on Other Assembler directives:

http://jena.apache.org/documentation/assembler/assembler-howto.html#other-assembler-directives

Using ja:loadClass to load in a class that sets up any custom assemblers via static initializer blocks in that class should be sufficient and doesn’t require connection to a Fuseki 

Rob

On 12/12/2017, 10:36, "Nouwt, B. (Barry)" <ba...@tno.nl> wrote:

    Thanks for your reply. I have a follow up question.
    
    I've successfully created a CustomBuiltinAssembler that 'opens' the custom builtin's and loads them into the BuiltinRegistry. So, if I use the statement:
    
    Assembler.general.open(truckRoot);
    
    to explicitly open those resources (and load them in the BuiltinRegistry) from the Assembler specs, it works like expected.
    
    However, in Apache Jena Fuseki the custom builtin's do not get loaded from a configuration file. I suspect this happens because Fuseki only tries to open 'services' and everything related to them and does not try to load any dangling resources (like my CustomBuiltin's). Because I rather not extend the existing InfModelAssembler of Apache Jena, I have no way of connect my CustomBuiltin's to the services resource. My current Assembler specs can be found below.
    
    Am I right that my CustomBuiltin's need to be connected to a Fuseki service to get loaded? And is there some way to achieve this without extending some existing Assember?
    
    Kind regards,
    
    Barry Nouwt
    
    
    @prefix : <http://www.example.org/tno#> .
    @prefix fuseki: <http://jena.apache.org/fuseki#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
    @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
    
    tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
    tdb:GraphTDB rdfs:subClassOf ja:Model .
    
    :CustomBuiltin rdfs:subClassOf ja:Object ;
    	ja:assembler "nl.tno.ds.cb.CustomBuiltinAssembler" .
    
    :shipCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.FirstBuiltin" .
    	
    :truckCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.SecondBuiltin" .
    
    :dataset rdf:type ja:RDFDataset ;
    	ja:defaultGraph <#infGraph> .
    
    <#infGraph>  rdf:type ja:InfModel ;
                 ja:reasoner [ ja:rulesFrom <file:src/test/resources/et.rules> ; ] ;
                 ja:content <#test-inf> .
    
    <#test-inf> ja:externalContent <src/test/resources/data.ttl> .
    
    -----Original Message-----
    From: ajs6f [mailto:ajs6f@apache.org] 
    Sent: zaterdag 25 november 2017 15:45
    To: users@jena.apache.org
    Subject: Re: Assembler for GenericRuleEngine Custom Builtin
    
    I'm not too familiar with the rules system, so I may be wrong, but I think the answer is simply no, we don't have that feature right now. It does sound quite useful. If you write this code for yourself please do open a ticket (actually, that would be nice in any event) and send a PR!
    
    For anyone who may be wondering about programmatic use of custom built-ins, there is a test case here:
    
    org.apache.jena.reasoner.rulesys.test.TestGenericRuleReasonerConfig.testRuleLoadingWithOverridenBuiltins()
    
    
    ajs6f
    
    > On Nov 24, 2017, at 11:26 AM, Nouwt, B. (Barry) <ba...@tno.nl> wrote:
    > 
    > Hi all,
    > 
    > Does anyone know whether there is an Assember to load a custom Builtin (for usage in rules for the GenericRuleEngine) using a Fuseki configuration .ttl file. I assume not, because I cannot find it in: https://github.com/apache/jena/tree/master/jena-core/src/main/java/org/apache/jena/assembler/assemblers
    > 
    > I do see a RuleSetAssembler and a ReasonerFactory, but they do not seem to have a Builtin load option. Also, via code I use the BuiltinRegistry class, so it would probably be not too difficult to add this feature myself.
    > 
    > Any pointers?
    > 
    > Regards, Barry
    > 
    > 
    > 
    > 
    > This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.
    
    





RE: Assembler for GenericRuleEngine Custom Builtin

Posted by "Nouwt, B. (Barry)" <ba...@tno.nl>.
Hi Rob, thanks!

I was not aware of this ja:loadClass usage. But if the static initializer blocks get executed, I could of course just replace my CustomBuiltinAssembler with a class that registers the required Builtin's in such a initializer block. I would not have to write an Assembler at all for my use case (of loading a custom builtin function). Is that correct?

I'll test this and confirm whether this actually works or not.

Regards, Barry

-----Original Message-----
From: Rob Vesse [mailto:rvesse@dotnetrdf.org] 
Sent: dinsdag 12 december 2017 12:00
To: users@jena.apache.org
Subject: Re: Assembler for GenericRuleEngine Custom Builtin

See the documentation on Other Assembler directives:

http://jena.apache.org/documentation/assembler/assembler-howto.html#other-assembler-directives

Using ja:loadClass to load in a class that sets up any custom assemblers via static initializer blocks in that class should be sufficient and doesn’t require connection to a Fuseki 

Rob

On 12/12/2017, 10:36, "Nouwt, B. (Barry)" <ba...@tno.nl> wrote:

    Thanks for your reply. I have a follow up question.
    
    I've successfully created a CustomBuiltinAssembler that 'opens' the custom builtin's and loads them into the BuiltinRegistry. So, if I use the statement:
    
    Assembler.general.open(truckRoot);
    
    to explicitly open those resources (and load them in the BuiltinRegistry) from the Assembler specs, it works like expected.
    
    However, in Apache Jena Fuseki the custom builtin's do not get loaded from a configuration file. I suspect this happens because Fuseki only tries to open 'services' and everything related to them and does not try to load any dangling resources (like my CustomBuiltin's). Because I rather not extend the existing InfModelAssembler of Apache Jena, I have no way of connect my CustomBuiltin's to the services resource. My current Assembler specs can be found below.
    
    Am I right that my CustomBuiltin's need to be connected to a Fuseki service to get loaded? And is there some way to achieve this without extending some existing Assember?
    
    Kind regards,
    
    Barry Nouwt
    
    
    @prefix : <http://www.example.org/tno#> .
    @prefix fuseki: <http://jena.apache.org/fuseki#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
    @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
    
    tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
    tdb:GraphTDB rdfs:subClassOf ja:Model .
    
    :CustomBuiltin rdfs:subClassOf ja:Object ;
    	ja:assembler "nl.tno.ds.cb.CustomBuiltinAssembler" .
    
    :shipCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.FirstBuiltin" .
    	
    :truckCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.SecondBuiltin" .
    
    :dataset rdf:type ja:RDFDataset ;
    	ja:defaultGraph <#infGraph> .
    
    <#infGraph>  rdf:type ja:InfModel ;
                 ja:reasoner [ ja:rulesFrom <file:src/test/resources/et.rules> ; ] ;
                 ja:content <#test-inf> .
    
    <#test-inf> ja:externalContent <src/test/resources/data.ttl> .
    
    -----Original Message-----
    From: ajs6f [mailto:ajs6f@apache.org] 
    Sent: zaterdag 25 november 2017 15:45
    To: users@jena.apache.org
    Subject: Re: Assembler for GenericRuleEngine Custom Builtin
    
    I'm not too familiar with the rules system, so I may be wrong, but I think the answer is simply no, we don't have that feature right now. It does sound quite useful. If you write this code for yourself please do open a ticket (actually, that would be nice in any event) and send a PR!
    
    For anyone who may be wondering about programmatic use of custom built-ins, there is a test case here:
    
    org.apache.jena.reasoner.rulesys.test.TestGenericRuleReasonerConfig.testRuleLoadingWithOverridenBuiltins()
    
    
    ajs6f
    
    > On Nov 24, 2017, at 11:26 AM, Nouwt, B. (Barry) <ba...@tno.nl> wrote:
    > 
    > Hi all,
    > 
    > Does anyone know whether there is an Assember to load a custom Builtin (for usage in rules for the GenericRuleEngine) using a Fuseki configuration .ttl file. I assume not, because I cannot find it in: https://github.com/apache/jena/tree/master/jena-core/src/main/java/org/apache/jena/assembler/assemblers
    > 
    > I do see a RuleSetAssembler and a ReasonerFactory, but they do not seem to have a Builtin load option. Also, via code I use the BuiltinRegistry class, so it would probably be not too difficult to add this feature myself.
    > 
    > Any pointers?
    > 
    > Regards, Barry
    > 
    > 
    > 
    > 
    > This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.
    
    





Re: Assembler for GenericRuleEngine Custom Builtin

Posted by Rob Vesse <rv...@dotnetrdf.org>.
See the documentation on Other Assembler directives:

http://jena.apache.org/documentation/assembler/assembler-howto.html#other-assembler-directives

Using ja:loadClass to load in a class that sets up any custom assemblers via static initializer blocks in that class should be sufficient and doesn’t require connection to a Fuseki 

Rob

On 12/12/2017, 10:36, "Nouwt, B. (Barry)" <ba...@tno.nl> wrote:

    Thanks for your reply. I have a follow up question.
    
    I've successfully created a CustomBuiltinAssembler that 'opens' the custom builtin's and loads them into the BuiltinRegistry. So, if I use the statement:
    
    Assembler.general.open(truckRoot);
    
    to explicitly open those resources (and load them in the BuiltinRegistry) from the Assembler specs, it works like expected.
    
    However, in Apache Jena Fuseki the custom builtin's do not get loaded from a configuration file. I suspect this happens because Fuseki only tries to open 'services' and everything related to them and does not try to load any dangling resources (like my CustomBuiltin's). Because I rather not extend the existing InfModelAssembler of Apache Jena, I have no way of connect my CustomBuiltin's to the services resource. My current Assembler specs can be found below.
    
    Am I right that my CustomBuiltin's need to be connected to a Fuseki service to get loaded? And is there some way to achieve this without extending some existing Assember?
    
    Kind regards,
    
    Barry Nouwt
    
    
    @prefix : <http://www.example.org/tno#> .
    @prefix fuseki: <http://jena.apache.org/fuseki#> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
    @prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
    
    tdb:DatasetTDB rdfs:subClassOf ja:RDFDataset .
    tdb:GraphTDB rdfs:subClassOf ja:Model .
    
    :CustomBuiltin rdfs:subClassOf ja:Object ;
    	ja:assembler "nl.tno.ds.cb.CustomBuiltinAssembler" .
    
    :shipCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.FirstBuiltin" .
    	
    :truckCustom a :CustomBuiltin ;
    	:hasClass "nl.tno.ds.cb.SecondBuiltin" .
    
    :dataset rdf:type ja:RDFDataset ;
    	ja:defaultGraph <#infGraph> .
    
    <#infGraph>  rdf:type ja:InfModel ;
                 ja:reasoner [ ja:rulesFrom <file:src/test/resources/et.rules> ; ] ;
                 ja:content <#test-inf> .
    
    <#test-inf> ja:externalContent <src/test/resources/data.ttl> .
    
    -----Original Message-----
    From: ajs6f [mailto:ajs6f@apache.org] 
    Sent: zaterdag 25 november 2017 15:45
    To: users@jena.apache.org
    Subject: Re: Assembler for GenericRuleEngine Custom Builtin
    
    I'm not too familiar with the rules system, so I may be wrong, but I think the answer is simply no, we don't have that feature right now. It does sound quite useful. If you write this code for yourself please do open a ticket (actually, that would be nice in any event) and send a PR!
    
    For anyone who may be wondering about programmatic use of custom built-ins, there is a test case here:
    
    org.apache.jena.reasoner.rulesys.test.TestGenericRuleReasonerConfig.testRuleLoadingWithOverridenBuiltins()
    
    
    ajs6f
    
    > On Nov 24, 2017, at 11:26 AM, Nouwt, B. (Barry) <ba...@tno.nl> wrote:
    > 
    > Hi all,
    > 
    > Does anyone know whether there is an Assember to load a custom Builtin (for usage in rules for the GenericRuleEngine) using a Fuseki configuration .ttl file. I assume not, because I cannot find it in: https://github.com/apache/jena/tree/master/jena-core/src/main/java/org/apache/jena/assembler/assemblers
    > 
    > I do see a RuleSetAssembler and a ReasonerFactory, but they do not seem to have a Builtin load option. Also, via code I use the BuiltinRegistry class, so it would probably be not too difficult to add this feature myself.
    > 
    > Any pointers?
    > 
    > Regards, Barry
    > 
    > 
    > 
    > 
    > This message may contain information that is not intended for you. If you are not the addressee or if this message was sent to you by mistake, you are requested to inform the sender and delete the message. TNO accepts no liability for the content of this e-mail, for the manner in which you use it and for damage of any kind resulting from the risks inherent to the electronic transmission of messages.