Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » EEnum to Epackage relationship lost
EEnum to Epackage relationship lost [message #73745] Tue, 06 March 2007 08:35 Go to next message
Eclipse UserFriend
Originally posted by: prateek.babel.in.bosch.com

Hello,
I have a condition where I have an EPackage(OriginPackage) with some
EClassifiers in it.

Now using Dynamic EMF we are trying to create a new package with details
from OriginPackage like EClassifiers,name,uri,nsURI.

Code Snipplet:

for (Iterator iter = oldSubpackage.getEClassifiers().iterator();
iter.hasNext();) {

// Object container = element.getEClassifiers().get(i);
Object container = iter.next();
if (container instanceof EClass) {
EClass newClass = EcoreFactory.eINSTANCE.createEClass();
newClass.setName("_" + ((EClass) container).getName());
newClass.getESuperTypes().add(container);
newSubPackage.getEClassifiers().add(newClass);
} else {
EEnum tempEnum = EcoreFactory.eINSTANCE.createEEnum();
tempEnum.setName(((EEnum) container).getName());
tempEnum.getELiterals().addAll(((EEnum) container).getELiterals());
newSubPackage.getEClassifiers().add(tempEnum);
}
}


When this code is executed for the EEnum classifiers the EPackage is not
set. That is if i try to do eenum.getEPackage() it return null.


Any solutions?
Re: EEnum to Epackage relationship lost [message #73781 is a reply to message #73745] Tue, 06 March 2007 09:15 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Prateek,

It looks like this code wouldn't work if the EClassifier is an
EDataType. It also looks like you will move the EEnumLiterals from the
original to the copy; you should use EcoreUtil.copy to copy each
literal. It should not be possible for tempEnum to have no containing
EPackage after you add it to the classifiers of a package. What's the
value of EObject.eContainer() and EObject.eContainmentFeature() for it?


Prateek wrote:
> Hello,
> I have a condition where I have an EPackage(OriginPackage) with some
> EClassifiers in it.
> Now using Dynamic EMF we are trying to create a new package with
> details from OriginPackage like EClassifiers,name,uri,nsURI.
>
> Code Snipplet:
>
> for (Iterator iter = oldSubpackage.getEClassifiers().iterator();
> iter.hasNext();) {
>
> // Object container = element.getEClassifiers().get(i);
> Object container = iter.next();
> if (container instanceof EClass) {
> EClass newClass = EcoreFactory.eINSTANCE.createEClass();
> newClass.setName("_" + ((EClass) container).getName());
> newClass.getESuperTypes().add(container);
> newSubPackage.getEClassifiers().add(newClass);
> } else {
> EEnum tempEnum = EcoreFactory.eINSTANCE.createEEnum();
> tempEnum.setName(((EEnum) container).getName());
> tempEnum.getELiterals().addAll(((EEnum)
> container).getELiterals());
> newSubPackage.getEClassifiers().add(tempEnum);
> }
> }
>
>
> When this code is executed for the EEnum classifiers the EPackage is
> not set. That is if i try to do eenum.getEPackage() it return null.
>
>
> Any solutions?
>
Re: EEnum to Epackage relationship lost [message #603163 is a reply to message #73745] Tue, 06 March 2007 09:15 Go to previous message
Eclipse UserFriend
Prateek,

It looks like this code wouldn't work if the EClassifier is an
EDataType. It also looks like you will move the EEnumLiterals from the
original to the copy; you should use EcoreUtil.copy to copy each
literal. It should not be possible for tempEnum to have no containing
EPackage after you add it to the classifiers of a package. What's the
value of EObject.eContainer() and EObject.eContainmentFeature() for it?


Prateek wrote:
> Hello,
> I have a condition where I have an EPackage(OriginPackage) with some
> EClassifiers in it.
> Now using Dynamic EMF we are trying to create a new package with
> details from OriginPackage like EClassifiers,name,uri,nsURI.
>
> Code Snipplet:
>
> for (Iterator iter = oldSubpackage.getEClassifiers().iterator();
> iter.hasNext();) {
>
> // Object container = element.getEClassifiers().get(i);
> Object container = iter.next();
> if (container instanceof EClass) {
> EClass newClass = EcoreFactory.eINSTANCE.createEClass();
> newClass.setName("_" + ((EClass) container).getName());
> newClass.getESuperTypes().add(container);
> newSubPackage.getEClassifiers().add(newClass);
> } else {
> EEnum tempEnum = EcoreFactory.eINSTANCE.createEEnum();
> tempEnum.setName(((EEnum) container).getName());
> tempEnum.getELiterals().addAll(((EEnum)
> container).getELiterals());
> newSubPackage.getEClassifiers().add(tempEnum);
> }
> }
>
>
> When this code is executed for the EEnum classifiers the EPackage is
> not set. That is if i try to do eenum.getEPackage() it return null.
>
>
> Any solutions?
>
Previous Topic:EEnum to Epackage relationship lost
Next Topic:[Teneo] Can't add data
Goto Forum:
  


Current Time: Wed Jul 23 06:13:40 EDT 2025

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

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

Back to the top