Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsEEnum to Epackage relationship lost
https://www.eclipse.org/forums/index.php/mv/msg/22911/73745/#msg_73745
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();) {
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?]]>2007-03-06T13:35:16-00:00Re: EEnum to Epackage relationship lost
https://www.eclipse.org/forums/index.php/mv/msg/22911/603163/#msg_603163
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?
>]]>Ed Merks2007-03-06T14:15:58-00:00Re: EEnum to Epackage relationship lost
https://www.eclipse.org/forums/index.php/mv/msg/22911/73781/#msg_73781
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?
>]]>2007-03-06T14:15:58-00:00