Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Finding an CDOObject based on its intrinsic ID
Finding an CDOObject based on its intrinsic ID [message #423169] Wed, 24 September 2008 10:04 Go to next message
Jasper is currently offline JasperFriend
Messages: 84
Registered: July 2009
Member
Using an XMIResource, I can look up an object based on its intrinsic ID,
by calling Resource.getEObject(String uriFragment).

If I try the same with a CDOResourceImpl, that fails because, as I've
discovered, CDO uses CDOID's to encode the object's CDOID.Type...

Does this mean that CDO does not honor the intrinsic ID's declared in
the model? Or if it does, how can one find an EObject based on the
intrinsic ID?

Thanks,
Jasper.
Re: Finding an CDOObject based on its intrinsic ID [message #423170 is a reply to message #423169] Wed, 24 September 2008 10:32 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Jasper schrieb:
> Using an XMIResource, I can look up an object based on its intrinsic
> ID, by calling Resource.getEObject(String uriFragment).
>
> If I try the same with a CDOResourceImpl, that fails because, as I've
> discovered, CDO uses CDOID's to encode the object's CDOID.Type...
Yes, internally CDO always uses CDOIDs to identify objects. They are
guaranteed to be unique ina whole repository (as opposed to only a
resource). You can think of it as an opaque token that is valid only in
the associated session (you even can't compare them between sessions).
You can use it in any view of the session: getObject(CDOID).

>
> Does this mean that CDO does not honor the intrinsic ID's declared in
> the model? Or if it does, how can one find an EObject based on the
> intrinsic ID?
I don't think that CDOResource honors *intrinsic* IDs. But if the CDO
native apporach, i.e. CDOView.getObject(CDOID), doesn't suit your needs
there should now (HEAD) be the possibility to call
CDOResource.getURIFragment(EObject) to receive a fragment that you can
use with CDOResource.getEObject(String). The fragment will possibly not
contain the value of the ID attribute of your model but rather an
encoded CDOID.

Maybe the URI gurus want to add something?

Cheers
/Eike


Re: Finding an CDOObject based on its intrinsic ID [message #423176 is a reply to message #423170] Wed, 24 September 2008 11:42 Go to previous messageGo to next message
Jasper is currently offline JasperFriend
Messages: 84
Registered: July 2009
Member
Eike,

CDOResource.getURIFragment(EObject) saves the day :-) I guess I should
have used this all along (even when using an XMIResource), but I was
manually retrieving the intrinsic ID and using just that...

As for the CDOID's, I understand the idea, but as much as possible I
want my front-end to be able to work with both CDOResources and
XMIResources.

Thanks,
Jasper.


Eike Stepper wrote:
> Jasper schrieb:
>> Using an XMIResource, I can look up an object based on its intrinsic
>> ID, by calling Resource.getEObject(String uriFragment).
>>
>> If I try the same with a CDOResourceImpl, that fails because, as I've
>> discovered, CDO uses CDOID's to encode the object's CDOID.Type...
> Yes, internally CDO always uses CDOIDs to identify objects. They are
> guaranteed to be unique ina whole repository (as opposed to only a
> resource). You can think of it as an opaque token that is valid only in
> the associated session (you even can't compare them between sessions).
> You can use it in any view of the session: getObject(CDOID).
>
>>
>> Does this mean that CDO does not honor the intrinsic ID's declared in
>> the model? Or if it does, how can one find an EObject based on the
>> intrinsic ID?
> I don't think that CDOResource honors *intrinsic* IDs. But if the CDO
> native apporach, i.e. CDOView.getObject(CDOID), doesn't suit your needs
> there should now (HEAD) be the possibility to call
> CDOResource.getURIFragment(EObject) to receive a fragment that you can
> use with CDOResource.getEObject(String). The fragment will possibly not
> contain the value of the ID attribute of your model but rather an
> encoded CDOID.
>
> Maybe the URI gurus want to add something?
>
> Cheers
> /Eike
>
Re: Finding an CDOObject based on its intrinsic ID [message #423178 is a reply to message #423176] Wed, 24 September 2008 11:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Jasper,

Yes, getURIFragment is the most general way of obtaining the string that
the resource itself decides is the one that it wants to use for
identifying the object. EcoreUtil.getID can be used to determine the
intrinsic ID of an EObject, if it has one, but their's no guarantee that
any particular resource implementation will necessarily use it.


Jasper wrote:
> Eike,
>
> CDOResource.getURIFragment(EObject) saves the day :-) I guess I should
> have used this all along (even when using an XMIResource), but I was
> manually retrieving the intrinsic ID and using just that...
>
> As for the CDOID's, I understand the idea, but as much as possible I
> want my front-end to be able to work with both CDOResources and
> XMIResources.
>
> Thanks,
> Jasper.
>
>
> Eike Stepper wrote:
>> Jasper schrieb:
>>> Using an XMIResource, I can look up an object based on its intrinsic
>>> ID, by calling Resource.getEObject(String uriFragment).
>>>
>>> If I try the same with a CDOResourceImpl, that fails because, as
>>> I've discovered, CDO uses CDOID's to encode the object's CDOID.Type...
>> Yes, internally CDO always uses CDOIDs to identify objects. They are
>> guaranteed to be unique ina whole repository (as opposed to only a
>> resource). You can think of it as an opaque token that is valid only
>> in the associated session (you even can't compare them between
>> sessions). You can use it in any view of the session: getObject(CDOID).
>>
>>>
>>> Does this mean that CDO does not honor the intrinsic ID's declared
>>> in the model? Or if it does, how can one find an EObject based on
>>> the intrinsic ID?
>> I don't think that CDOResource honors *intrinsic* IDs. But if the CDO
>> native apporach, i.e. CDOView.getObject(CDOID), doesn't suit your
>> needs there should now (HEAD) be the possibility to call
>> CDOResource.getURIFragment(EObject) to receive a fragment that you
>> can use with CDOResource.getEObject(String). The fragment will
>> possibly not contain the value of the ID attribute of your model but
>> rather an encoded CDOID.
>>
>> Maybe the URI gurus want to add something?
>>
>> Cheers
>> /Eike
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:"Initialize by loading" & DocumentRoot
Next Topic:Dynamic EMF
Goto Forum:
  


Current Time: Tue Apr 16 19:27:33 GMT 2024

Powered by FUDForum. Page generated in 0.44285 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top