Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » automatic assignment of generated UUID to attribute with property ID=true [intrinsic]
automatic assignment of generated UUID to attribute with property ID=true [intrinsic] [message #530655] Fri, 30 April 2010 12:37 Go to next message
Kris Missing name is currently offline Kris Missing nameFriend
Messages: 47
Registered: July 2009
Member
hi,

I would like to set an attribute of modeled class with the provided UUID
after one overrides the ResourceFactory/XMIResourceImpl + method
useUUIDs return true.

How can this be achieved? I assume overriding the setId-method is a
solution. if so, how can one get find the feature which property ID is
set to true? Like:

public void setID(EObject eObject, String id) {


super.setID(eObject, id);

EList<EStructuralFeature> feat =
eObject.eClass().getEAllStructuralFeatures();

for(EStructuralFeature f : feat){
if(f.isID()){
//set the id to this feature ...
//somehow...
}
}

}

However, there is no isID() method - only methods like isUnique(),
isMany() etc.

Thanks
Kris
Re: automatic assignment of generated UUID to attribute with property ID=true [intrinsic] [message #530656 is a reply to message #530655] Fri, 30 April 2010 12:39 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
You could use EcoreUtil.setID or logic just like it uses.


KW wrote:
> hi,
>
> I would like to set an attribute of modeled class with the provided
> UUID after one overrides the ResourceFactory/XMIResourceImpl + method
> useUUIDs return true.
>
> How can this be achieved? I assume overriding the setId-method is a
> solution. if so, how can one get find the feature which property ID is
> set to true? Like:
>
> public void setID(EObject eObject, String id) {
>
>
> super.setID(eObject, id);
>
> EList<EStructuralFeature> feat =
> eObject.eClass().getEAllStructuralFeatures();
>
> for(EStructuralFeature f : feat){
> if(f.isID()){
> //set the id to this feature ...
> //somehow...
> }
> }
>
> }
>
> However, there is no isID() method - only methods like isUnique(),
> isMany() etc.
>
> Thanks
> Kris


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] Mapping from CODObject to CDOClass
Next Topic:[CDO Teneo] Do not set your version attribute to negative default
Goto Forum:
  


Current Time: Fri Apr 26 03:10:08 GMT 2024

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

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

Back to the top