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

MessageContentSerializer.deserialize does not find root resouce #498

Open
Alfiva opened this issue Oct 17, 2018 · 0 comments
Open

MessageContentSerializer.deserialize does not find root resouce #498

Alfiva opened this issue Oct 17, 2018 · 0 comments

Comments

@Alfiva
Copy link
Member

Alfiva commented Oct 17, 2018

I assumed MessageContentSerializer.deserialize would parse whatever turtle content and return the "root-most" resource (the subject that is not object to other statements), assuming there is only one. But that is not the case. Consider the following example (prefixes ommited for clarity):

<urn:org.universAAL.middleware.context.rdf:ContextEvent#_:0123456789abcdef:0001>
  a :ContextEvent ;
  :hasTimestamp "1521046800000"^^xsd:long ;
  rdf:subject ex:mydevice ;
  rdf:predicate dev:hasValue ;
  rdf:object dev:Activated .
ex:mydevice a dev:SwitchActuator .
dev:Activated a dev:StatusValue .

This is properly deserialized as a ContextEvent java object. However only chaning the first line to be the last makes it fail:

dev:Activated a dev:StatusValue .
<urn:org.universAAL.middleware.context.rdf:ContextEvent#_:0123456789abcdef:0001>
  a :ContextEvent ;
  :hasTimestamp "1521046800000"^^xsd:long ;
  rdf:subject ex:mydevice ;
  rdf:predicate dev:hasValue ;
  rdf:object dev:Activated .
ex:mydevice a dev:SwitchActuator .

This is deserialized as the Activated java object, despite being obviously not the root of the graph. I tracked this issue to TurtleParser.parseTriples in mw.data.serialization.turtle.core, where it clearly states:

// we found a new root node
// this is not generally true, since this subject could also appear
// later as rdf:object

But it does not do anything to modify that if it indeed appears later. Then in TurtleParser.finalizeAndGetRoot it simply returns the first root found, if no root is explicitly requested.

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

1 participant