Pinto and setting IRI of subject from Model

2 views
Skip to first unread message

jan.bjo...@gmail.com

unread,
Nov 21, 2016, 4:31:59 AM11/21/16
to Stardog
Hey.

I am using Pinto (https://github.com/stardog-union/pinto) and the Identifable interface for controlling the id when mapping from POJO to Model.

public class VirksomhetId implements Identifiable {

    private Resource id;
   
    ( ... )
  
    @Override
    public Resource id() {
        return id;
    }

    @Override
    public void id(Resource id) {
        this.id = id;
    }
   
    public void setId(String id) {
        this.id = SimpleValueFactory.getInstance().createIRI(id);
    }
}

Is there any way of reading the IRI of the subject into Id when mapping back from Model to POJO?

Michael Grove

unread,
Nov 21, 2016, 7:17:18 AM11/21/16
to stardog
I'm not sure I follow. The id should be set when creating the bean from the RDF. Is that not the behavior you're seeing?

Cheers,

Mike
 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+unsubscribe@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

jan.bjo...@gmail.com

unread,
Nov 22, 2016, 3:58:34 AM11/22/16
to Stardog


mandag 21. november 2016 13.17.18 UTC+1 skrev Michael Grove følgende:
On Mon, Nov 21, 2016 at 4:31 AM, <jan.bjo...@gmail.com> wrote:
Hey.

I am using Pinto (https://github.com/stardog-union/pinto) and the Identifable interface for controlling the id when mapping from POJO to Model.

public class VirksomhetId implements Identifiable {

    private Resource id;
   
    ( ... )
  
    @Override
    public Resource id() {
        return id;
    }

    @Override
    public void id(Resource id) {
        this.id = id;
    }
   
    public void setId(String id) {
        this.id = SimpleValueFactory.getInstance().createIRI(id);
    }
}

Is there any way of reading the IRI of the subject into Id when mapping back from Model to POJO?

I'm not sure I follow. The id should be set when creating the bean from the RDF. Is that not the behavior you're seeing?

Cheers,

Mike
 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to


No. The id is not set in my case.
When doing:
EnhetId enhetId = rdfMapper.readValue(model, EnhetId.class, subject);

results in:

enhetId.id() is null.

What I am doing is manually setting the id because I already know the IRI as subject, but this becomes harder when nesting Resources.

Am I missing an annotation or something?

When creating the POJO the id is set to IRI from a namespace and UUID, so Pinto is not generating ids for me.

Michael Grove

unread,
Nov 22, 2016, 8:24:50 AM11/22/16
to stardog
Thanks for mentioning this. Looks like Identifiable's are not being correctly roundtripped when the IRI is created. I've fixed this and pushed the update to develop.

Cheers,

Mike
 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages