Incomplete/Incorrect handling of @RDFContainer properties
twallmey opened this issue · 2 comments
Hi all!
I've encountered a problem while using properties that are annotated by @RDFContainer. I've got a simple property of Java type collection that is annotated like this:
@RDFContainer(ContainerType.SEQ)
@RDF("myns:data/modification")
public Collection<DataModification> getModification();
This works perfectly well when persisting entries for the first time. Nevertheless there seems to be a bug when updating existing entries. In this case the old list entries do not get deleted completely and are kept within the database although they have no more links:
<http://test.de/s/2667379723> http://test.de/meta/property/data/modification> _:node1dl4430n8x1
_:node1dl4430n8x1 <rdf:_1> myValue
_:node1dl4430n8x1 <rdf:type> <rdf:Seq>
Regarding the abstract example supplied only the first statement would get deleted whereas the two last onces would remain. I assume the problem has to be fixed within the method setValue() of class RDFBeanDelegator. Within line 355 and 358 it should be checked if the object of deleted statement is a list. In this case the list values should be deleted additionaly. From my point of view should the deletion even work recursively because an entry of list could be a list itsself.
It would be great if this problem could be fixed in near feature and be merged into the current development branch that does already contain the subgraph/context enhancement.
Best,
Thorben
Unfortunately problem still remains... Any news about this?
Hi!
I was forced to solve the problem on my own because it occurred throughout our whole project. I've changed the following lines of code within the class RDFBeanDelegator:
boolean newTxn = !conn.isActive();
if (newTxn) {
conn.begin();
}
try {
// Clear old values
//BEGIN: code required for deleting list values
if(value instanceof Collection && p.getContainerType() != ContainerType.NONE) {
List<Statement> listStatements = Iterations.asList(conn.getStatements(subject, p.getUri(), null, (IRI)context));
if(listStatements.size() > 0) {
//list entries available - object of statements represents bNode of list, so get any
Resource listBNode = (Resource) listStatements.get(0).getObject();
conn.remove(listBNode, null, null, (IRI)context);
}
}
//END: code required for deleting list values
if (p.isInversionOfProperty()) {
conn.remove((Resource)null, p.getUri(), subject, (IRI)context);
}else {
conn.remove(subject, p.getUri(), null, (IRI)context);
}
Although I've carefully analyzed the code and it is working for me I would really looking forward to having you experts a final view on my solution and supplying an official bugfix. In case you have any questions pls. just get in contact with me!
Best,
Thorben