You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Florian Kleedorfer <fl...@austria.fm> on 2020/11/24 12:41:05 UTC

Access to private fields in SHACL Constraints?

Hi,

I am developing a program based on Jena/SHACL and I think I need a small 
adaptation.

What I want to achieve:
- analyze shacl shapes and generate java class files
- read shapes and data and instantiate objects representing the data

While doing that, I realized that the properties of the 
Constraint-implementations in `org.apache.jena.shacl.engine.constraint` 
are not accessible. E.g. in `NodeKindConstraint`, the field `kind` is 
private, and it has no getter method. In the current SHACL use case of 
jena, the Constraints don't need to be accessible (they just check their 
respective conditions). In my use case, I'll need to access that 
information for determining property types etc. (e.g by analyzing 
sh:nodeKind) and therefore need to access the constraints.

Would it be possible to make the Constraints' properties accessible with 
public getters?

I could prepare a PR if that's ok.

Best regards,
Florian

Re: Access to private fields in SHACL Constraints?

Posted by Andy Seaborne <an...@apache.org>.
No problem .. and the compact writer has magic access so there can be 
missing accessors. (I though it was the other, visitor-like, design.)

     Andy

On 24/11/2020 18:32, Florian Kleedorfer wrote:
> 
> Ok, will do. Sorry the example I gave was outdated, I realized that when 
> I checked out the latest sources (I was on 3.16.0). There are still some 
> accessors to add.
> 
> Best,
> Florian
> 
> Am 2020-11-24 17:34, schrieb Andy Seaborne:
> 
>> Yes, please put in a PR for anything missing.
>>
>> There is compact syntax writer in 3.17.0 and it needs access to
>> constraints details so it can print so most should be here.
>>
>> I do see in the current codebase: NodeKindConstraint.getKind()
>>
>>     Andy
>>
>> https://github.com/apache/jena/blob/master/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/NodeKindConstraint.java#L58 
>>
>>
>>
>> On 24/11/2020 12:41, Florian Kleedorfer wrote:
>>> Hi,
>>>
>>> I am developing a program based on Jena/SHACL and I think I need a 
>>> small adaptation.
>>>
>>> What I want to achieve:
>>> - analyze shacl shapes and generate java class files
>>> - read shapes and data and instantiate objects representing the data
>>>
>>> While doing that, I realized that the properties of the 
>>> Constraint-implementations in 
>>> `org.apache.jena.shacl.engine.constraint` are not accessible. E.g. in 
>>> `NodeKindConstraint`, the field `kind` is private, and it has no 
>>> getter method. In the current SHACL use case of jena, the Constraints 
>>> don't need to be accessible (they just check their respective 
>>> conditions). In my use case, I'll need to access that information for 
>>> determining property types etc. (e.g by analyzing sh:nodeKind) and 
>>> therefore need to access the constraints.
>>>
>>> Would it be possible to make the Constraints' properties accessible 
>>> with public getters?
>>>
>>> I could prepare a PR if that's ok.
>>>
>>> Best regards,
>>> Florian

Re: Access to private fields in SHACL Constraints?

Posted by Florian Kleedorfer <fl...@austria.fm>.
Ok, will do. Sorry the example I gave was outdated, I realized that when 
I checked out the latest sources (I was on 3.16.0). There are still some 
accessors to add.

Best,
Florian

Am 2020-11-24 17:34, schrieb Andy Seaborne:

> Yes, please put in a PR for anything missing.
> 
> There is compact syntax writer in 3.17.0 and it needs access to
> constraints details so it can print so most should be here.
> 
> I do see in the current codebase: NodeKindConstraint.getKind()
> 
>     Andy
> 
> https://github.com/apache/jena/blob/master/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/NodeKindConstraint.java#L58
> 
> 
> On 24/11/2020 12:41, Florian Kleedorfer wrote:
>> Hi,
>> 
>> I am developing a program based on Jena/SHACL and I think I need a 
>> small adaptation.
>> 
>> What I want to achieve:
>> - analyze shacl shapes and generate java class files
>> - read shapes and data and instantiate objects representing the data
>> 
>> While doing that, I realized that the properties of the 
>> Constraint-implementations in 
>> `org.apache.jena.shacl.engine.constraint` are not accessible. E.g. in 
>> `NodeKindConstraint`, the field `kind` is private, and it has no 
>> getter method. In the current SHACL use case of jena, the Constraints 
>> don't need to be accessible (they just check their respective 
>> conditions). In my use case, I'll need to access that information for 
>> determining property types etc. (e.g by analyzing sh:nodeKind) and 
>> therefore need to access the constraints.
>> 
>> Would it be possible to make the Constraints' properties accessible 
>> with public getters?
>> 
>> I could prepare a PR if that's ok.
>> 
>> Best regards,
>> Florian

Re: Access to private fields in SHACL Constraints?

Posted by Andy Seaborne <an...@apache.org>.
Yes, please put in a PR for anything missing.

There is compact syntax writer in 3.17.0 and it needs access to 
constraints details so it can print so most should be here.

I do see in the current codebase: NodeKindConstraint.getKind()

     Andy

https://github.com/apache/jena/blob/master/jena-shacl/src/main/java/org/apache/jena/shacl/engine/constraint/NodeKindConstraint.java#L58


On 24/11/2020 12:41, Florian Kleedorfer wrote:
> Hi,
> 
> I am developing a program based on Jena/SHACL and I think I need a small 
> adaptation.
> 
> What I want to achieve:
> - analyze shacl shapes and generate java class files
> - read shapes and data and instantiate objects representing the data
> 
> While doing that, I realized that the properties of the 
> Constraint-implementations in `org.apache.jena.shacl.engine.constraint` 
> are not accessible. E.g. in `NodeKindConstraint`, the field `kind` is 
> private, and it has no getter method. In the current SHACL use case of 
> jena, the Constraints don't need to be accessible (they just check their 
> respective conditions). In my use case, I'll need to access that 
> information for determining property types etc. (e.g by analyzing 
> sh:nodeKind) and therefore need to access the constraints.
> 
> Would it be possible to make the Constraints' properties accessible with 
> public getters?
> 
> I could prepare a PR if that's ok.
> 
> Best regards,
> Florian