Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Teneo : persistence of objects URI
Teneo : persistence of objects URI [message #58396] |
Fri, 20 October 2006 09:38 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: mat.loo.gmail.com
Hi
Are we ensured that the URI of an object will remain the same during all
its life cycle ?
I mean, when I create a Marker on an EMF Object (that I identify with its
URI, as EMF does in general), am I sure this URI will remain the same the
next time I launch Eclipse ? When Teneo/Jpox builds EObjects while reading
database, will all URIs be unique for each object and the same as the last
time Teneo/Jpox read the database ?
Thx
|
|
|
Re: Teneo : persistence of objects URI [message #58435 is a reply to message #58396] |
Fri, 20 October 2006 10:23 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Mat,
URIs are how EMF references other objects in general so this is a more
general question. The URI consists of the <base>#<fragment> where the
base identifies the resource containing the object and the fragment
identifies the object within that resource. If you actually moved the
object to a new resource, then clearly the base could change. The
fragment might well be a fragment path, so if the object moved within
the tree structure of the resource, then that path could change. If the
fragment is just an ID/UUID, then it won't change no matter how the
object is moved around within its resource. The URI should generally
not change arbitrarily unless you move or change the object. I assume
this is the case for how Teneo uses URIs as well...
Mat Lo wrote:
> Hi
>
> Are we ensured that the URI of an object will remain the same during
> all its life cycle ? I mean, when I create a Marker on an EMF Object
> (that I identify with its URI, as EMF does in general), am I sure this
> URI will remain the same the next time I launch Eclipse ? When
> Teneo/Jpox builds EObjects while reading database, will all URIs be
> unique for each object and the same as the last time Teneo/Jpox read
> the database ?
>
> Thx
>
|
|
|
Re: Teneo : persistence of objects URI [message #58449 is a reply to message #58435] |
Fri, 20 October 2006 10:50 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Mat,
The relational database does not have a notion of resources. The way you read the objects in the
resource determines there ordering and therefore the uri, if the uri is based on position.
So it is a safer approach to use the concept of an EMF id. You can try to map the emf id notion to
the same efeature as the database id. However, afaik (please correct me Ed if I am wrong) an EMF id
is always a string while the database id can be something else (auto-increment long or something).
This can be workarounded pretty easily by having a separate EMF id and database id efeature and
keeping the EMF id in sync with the database id.
gr. Martin
Ed Merks wrote:
> Mat,
>
> URIs are how EMF references other objects in general so this is a more
> general question. The URI consists of the <base>#<fragment> where the
> base identifies the resource containing the object and the fragment
> identifies the object within that resource. If you actually moved the
> object to a new resource, then clearly the base could change. The
> fragment might well be a fragment path, so if the object moved within
> the tree structure of the resource, then that path could change. If the
> fragment is just an ID/UUID, then it won't change no matter how the
> object is moved around within its resource. The URI should generally
> not change arbitrarily unless you move or change the object. I assume
> this is the case for how Teneo uses URIs as well...
>
>
> Mat Lo wrote:
>> Hi
>>
>> Are we ensured that the URI of an object will remain the same during
>> all its life cycle ? I mean, when I create a Marker on an EMF Object
>> (that I identify with its URI, as EMF does in general), am I sure this
>> URI will remain the same the next time I launch Eclipse ? When
>> Teneo/Jpox builds EObjects while reading database, will all URIs be
>> unique for each object and the same as the last time Teneo/Jpox read
>> the database ?
>>
>> Thx
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Teneo : persistence of objects URI [message #58460 is a reply to message #58449] |
Fri, 20 October 2006 11:07 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------000800040507010000000902
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Martin,
EMF doesn't force the ID to be a string. As you can see in these
EcoreUtil methods, it will convert to and from a string representation
as necessary.
/**
* Returns the value of the object's ID attribute as a String.
* If the object has no ID attribute or the ID attribute is not
set, it returns <code>null</code>.
* @param eObject the object in question.
* @return the value of the object's ID attribute as a String.
* @see org.eclipse.emf.ecore.EAttribute#isID
* @see org.eclipse.emf.ecore.EClass#getEIDAttribute
* @see #setID(EObject, String)
*/
public static String getID(EObject eObject)
{
EClass eClass = eObject.eClass();
EAttribute eIDAttribute = eClass.getEIDAttribute();
return eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ?
null : convertToString(
eIDAttribute.getEAttributeType(),
eObject.eGet(eIDAttribute));
}
/**
* Sets the value of the object's ID attribute according to the
value represented by the String.
* A <code>null</code> ID will unset the attribute rather than
setting it to <code>null</code>.
* @param eObject the object in question.
* @param id the String value of the new ID.
* @return the value of the object's ID attribute as a String.
* @throws IllegalArgumentException if the object has no ID attribute.
* @see #getID(EObject)
* @see org.eclipse.emf.ecore.EAttribute#isID
* @see org.eclipse.emf.ecore.EClass#getEIDAttribute
*/
public static void setID(EObject eObject, String id)
{
EClass eClass = eObject.eClass();
EAttribute eIDAttribute = eClass.getEIDAttribute();
if (eIDAttribute == null)
{
throw new IllegalArgumentException("The object doesn't have an
ID feature.");
}
else if (id == null)
{
eObject.eUnset(eIDAttribute);
}
else
{
eObject.eSet(eIDAttribute,
createFromString(eIDAttribute.getEAttributeType(), id));
}
}
Martin Taal wrote:
> Mat,
> The relational database does not have a notion of resources. The way
> you read the objects in the resource determines there ordering and
> therefore the uri, if the uri is based on position.
> So it is a safer approach to use the concept of an EMF id. You can try
> to map the emf id notion to the same efeature as the database id.
> However, afaik (please correct me Ed if I am wrong) an EMF id is
> always a string while the database id can be something else
> (auto-increment long or something). This can be workarounded pretty
> easily by having a separate EMF id and database id efeature and
> keeping the EMF id in sync with the database id.
>
> gr. Martin
>
> Ed Merks wrote:
>> Mat,
>>
>> URIs are how EMF references other objects in general so this is a
>> more general question. The URI consists of the <base>#<fragment>
>> where the base identifies the resource containing the object and the
>> fragment identifies the object within that resource. If you actually
>> moved the object to a new resource, then clearly the base could
>> change. The fragment might well be a fragment path, so if the object
>> moved within the tree structure of the resource, then that path could
>> change. If the fragment is just an ID/UUID, then it won't change no
>> matter how the object is moved around within its resource. The URI
>> should generally not change arbitrarily unless you move or change the
>> object. I assume this is the case for how Teneo uses URIs as well...
>>
>>
>> Mat Lo wrote:
>>> Hi
>>>
>>> Are we ensured that the URI of an object will remain the same during
>>> all its life cycle ? I mean, when I create a Marker on an EMF Object
>>> (that I identify with its URI, as EMF does in general), am I sure
>>> this URI will remain the same the next time I launch Eclipse ? When
>>> Teneo/Jpox builds EObjects while reading database, will all URIs be
>>> unique for each object and the same as the last time Teneo/Jpox read
>>> the database ?
>>>
>>> Thx
>>>
>
>
--------------000800040507010000000902
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
EMF doesn't force the ID to be a string.
|
|
|
Re: Teneo : persistence of objects URI [message #59888 is a reply to message #58460] |
Thu, 02 November 2006 17:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: mat.loo.gmail.com
Thanks for your answers.
I want to use Id automatically generated by Teneo (I don't want to add an
attribute to my eObjects and set it to "id").
Is there a way to access the id managed by Teneo (I saw it generates them
when no id is set in ECore model)
Thx again.
|
|
|
Re: Teneo : persistence of objects URI [message #59936 is a reply to message #59888] |
Thu, 02 November 2006 17:09 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: merks.ca.ibm.com
Mat,
I assume that eObject.eResource().getURIFragment(eObject) will return
the ID managed by the resource that contains the eObject.
Mat Lo wrote:
> Thanks for your answers.
>
> I want to use Id automatically generated by Teneo (I don't want to add
> an attribute to my eObjects and set it to "id").
> Is there a way to access the id managed by Teneo (I saw it generates
> them when no id is set in ECore model)
>
> Thx again.
>
|
|
| | | |
Re: Teneo : persistence of objects URI [message #594447 is a reply to message #58396] |
Fri, 20 October 2006 10:23 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Ed Merks![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ed.merks%40gmail.com) Messages: 33197 Registered: July 2009 |
Senior Member |
|
|
Mat,
URIs are how EMF references other objects in general so this is a more
general question. The URI consists of the <base>#<fragment> where the
base identifies the resource containing the object and the fragment
identifies the object within that resource. If you actually moved the
object to a new resource, then clearly the base could change. The
fragment might well be a fragment path, so if the object moved within
the tree structure of the resource, then that path could change. If the
fragment is just an ID/UUID, then it won't change no matter how the
object is moved around within its resource. The URI should generally
not change arbitrarily unless you move or change the object. I assume
this is the case for how Teneo uses URIs as well...
Mat Lo wrote:
> Hi
>
> Are we ensured that the URI of an object will remain the same during
> all its life cycle ? I mean, when I create a Marker on an EMF Object
> (that I identify with its URI, as EMF does in general), am I sure this
> URI will remain the same the next time I launch Eclipse ? When
> Teneo/Jpox builds EObjects while reading database, will all URIs be
> unique for each object and the same as the last time Teneo/Jpox read
> the database ?
>
> Thx
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Teneo : persistence of objects URI [message #594456 is a reply to message #58435] |
Fri, 20 October 2006 10:50 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Martin Taal![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=mtaal%40springsite.com) Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Mat,
The relational database does not have a notion of resources. The way you read the objects in the
resource determines there ordering and therefore the uri, if the uri is based on position.
So it is a safer approach to use the concept of an EMF id. You can try to map the emf id notion to
the same efeature as the database id. However, afaik (please correct me Ed if I am wrong) an EMF id
is always a string while the database id can be something else (auto-increment long or something).
This can be workarounded pretty easily by having a separate EMF id and database id efeature and
keeping the EMF id in sync with the database id.
gr. Martin
Ed Merks wrote:
> Mat,
>
> URIs are how EMF references other objects in general so this is a more
> general question. The URI consists of the <base>#<fragment> where the
> base identifies the resource containing the object and the fragment
> identifies the object within that resource. If you actually moved the
> object to a new resource, then clearly the base could change. The
> fragment might well be a fragment path, so if the object moved within
> the tree structure of the resource, then that path could change. If the
> fragment is just an ID/UUID, then it won't change no matter how the
> object is moved around within its resource. The URI should generally
> not change arbitrarily unless you move or change the object. I assume
> this is the case for how Teneo uses URIs as well...
>
>
> Mat Lo wrote:
>> Hi
>>
>> Are we ensured that the URI of an object will remain the same during
>> all its life cycle ? I mean, when I create a Marker on an EMF Object
>> (that I identify with its URI, as EMF does in general), am I sure this
>> URI will remain the same the next time I launch Eclipse ? When
>> Teneo/Jpox builds EObjects while reading database, will all URIs be
>> unique for each object and the same as the last time Teneo/Jpox read
>> the database ?
>>
>> Thx
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: Teneo : persistence of objects URI [message #594467 is a reply to message #58449] |
Fri, 20 October 2006 11:07 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Ed Merks![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ed.merks%40gmail.com) Messages: 33197 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------000800040507010000000902
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Martin,
EMF doesn't force the ID to be a string. As you can see in these
EcoreUtil methods, it will convert to and from a string representation
as necessary.
/**
* Returns the value of the object's ID attribute as a String.
* If the object has no ID attribute or the ID attribute is not
set, it returns <code>null</code>.
* @param eObject the object in question.
* @return the value of the object's ID attribute as a String.
* @see org.eclipse.emf.ecore.EAttribute#isID
* @see org.eclipse.emf.ecore.EClass#getEIDAttribute
* @see #setID(EObject, String)
*/
public static String getID(EObject eObject)
{
EClass eClass = eObject.eClass();
EAttribute eIDAttribute = eClass.getEIDAttribute();
return eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ?
null : convertToString(
eIDAttribute.getEAttributeType(),
eObject.eGet(eIDAttribute));
}
/**
* Sets the value of the object's ID attribute according to the
value represented by the String.
* A <code>null</code> ID will unset the attribute rather than
setting it to <code>null</code>.
* @param eObject the object in question.
* @param id the String value of the new ID.
* @return the value of the object's ID attribute as a String.
* @throws IllegalArgumentException if the object has no ID attribute.
* @see #getID(EObject)
* @see org.eclipse.emf.ecore.EAttribute#isID
* @see org.eclipse.emf.ecore.EClass#getEIDAttribute
*/
public static void setID(EObject eObject, String id)
{
EClass eClass = eObject.eClass();
EAttribute eIDAttribute = eClass.getEIDAttribute();
if (eIDAttribute == null)
{
throw new IllegalArgumentException("The object doesn't have an
ID feature.");
}
else if (id == null)
{
eObject.eUnset(eIDAttribute);
}
else
{
eObject.eSet(eIDAttribute,
createFromString(eIDAttribute.getEAttributeType(), id));
}
}
Martin Taal wrote:
> Mat,
> The relational database does not have a notion of resources. The way
> you read the objects in the resource determines there ordering and
> therefore the uri, if the uri is based on position.
> So it is a safer approach to use the concept of an EMF id. You can try
> to map the emf id notion to the same efeature as the database id.
> However, afaik (please correct me Ed if I am wrong) an EMF id is
> always a string while the database id can be something else
> (auto-increment long or something). This can be workarounded pretty
> easily by having a separate EMF id and database id efeature and
> keeping the EMF id in sync with the database id.
>
> gr. Martin
>
> Ed Merks wrote:
>> Mat,
>>
>> URIs are how EMF references other objects in general so this is a
>> more general question. The URI consists of the <base>#<fragment>
>> where the base identifies the resource containing the object and the
>> fragment identifies the object within that resource. If you actually
>> moved the object to a new resource, then clearly the base could
>> change. The fragment might well be a fragment path, so if the object
>> moved within the tree structure of the resource, then that path could
>> change. If the fragment is just an ID/UUID, then it won't change no
>> matter how the object is moved around within its resource. The URI
>> should generally not change arbitrarily unless you move or change the
>> object. I assume this is the case for how Teneo uses URIs as well...
>>
>>
>> Mat Lo wrote:
>>> Hi
>>>
>>> Are we ensured that the URI of an object will remain the same during
>>> all its life cycle ? I mean, when I create a Marker on an EMF Object
>>> (that I identify with its URI, as EMF does in general), am I sure
>>> this URI will remain the same the next time I launch Eclipse ? When
>>> Teneo/Jpox builds EObjects while reading database, will all URIs be
>>> unique for each object and the same as the last time Teneo/Jpox read
>>> the database ?
>>>
>>> Thx
>>>
>
>
--------------000800040507010000000902
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
EMF doesn't force the ID to be a string.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Teneo : persistence of objects URI [message #595087 is a reply to message #58460] |
Thu, 02 November 2006 17:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: mat.loo.gmail.com
Thanks for your answers.
I want to use Id automatically generated by Teneo (I don't want to add an
attribute to my eObjects and set it to "id").
Is there a way to access the id managed by Teneo (I saw it generates them
when no id is set in ECore model)
Thx again.
|
|
|
Re: Teneo : persistence of objects URI [message #595103 is a reply to message #59888] |
Thu, 02 November 2006 17:09 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Ed Merks![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=ed.merks%40gmail.com) Messages: 33197 Registered: July 2009 |
Senior Member |
|
|
Mat,
I assume that eObject.eResource().getURIFragment(eObject) will return
the ID managed by the resource that contains the eObject.
Mat Lo wrote:
> Thanks for your answers.
>
> I want to use Id automatically generated by Teneo (I don't want to add
> an attribute to my eObjects and set it to "id").
> Is there a way to access the id managed by Teneo (I saw it generates
> them when no id is set in ECore model)
>
> Thx again.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Goto Forum:
Current Time: Mon Aug 19 07:04:43 GMT 2024
Powered by FUDForum. Page generated in 0.07005 seconds
|