Creating ID from RDF

4 views
Skip to first unread message

uoccou

unread,
Apr 28, 2010, 2:39:57 PM4/28/10
to jenabean-dev
Hi,

Im wondering why in the TypeWrapper.toBean methods you call last(uri)
when a Bean has a constructor with a single String. My beans have such
a constructor and go to lengths to generate an id (a local defined ns
based uri) and when I read back these objects with an RDF2Bean reader
using the same generated id, the call to last blows it away and I end
up with unequal objects.

Is there a way around this ? Can the constructor be left to do its
work with the id that was found in the repository ?

--
You received this message because you are subscribed to the Google Groups "jenabean-dev" group.
To post to this group, send email to jenabe...@googlegroups.com.
To unsubscribe from this group, send email to jenabean-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jenabean-dev?hl=en.

uoccou

unread,
Apr 28, 2010, 3:20:45 PM4/28/10
to jenabean-dev
Or should I not be attempting to control the ID to that extend and let
jenabean do it ? Im not coding at the moment, but Im guessing that
jenabean will create the URI for the rdf from the namespace and
classname, then tack on the id property, so if Im manually creating an
ID directly its interfering with that mechanism - that is to say I
should create the unique part of the ID only, and let jenabean create
the leading part of the URI ?

uoc

unread,
Apr 29, 2010, 3:05:09 AM4/29/10
to jenabe...@googlegroups.com, uoccou
On 28/04/2010 20:20, uoccou wrote:
> Or should I not be attempting to control the ID to that extend and let
> jenabean do it ? Im not coding at the moment, but Im guessing that
> jenabean will create the URI for the rdf from the namespace and
> classname, then tack on the id property, so if Im manually creating an
> ID directly its interfering with that mechanism - that is to say I
> should create the unique part of the ID only, and let jenabean create
> the leading part of the URI ?
>
>
>
> On Apr 28, 7:39 pm, uoccou<uoc...@googlemail.com> wrote:
>
>> Hi,
>>
>> Im wondering why in the TypeWrapper.toBean methods you call last(uri)
>> when a Bean has a constructor with a single String. My beans have such
>> a constructor and go to lengths to generate an id (a local defined ns
>> based uri) and when I read back these objects with an RDF2Bean reader
>> using the same generated id, the call to last blows it away and I end
>> up with unequal objects.
>>
>> Is there a way around this ? Can the constructor be left to do its
>> work with the id that was found in the repository ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups "jenabean-dev" group.
>> To post to this group, send email to jenabe...@googlegroups.com.
>> To unsubscribe from this group, send email to jenabean-dev...@googlegroups.com.
>> For more options, visit this group athttp://groups.google.com/group/jenabean-dev?hl=en.
>>
>
And another thing :-) and with reference to
http://groups.google.com/group/jenabean-dev/t/60ff001299b72c77?hl=en, it
seems to me that a mechanism to allow an independent ID generation
mechanism is required - in the Linked Data Web, its often a requirement
that a permanent url (eg http://purl.org/mydomain/mydataset) is required
so that data can be retrieved consistently regardless of a sometimes
changing location. How about if @TypeName can be expanded to include a
static override or an indication of a class that should be used to
generate the name

@${http://purl.org/mydomain/mydataset}${RdfType}/${id}(as per Brandon)
@${com.example.idgenerator}${RdfType}/${id}

uoccou

unread,
Apr 29, 2010, 8:36:02 AM4/29/10
to jenabean-dev

But if your ID field is a URI, this is bust - then id wont be
generated by jenabean, but will be subject to the last() call on the
way out....


On Apr 29, 8:05 am, uoc <uoc...@gmail.com> wrote:
> On 28/04/2010 20:20, uoccou wrote:
>
> > Or should I not be attempting to control the ID to that extend and let
> > jenabean do it ? Im not coding at the moment, but Im guessing that
> > jenabean will create the URI for the rdf from the namespace and
> > classname, then tack on the id property, so if Im manually creating an
> > ID directly its interfering with that mechanism - that is to say I
> > should create the unique part of the ID only, and let jenabean create
> > the leading part of the URI ?
>
> > On Apr 28, 7:39 pm, uoccou<uoc...@googlemail.com>  wrote:
>
> >> Hi,
>
> >> Im wondering why in the TypeWrapper.toBean methods you call last(uri)
> >> when a Bean has a constructor with a single String. My beans have such
> >> a constructor and go to lengths to generate an id (a local defined ns
> >> based uri) and when I read back these objects with an RDF2Bean reader
> >> using the same generated id, the call to last blows it away and I end
> >> up with unequal objects.
>
> >> Is there a way around this ? Can the constructor be left to do its
> >> work with the id that was found in the repository ?
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "jenabean-dev" group.
> >> To post to this group, send email to jenabe...@googlegroups.com.
> >> To unsubscribe from this group, send email to jenabean-dev...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/jenabean-dev?hl=en.
>
> And another thing :-) and with reference tohttp://groups.google.com/group/jenabean-dev/t/60ff001299b72c77?hl=en, it
> seems to me that a mechanism to allow an independent ID generation
> mechanism is required - in the Linked Data Web, its often a requirement
> that a permanent url (eghttp://purl.org/mydomain/mydataset) is required

uoc

unread,
Apr 29, 2010, 12:11:16 PM4/29/10
to jenabe...@googlegroups.com, uoccou
...So dont have a constructor that takes a single string: have a
constructor that takes a URI and generate the URI yourself.
Then the convenience of having the Object encapsulate its ID generation
and exception handing is somewhat lost - perhaps if the TypeWrapper
took into account if the id field was a URI and had alternative
behaviour in this case then it wouldnt be necessary. I do so something
like this in the IdFieldWrapper so maybe Im missing something ?

Taylor Cowan

unread,
Apr 29, 2010, 10:54:27 PM4/29/10
to jenabe...@googlegroups.com
So many thoughts have gone by I'm still trying to catch up ;-). For
the String constructor, the idea behind that was so that you'd not
have to create a URI, it's create for you, the id is the last segment
in the URI, so:

http://mydomain/MyClass/1234

new MyClass("1234");

If you want to be in control of the bean's URI, just have a uri field:

@Id
private URI myid;

That's the most explicit way, and jenabean handles populating that
field from the model for you.

uoccou

unread,
Apr 30, 2010, 7:56:30 AM4/30/10
to jenabe...@googlegroups.com, Taylor Cowan
But the fieldWrapper, when unmarshalling from the RDF store, looks for a
single string constructor even if its a URI right ?

uoccou

unread,
May 21, 2010, 9:00:10 AM5/21/10
to jenabean-dev
Just to say I got around this issue where the base class I extend with
an id that is a URI, I now have an additional constructor with string
and boolean to signal whether the id should be generated or not. The
single string constructor calls this with a false arg so that when
Jenabean unmarshalls the rdf it doesnt generate the ID again.
But when I first create the bean tho, I need to make sure I call the 2
arg constructor so that I can generate the ID - this is mostly because
I want to take the URI thats passed in and modify it to create a new
URI, and I need to make sure that the class itself rather then the
caller generates the ID.


On Apr 28, 7:39 pm, uoccou <uoc...@googlemail.com> wrote:
Reply all
Reply to author
Forward
0 new messages