Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous RDFBeans by menas of interfaces #33

Open
twallmey opened this issue Mar 19, 2019 · 3 comments
Open

Anonymous RDFBeans by menas of interfaces #33

twallmey opened this issue Mar 19, 2019 · 3 comments

Comments

@twallmey
Copy link

twallmey commented Mar 19, 2019

Hi all,

I'm using RDFBeans (annotated interfaces) with success and would like to make use of anonymous/blank nodes now. I've followed every step from the documentation, but everytime I'm trying to assign an anonymous bean to another bean (calling setter of property) it throws an exception saying, that @RDFSubject annotation is missing. My code is:

KT aBean = this.manager.create(ID_UNKNOWN, beanType);
aBean.setId(null); //reset to make anonymous - id not set
bBean.setProp(aBean); //throws exception

I've tried a second way to solve my problem. This time I've explictely created an anonymous node and tried to create the bean afterwards:

Resource r = SimpleValueFactory.getInstance().createBNode();
Context ctx = this.manager.create(r, Context.class);

Unfortunately, this appraoch resulted in a different exception:
java.lang.ClassCastException: org.eclipse.rdf4j.model.impl.SimpleBNode cannot be cast to org.eclipse.rdf4j.model.IRI

As none of my solutions work I'm guessing that anonymous RDFBeans only work for classes and not for interfaces. Is that right? Or could someone tell me what I am doing wrong and point me into the correct direction?

Thanks in advance,

Thorben

@cyberborean
Copy link
Owner

Hi,

Yes, using RDFBean classes, it is possible to instantiate a bean without @RDFSubject value and assign it to properties of other beans. The anonymous bean will be represented as a BNode in the RDF model.

Instantiating a proxy object for a RDFBean interface requires an explicit resource identifier, so it doesn't work this way.

Perhaps, it makes sense to change the type of the create() argument from Resource to IRI, to make this explicit and avoid confusion.

@twallmey
Copy link
Author

Hi,

thanks a lot for your response!

Wouldn't it make sense to fix this "problem" instead of changing the method signature? If creating an anonymous bean from class already works it shouldn't be a big issue to make this working for interfaces as well: an anonymous RDFBean (mapped by class) should already be assigned a generated ID that could be assigend to a RDFBean (mapped by interface) as well. From my point of view this should already solve the problem, shouldn't it?

@twallmey
Copy link
Author

Are there any news about this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants