Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] Problem with ClassCastException in ModelPackage
[TEXO] Problem with ClassCastException in ModelPackage [message #559199] Wed, 15 September 2010 23:01 Go to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi,

I created a code-gen.annotationsmodel from my ecore to change the package path.
The enums will not saved in the correct folder from the annotionsmodel, but the package definition in the generated code ist correct.

In my model if have a Contact class and an enum called ContactType. If I call ModelPackage.INSTANCE I get the following exception:
Caused by: java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EEnumImpl cannot be cast to org.eclipse.emf.ecore.EClass
	at de.sim.texo.model.common.person.PersonModelPackage.getContactEClass(PersonModelPackage.java:787)
	at de.sim.texo.model.common.person.PersonModelPackage.initialize(PersonModelPackage.java:405)
	at de.sim.texo.model.common.person.PersonModelPackage.<clinit>(PersonModelPackage.java:376)
	... 31 more


The generated code looks like this:
	/**
	 * Returns the {@link EClass} '<em><b>Contact</b></em>'.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @return an instance of the {@link EClass} '<em><b>Contact</b></em>' 
	 * @generated
	 */
	public EClass getContactEClass() {
		return (EClass) getEPackage().getEClassifiers().get(
				CONTACT_CLASSIFIER_ID);
	}

I debugged a little bit. This method return the ContactType instead of the Contact.

In my ecore looks like this:
<eClassifiers xsi:type="ecore:EClass" name="Contact">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" lowerBound="1" eType="#//ContactType"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="context" lowerBound="1"
        eType="#//ContactContextType" defaultValueLiteral="PRIVATE"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="note" eType="ecore:EClass common.ecore#//Note"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
    <eLiterals name="EMAIL"/>
    <eLiterals name="PHONE" value="1"/>
    <eLiterals name="MOBILE" value="2"/>
    <eLiterals name="FAX" value="3"/>
    <eLiterals name="WWW" value="4"/>
    <eLiterals name="MESSENGER" value="5"/>
    <eLiterals name="OTHER" value="6"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="ContactContextType">
    <eLiterals name="PRIVATE"/>
    <eLiterals name="BUSINESS" value="1"/>
    <eLiterals name="OTHER" value="2"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="ContactList">
    <eStructuralFeatures xsi:type="ecore:EReference" name="contacts" upperBound="-1"
        eType="#//Contact"/>
  </eClassifiers>


Does anybody know this problem?

Regards,
Mark

Re: [TEXO] Problem with ClassCastException in ModelPackage [message #559236 is a reply to message #559199] Thu, 16 September 2010 06:52 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
Maybe the CONTACT_CLASSIFIER_ID has a wrong value, i.e. the same value as the classifier id of the enum (can you check
this in the generated ModelPackage class?)?

Can you send me the complete ecore and the annotations model? Then I can try to reproduce the problem.

Btw, what do you mean with this:
The enums will not saved in the correct folder from the annotionsmodel, but the package definition in the generated code
ist correct.

The enum classes were not generated you mean?

gr. Martin

On 09/16/2010 01:01 AM, Mark Hoffmann wrote:
>
> <eClassifiers xsi:type="ecore:EClass" name="Contact">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> lowerBound="1" eType="#//ContactType"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="context"
> lowerBound="1"
> eType="#//ContactContextType" defaultValueLiteral="PRIVATE"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//ELong"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="note"
> eType="ecore:EClass common.ecore#//Note"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
> <eLiterals name="EMAIL"/>
> <eLiterals name="PHONE" value="1"/>
> <eLiterals name="MOBILE" value="2"/>
> <eLiterals name="FAX" value="3"/>
> <eLiterals name="WWW" value="4"/>
> <eLiterals name="MESSENGER" value="5"/>
> <eLiterals name="OTHER" value="6"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactContextType">
> <eLiterals name="PRIVATE"/>
> <eLiterals name="BUSINESS" value="1"/>
> <eLiterals name="OTHER" value="2"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="ContactList">
> <eStructuralFeatures xsi:type="ecore:EReference" name="contacts"
> upperBound="-1"
> eType="#//Contact"/>
> </eClassifiers>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [TEXO] Problem with ClassCastException in ModelPackage [message #559270 is a reply to message #559236] Thu, 16 September 2010 08:47 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

I looked into it a little bit. You're right the classifier id's are wrong. I changed it in the generated code by hand and everything works.

Regarding the enum problem:
I have an ecore with enums. I create an annotionsmodel from this ecore. I changed the package path, model class package path as well as the qualified class names for the classes and enums in the annotionsmodel.

When I generate the model code, for classes everything is fine. The enum java code contains the annotationsmodel package definition. but the java-file is generated in the original folder from the standard defintion. It should be generated in the folder structure from the annotionsmodel.

Further there are some wrong paths in the generated factory. You will see it, when you generate code from this ecore and annotationsmodel.

I can send you ecore and model so i paste it here:
ECORE:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
    nsURI="http://test" nsPrefix="test">
  <eClassifiers xsi:type="ecore:EClass" name="Person">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="address" lowerBound="1"
        eType="#//Address"/>
    <eStructuralFeatures xsi:type="ecore:EReference" name="contacts" upperBound="-1"
        eType="#//Contact"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Address">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Contact">
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ContactType"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
    <eLiterals name="PHONE"/>
    <eLiterals name="EMAIL" value="1"/>
  </eClassifiers>
</ecore:EPackage>


Annotationsmodel:
<?xml version="1.0" encoding="ASCII"?>
<annotationsmodel:AnnotatedModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:annotationsmodel="http://www.eclipse.org/emf/texo/annotations/model" xmlns:modelannotations="http://www.eclipse.org/emf/texo/modelgenerator/modelannotations">
  <annotatedEPackages>
    <ePackage href="test.ecore#/"/>
    <ePackageAnnotations xsi:type="modelannotations:EPackageModelGenAnnotation" name="test" packagePath="texo.test" modelClassesPackagePath="texo.test" qualifiedClassName="test.TestModelPackage" simpleClassName="TestModelPackage" simpleModelFactoryClassName="TestModelFactory" ecoreFileContent="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>&#xD;&#xA;&lt;ecore:EPackage xmi:version=&quot;2.0&quot;&#xD;&#xA;    xmlns:xmi=&quot;http://www.omg.org/XMI&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&#xD;&#xA;    xmlns:ecore=&quot;http://www.eclipse.org/emf/2002/Ecore&quot; name=&quot;test&quot;&#xD;&#xA;    nsURI=&quot;http://test&quot; nsPrefix=&quot;test&quot;>&#xD;&#xA;  &lt;eClassifiers xsi:type=&quot;ecore:EClass&quot; name=&quot;Person&quot;>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;firstname&quot; eType=&quot;ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString&quot;/>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;lastname&quot; eType=&quot;ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString&quot;/>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EReference&quot; name=&quot;address&quot; lowerBound=&quot;1&quot;&#xD;&#xA;        eType=&quot;#//Address&quot;/>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EReference&quot; name=&quot;contacts&quot; upperBound=&quot;-1&quot;&#xD;&#xA;        eType=&quot;#//Contact&quot;/>&#xD;&#xA;  &lt;/eClassifiers>&#xD;&#xA;  &lt;eClassifiers xsi:type=&quot;ecore:EClass&quot; name=&quot;Address&quot;>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;street&quot; eType=&quot;ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString&quot;/>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;city&quot; eType=&quot;ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString&quot;/>&#xD;&#xA;  &lt;/eClassifiers>&#xD;&#xA;  &lt;eClassifiers xsi:type=&quot;ecore:EClass&quot; name=&quot;Contact&quot;>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;value&quot; eType=&quot;ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString&quot;/>&#xD;&#xA;    &lt;eStructuralFeatures xsi:type=&quot;ecore:EAttribute&quot; name=&quot;type&quot; eType=&quot;#//ContactType&quot;/>&#xD;&#xA;  &lt;/eClassifiers>&#xD;&#xA;  &lt;eClassifiers xsi:type=&quot;ecore:EEnum&quot; name=&quot;ContactType&quot;>&#xD;&#xA;    &lt;eLiterals name=&quot;PHONE&quot;/>&#xD;&#xA;    &lt;eLiterals name=&quot;EMAIL&quot; value=&quot;1&quot;/>&#xD;&#xA;  &lt;/eClassifiers>&#xD;&#xA;&lt;/ecore:EPackage>&#xD;&#xA;" ecoreFileName="test.ecore"/>
    <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
      <eClass href="test.ecore#//Person"/>
      <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Person" qualifiedClassName="texo.test.Person" simpleClassName="Person" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0" hasManyFeatures="true" hasSuperEClass="false" serializable="false" abstract="false"/>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Person/firstname"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="firstname" getter="getFirstname" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setFirstname" validJavaMemberName="firstname" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Person/lastname"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="lastname" getter="getLastname" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setLastname" validJavaMemberName="lastname" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEReference">
        <eReference href="test.ecore#//Person/address"/>
        <eReferenceAnnotations xsi:type="modelannotations:EReferenceModelGenAnnotation" name="address" getter="getAddress" type="test.Address" objectType="test.Address" itemType="test.Address" defaultValue="null" setter="setAddress" validJavaMemberName="address" many="false" useList="false" reference="true" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnnotations.0" generateSafeManyAccess="true"/>
      </annotatedEStructuralFeatures>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEReference">
        <eReference href="test.ecore#//Person/contacts"/>
        <eReferenceAnnotations xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contacts" getter="getContacts" type="java.util.List&lt;test.Contact>" objectType="java.util.List&lt;test.Contact>" itemType="test.Contact" defaultValue="new java.util.ArrayList&lt;test.Contact>()" setter="setContacts" validJavaMemberName="contacts" many="true" useList="true" reference="true" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnnotations.0" generateSafeManyAccess="true"/>
      </annotatedEStructuralFeatures>
    </annotatedEClassifiers>
    <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
      <eClass href="test.ecore#//Address"/>
      <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Address" qualifiedClassName="texo.test.Address" simpleClassName="Address" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0" hasSuperEClass="false" serializable="false" abstract="false"/>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Address/street"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="street" getter="getStreet" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setStreet" validJavaMemberName="street" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Address/city"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="city" getter="getCity" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setCity" validJavaMemberName="city" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
    </annotatedEClassifiers>
    <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
      <eClass href="test.ecore#//Contact"/>
      <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Contact" qualifiedClassName="texo.test.Contact" simpleClassName="Contact" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0" hasSuperEClass="false" serializable="false" abstract="false"/>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Contact/value"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="value" getter="getValue" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setValue" validJavaMemberName="value" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
      <annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
        <eAttribute href="test.ecore#//Contact/type"/>
        <eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="type" getter="getType" type="test.ContactType" objectType="test.ContactType" itemType="test.ContactType" defaultValue="test.ContactType.PHONE" setter="setType" validJavaMemberName="type" many="false" useList="false" reference="false" ownerEClassAnnotation="//@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnnotations.0" boolean="false" primitive="false"/>
      </annotatedEStructuralFeatures>
    </annotatedEClassifiers>
    <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEEnum">
      <eEnum href="test.ecore#//ContactType"/>
      <eEnumAnnotations xsi:type="modelannotations:EEnumModelGenAnnotation" name="ContactType" qualifiedClassName="test.ContactType" simpleClassName="ContactType" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0" instanceClassName="texo.test.ContactType" objectClassName="test.ContactType" enum="true" dateType="false" automaticStringConversion="false" itemType="java.lang.Object"/>
      <annotatedEEnumLiterals>
        <eEnumLiteral href="test.ecore#//ContactType/PHONE"/>
      </annotatedEEnumLiterals>
      <annotatedEEnumLiterals>
        <eEnumLiteral href="test.ecore#//ContactType/EMAIL"/>
      </annotatedEEnumLiterals>
    </annotatedEClassifiers>
  </annotatedEPackages>
</annotationsmodel:AnnotatedModel>


Regards,
Mark
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #559280 is a reply to message #559270] Thu, 16 September 2010 09:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
The annotationsmodel seems to be illegal xml (maybe my copy-paste). Can you enter a bugzilla and attach the files to it?
Then I can add them to the test suite.

gr. Martin

On 09/16/2010 10:47 AM, Mark Hoffmann wrote:
> Hi Martin,
>
> I looked into it a little bit. You're right the classifier id's are
> wrong. I changed it in the generated code by hand and everything works.
>
> Regarding the enum problem:
> I have an ecore with enums. I create an annotionsmodel from this ecore.
> I changed the package path, model class package path as well as the
> qualified class names for the classes and enums in the annotionsmodel.
>
> When I generate the model code, for classes everything is fine. The enum
> java code contains the annotationsmodel package definition. but the
> java-file is generated in the original folder from the standard
> defintion. It should be generated in the folder structure from the
> annotionsmodel.
>
> Further there are some wrong paths in the generated factory. You will
> see it, when you generate code from this ecore and annotationsmodel.
>
> I can send you ecore and model so i paste it here:
> ECORE:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="http://test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Person">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="address"
> lowerBound="1"
> eType="#//Address"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="contacts"
> upperBound="-1"
> eType="#//Contact"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Address">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Contact">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="#//ContactType"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
> <eLiterals name="PHONE"/>
> <eLiterals name="EMAIL" value="1"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> Annotationsmodel:
>
> <?xml version="1.0" encoding="ASCII"?>
> <annotationsmodel:AnnotatedModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:annotationsmodel="http://www.eclipse.org/emf/texo/annotations/model"
> xmlns:modelannotations=" http://www.eclipse.org/emf/texo/modelgenerator/modelannotati ons">
>
> <annotatedEPackages>
> <ePackage href="test.ecore#/"/>
> <ePackageAnnotations
> xsi:type="modelannotations:EPackageModelGenAnnotation" name="test"
> packagePath="texo.test" modelClassesPackagePath="texo.test"
> qualifiedClassName="test.TestModelPackage"
> simpleClassName="TestModelPackage"
> simpleModelFactoryClassName="TestModelFactory" ecoreFileContent="<?xml
> version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="http://test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Person">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="address"
> lowerBound="1"
> eType="#//Address"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="contacts"
> upperBound="-1"
> eType="#//Contact"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Address">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Contact">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="#//ContactType"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
> <eLiterals name="PHONE"/>
> <eLiterals name="EMAIL" value="1"/>
> </eClassifiers>
> </ecore:EPackage>
> " ecoreFileName="test.ecore"/>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Person"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Person" qualifiedClassName="texo.test.Person"
> simpleClassName="Person" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasManyFeatures="true" hasSuperEClass="false" serializable="false"
> abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Person/firstname"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation"
> name="firstname" getter="getFirstname" type="java.lang.String"
> objectType="java.lang.String" itemType="java.lang.String"
> defaultValue="null" setter="setFirstname"
> validJavaMemberName="firstname" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Person/lastname"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="lastname"
> getter="getLastname" type="java.lang.String"
> objectType="java.lang.String" itemType="java.lang.String"
> defaultValue="null" setter="setLastname" validJavaMemberName="lastname"
> many="false" useList="false" reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEReference">
> <eReference href="test.ecore#//Person/address"/>
> <eReferenceAnnotations
> xsi:type="modelannotations:EReferenceModelGenAnnotation" name="address"
> getter="getAddress" type="test.Address" objectType="test.Address"
> itemType="test.Address" defaultValue="null" setter="setAddress"
> validJavaMemberName="address" many="false" useList="false"
> reference="true"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> generateSafeManyAccess="true"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEReference">
> <eReference href="test.ecore#//Person/contacts"/>
> <eReferenceAnnotations
> xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contacts"
> getter="getContacts" type="java.util.List<test.Contact>"
> objectType="java.util.List<test.Contact>" itemType="test.Contact"
> defaultValue="new java.util.ArrayList<test.Contact>()"
> setter="setContacts" validJavaMemberName="contacts" many="true"
> useList="true" reference="true"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> generateSafeManyAccess="true"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Address"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Address" qualifiedClassName="texo.test.Address"
> simpleClassName="Address" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasSuperEClass="false" serializable="false" abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Address/street"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="street"
> getter="getStreet" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setStreet"
> validJavaMemberName="street" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Address/city"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="city"
> getter="getCity" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setCity"
> validJavaMemberName="city" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Contact"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Contact" qualifiedClassName="texo.test.Contact"
> simpleClassName="Contact" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasSuperEClass="false" serializable="false" abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Contact/value"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="value"
> getter="getValue" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setValue"
> validJavaMemberName="value" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Contact/type"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="type"
> getter="getType" type="test.ContactType" objectType="test.ContactType"
> itemType="test.ContactType" defaultValue="test.ContactType.PHONE"
> setter="setType" validJavaMemberName="type" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEEnum">
> <eEnum href="test.ecore#//ContactType"/>
> <eEnumAnnotations xsi:type="modelannotations:EEnumModelGenAnnotation"
> name="ContactType" qualifiedClassName="test.ContactType"
> simpleClassName="ContactType" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> instanceClassName="texo.test.ContactType"
> objectClassName="test.ContactType" enum="true" dateType="false"
> automaticStringConversion="false" itemType="java.lang.Object"/>
> <annotatedEEnumLiterals>
> <eEnumLiteral href="test.ecore#//ContactType/PHONE"/>
> </annotatedEEnumLiterals>
> <annotatedEEnumLiterals>
> <eEnumLiteral href="test.ecore#//ContactType/EMAIL"/>
> </annotatedEEnumLiterals>
> </annotatedEClassifiers>
> </annotatedEPackages>
> </annotationsmodel:AnnotatedModel>
>
>
> Regards,
> Mark


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [TEXO] Problem with ClassCastException in ModelPackage [message #559296 is a reply to message #559280] Thu, 16 September 2010 10:02 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

there are two new bugs:
- 325427 regarding the wron classifier id's
- 325429 regarding some generation problems
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #559313 is a reply to message #559296] Thu, 16 September 2010 11:06 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
I checked the annotations model and there are some strange in there. For example the Address eclass annotation has this
eattribute:
qualifiedClassName="texo.test.Address"
however, the Person eclass has an ereference annotation for address with this eattribute:
type="test.Address"

This is the reason that there are compile errors in the generated code for the Person, as it refers to a type which does
not get generated. It is best to have a quite empty annotationsmodel (so only annotate what you want to change, the rest
is automatically generated). So to solve this I would remove all the ereference annotations.

To be sure, did you manually change the annotations model?

The reason that the ContactType enum is generated in a separate package is because its annotation has this eattribute set:
qualifiedClassName="test.ContactType"

so therefore it ends up in the test package and not in the texo.test package.

gr. Martin

On 09/16/2010 12:02 PM, Mark Hoffmann wrote:
> Hi Martin,
>
> there are two new bugs:
> - 325427 regarding the wron classifier id's
> - 325429 regarding some generation problems


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [TEXO] Problem with ClassCastException in ModelPackage [message #559431 is a reply to message #559313] Thu, 16 September 2010 15:20 Go to previous messageGo to next message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

I gave a detailed answer in the bug#325429.

My intention was to get a result like the Base Package attribute in genmodel.

I just want to generate my model not in the package given from ecore. Instead I want to have it in my projects convention.

This means like in the code, generated by the gemodel, to change the references autoamtically.

So if I had the "base package" attribute in the annotionsmodel, I could simply add the base package before the defined package from the ecore. Thats it. You have to do this for eRefrences as well.

Do you know what I mean?

Regards,
Mark
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #559436 is a reply to message #559313] Thu, 16 September 2010 15:28 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Martin,

let us close this thread and discuss over the bugs or email

Mark
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #623216 is a reply to message #559236] Thu, 16 September 2010 08:47 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

I looked into it a little bit. You're right the classifier id's are wrong. I changed it in the generated code by hand and everything works.

Regarding the enum problem:
I have an ecore with enums. I create an annotionsmodel from this ecore. I changed the package path, model class package path as well as the qualified class names for the classes and enums in the annotionsmodel.

When I generate the model code, for classes everything is fine. The enum java code contains the annotationsmodel package definition. but the java-file is generated in the original folder from the standard defintion. It should be generated in the folder structure from the annotionsmodel.

Further there are some wrong paths in the generated factory. You will see it, when you generate code from this ecore and annotationsmodel.

I can send you ecore and model so i paste it here:
ECORE:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
nsURI="http://test" nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="Person">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="address" lowerBound="1"
eType="#//Address"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="contacts" upperBound="-1"
eType="#//Contact"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Address">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Contact">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ContactType"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="ContactType">
<eLiterals name="PHONE"/>
<eLiterals name="EMAIL" value="1"/>
</eClassifiers>
</ecore:EPackage>


Annotationsmodel:

<?xml version="1.0" encoding="ASCII"?>
<annotationsmodel:AnnotatedModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:annotationsmodel="http://www.eclipse.org/emf/texo/annotations/model" xmlns:modelannotations=" http://www.eclipse.org/emf/texo/modelgenerator/modelannotati ons">
<annotatedEPackages>
<ePackage href="test.ecore#/"/>
<ePackageAnnotations xsi:type="modelannotations:EPackageModelGenAnnotation" name="test" packagePath="texo.test" modelClassesPackagePath="texo.test" qualifiedClassName="test.TestModelPackage" simpleClassName="TestModelPackage" simpleModelFactoryClassName="TestModelFactory" ecoreFileContent="<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
nsURI="http://test" nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="Person">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="address" lowerBound="1"
eType="#//Address"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="contacts" upperBound="-1"
eType="#//Contact"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Address">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Contact">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="#//ContactType"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EEnum" name="ContactType">
<eLiterals name="PHONE"/>
<eLiterals name="EMAIL" value="1"/>
</eClassifiers>
</ecore:EPackage>
" ecoreFileName="test.ecore"/>
<annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
<eClass href="test.ecore#//Person"/>
<eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Person" qualifiedClassName="texo.test.Person" simpleClassName="Person" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 " hasManyFeatures="true" hasSuperEClass="false" serializable="false" abstract="false"/>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Person/firstname"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="firstname" getter="getFirstname" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setFirstname" validJavaMemberName="firstname" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Person/lastname"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="lastname" getter="getLastname" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setLastname" validJavaMemberName="lastname" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEReference">
<eReference href="test.ecore#//Person/address"/>
<eReferenceAnnotations xsi:type="modelannotations:EReferenceModelGenAnnotation" name="address" getter="getAddress" type="test.Address" objectType="test.Address" itemType="test.Address" defaultValue="null" setter="setAddress" validJavaMemberName="address" many="false" useList="false" reference="true" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 " generateSafeManyAccess="true"/>
</annotatedEStructuralFeatures>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEReference">
<eReference href="test.ecore#//Person/contacts"/>
<eReferenceAnnotations xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contacts" getter="getContacts" type="java.util.List<test.Contact>" objectType="java.util.List<test.Contact>" itemType="test.Contact" defaultValue="new java.util.ArrayList<test.Contact>()" setter="setContacts" validJavaMemberName="contacts" many="true" useList="true" reference="true" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 " generateSafeManyAccess="true"/>
</annotatedEStructuralFeatures>
</annotatedEClassifiers>
<annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
<eClass href="test.ecore#//Address"/>
<eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Address" qualifiedClassName="texo.test.Address" simpleClassName="Address" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 " hasSuperEClass="false" serializable="false" abstract="false"/>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Address/street"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="street" getter="getStreet" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setStreet" validJavaMemberName="street" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Address/city"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="city" getter="getCity" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setCity" validJavaMemberName="city" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
</annotatedEClassifiers>
<annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
<eClass href="test.ecore#//Contact"/>
<eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation" name="Contact" qualifiedClassName="texo.test.Contact" simpleClassName="Contact" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 " hasSuperEClass="false" serializable="false" abstract="false"/>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Contact/value"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="value" getter="getValue" type="java.lang.String" objectType="java.lang.String" itemType="java.lang.String" defaultValue="null" setter="setValue" validJavaMemberName="value" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
<annotatedEStructuralFeatures xsi:type="annotationsmodel:AnnotatedEAttribute">
<eAttribute href="test.ecore#//Contact/type"/>
<eAttributeAnnotations xsi:type="modelannotations:EAttributeModelGenAnnotation" name="type" getter="getType" type="test.ContactType" objectType="test.ContactType" itemType="test.ContactType" defaultValue="test.ContactType.PHONE" setter="setType" validJavaMemberName="type" many="false" useList="false" reference="false" ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 " boolean="false" primitive="false"/>
</annotatedEStructuralFeatures>
</annotatedEClassifiers>
<annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEEnum">
<eEnum href="test.ecore#//ContactType"/>
<eEnumAnnotations xsi:type="modelannotations:EEnumModelGenAnnotation" name="ContactType" qualifiedClassName="test.ContactType" simpleClassName="ContactType" generateCode="true" ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 " instanceClassName="texo.test.ContactType" objectClassName="test.ContactType" enum="true" dateType="false" automaticStringConversion="false" itemType="java.lang.Object"/>
<annotatedEEnumLiterals>
<eEnumLiteral href="test.ecore#//ContactType/PHONE"/>
</annotatedEEnumLiterals>
<annotatedEEnumLiterals>
<eEnumLiteral href="test.ecore#//ContactType/EMAIL"/>
</annotatedEEnumLiterals>
</annotatedEClassifiers>
</annotatedEPackages>
</annotationsmodel:AnnotatedModel>


Regards,
Mark
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #623218 is a reply to message #623216] Thu, 16 September 2010 09:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
The annotationsmodel seems to be illegal xml (maybe my copy-paste). Can you enter a bugzilla and attach the files to it?
Then I can add them to the test suite.

gr. Martin

On 09/16/2010 10:47 AM, Mark Hoffmann wrote:
> Hi Martin,
>
> I looked into it a little bit. You're right the classifier id's are
> wrong. I changed it in the generated code by hand and everything works.
>
> Regarding the enum problem:
> I have an ecore with enums. I create an annotionsmodel from this ecore.
> I changed the package path, model class package path as well as the
> qualified class names for the classes and enums in the annotionsmodel.
>
> When I generate the model code, for classes everything is fine. The enum
> java code contains the annotationsmodel package definition. but the
> java-file is generated in the original folder from the standard
> defintion. It should be generated in the folder structure from the
> annotionsmodel.
>
> Further there are some wrong paths in the generated factory. You will
> see it, when you generate code from this ecore and annotationsmodel.
>
> I can send you ecore and model so i paste it here:
> ECORE:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="http://test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Person">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="address"
> lowerBound="1"
> eType="#//Address"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="contacts"
> upperBound="-1"
> eType="#//Contact"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Address">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Contact">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="#//ContactType"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
> <eLiterals name="PHONE"/>
> <eLiterals name="EMAIL" value="1"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> Annotationsmodel:
>
> <?xml version="1.0" encoding="ASCII"?>
> <annotationsmodel:AnnotatedModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:annotationsmodel="http://www.eclipse.org/emf/texo/annotations/model"
> xmlns:modelannotations=" http://www.eclipse.org/emf/texo/modelgenerator/modelannotati ons">
>
> <annotatedEPackages>
> <ePackage href="test.ecore#/"/>
> <ePackageAnnotations
> xsi:type="modelannotations:EPackageModelGenAnnotation" name="test"
> packagePath="texo.test" modelClassesPackagePath="texo.test"
> qualifiedClassName="test.TestModelPackage"
> simpleClassName="TestModelPackage"
> simpleModelFactoryClassName="TestModelFactory" ecoreFileContent="<?xml
> version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
> nsURI="http://test" nsPrefix="test">
> <eClassifiers xsi:type="ecore:EClass" name="Person">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="firstname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="lastname"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="address"
> lowerBound="1"
> eType="#//Address"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="contacts"
> upperBound="-1"
> eType="#//Contact"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Address">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Contact">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> eType="#//ContactType"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EEnum" name="ContactType">
> <eLiterals name="PHONE"/>
> <eLiterals name="EMAIL" value="1"/>
> </eClassifiers>
> </ecore:EPackage>
> " ecoreFileName="test.ecore"/>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Person"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Person" qualifiedClassName="texo.test.Person"
> simpleClassName="Person" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasManyFeatures="true" hasSuperEClass="false" serializable="false"
> abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Person/firstname"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation"
> name="firstname" getter="getFirstname" type="java.lang.String"
> objectType="java.lang.String" itemType="java.lang.String"
> defaultValue="null" setter="setFirstname"
> validJavaMemberName="firstname" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Person/lastname"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="lastname"
> getter="getLastname" type="java.lang.String"
> objectType="java.lang.String" itemType="java.lang.String"
> defaultValue="null" setter="setLastname" validJavaMemberName="lastname"
> many="false" useList="false" reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEReference">
> <eReference href="test.ecore#//Person/address"/>
> <eReferenceAnnotations
> xsi:type="modelannotations:EReferenceModelGenAnnotation" name="address"
> getter="getAddress" type="test.Address" objectType="test.Address"
> itemType="test.Address" defaultValue="null" setter="setAddress"
> validJavaMemberName="address" many="false" useList="false"
> reference="true"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> generateSafeManyAccess="true"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEReference">
> <eReference href="test.ecore#//Person/contacts"/>
> <eReferenceAnnotations
> xsi:type="modelannotations:EReferenceModelGenAnnotation" name="contacts"
> getter="getContacts" type="java.util.List<test.Contact>"
> objectType="java.util.List<test.Contact>" itemType="test.Contact"
> defaultValue="new java.util.ArrayList<test.Contact>()"
> setter="setContacts" validJavaMemberName="contacts" many="true"
> useList="true" reference="true"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.0/@eClassAnno tations.0 "
> generateSafeManyAccess="true"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Address"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Address" qualifiedClassName="texo.test.Address"
> simpleClassName="Address" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasSuperEClass="false" serializable="false" abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Address/street"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="street"
> getter="getStreet" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setStreet"
> validJavaMemberName="street" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Address/city"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="city"
> getter="getCity" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setCity"
> validJavaMemberName="city" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.1/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Contact"/>
> <eClassAnnotations xsi:type="modelannotations:EClassModelGenAnnotation"
> name="Contact" qualifiedClassName="texo.test.Contact"
> simpleClassName="Contact" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> hasSuperEClass="false" serializable="false" abstract="false"/>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Contact/value"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="value"
> getter="getValue" type="java.lang.String" objectType="java.lang.String"
> itemType="java.lang.String" defaultValue="null" setter="setValue"
> validJavaMemberName="value" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> <annotatedEStructuralFeatures
> xsi:type="annotationsmodel:AnnotatedEAttribute">
> <eAttribute href="test.ecore#//Contact/type"/>
> <eAttributeAnnotations
> xsi:type="modelannotations:EAttributeModelGenAnnotation" name="type"
> getter="getType" type="test.ContactType" objectType="test.ContactType"
> itemType="test.ContactType" defaultValue="test.ContactType.PHONE"
> setter="setType" validJavaMemberName="type" many="false" useList="false"
> reference="false"
> ownerEClassAnnotation=" //@annotatedEPackages.0/@annotatedEClassifiers.2/@eClassAnno tations.0 "
> boolean="false" primitive="false"/>
> </annotatedEStructuralFeatures>
> </annotatedEClassifiers>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEEnum">
> <eEnum href="test.ecore#//ContactType"/>
> <eEnumAnnotations xsi:type="modelannotations:EEnumModelGenAnnotation"
> name="ContactType" qualifiedClassName="test.ContactType"
> simpleClassName="ContactType" generateCode="true"
> ownerEPackageAnnotation="//@annotatedEPackages.0/@ePackageAnnotations.0 "
> instanceClassName="texo.test.ContactType"
> objectClassName="test.ContactType" enum="true" dateType="false"
> automaticStringConversion="false" itemType="java.lang.Object"/>
> <annotatedEEnumLiterals>
> <eEnumLiteral href="test.ecore#//ContactType/PHONE"/>
> </annotatedEEnumLiterals>
> <annotatedEEnumLiterals>
> <eEnumLiteral href="test.ecore#//ContactType/EMAIL"/>
> </annotatedEEnumLiterals>
> </annotatedEClassifiers>
> </annotatedEPackages>
> </annotationsmodel:AnnotatedModel>
>
>
> Regards,
> Mark


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [TEXO] Problem with ClassCastException in ModelPackage [message #623220 is a reply to message #559280] Thu, 16 September 2010 10:02 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

there are two new bugs:
- 325427 regarding the wron classifier id's
- 325429 regarding some generation problems
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #623222 is a reply to message #623220] Thu, 16 September 2010 11:06 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mark,
I checked the annotations model and there are some strange in there. For example the Address eclass annotation has this
eattribute:
qualifiedClassName="texo.test.Address"
however, the Person eclass has an ereference annotation for address with this eattribute:
type="test.Address"

This is the reason that there are compile errors in the generated code for the Person, as it refers to a type which does
not get generated. It is best to have a quite empty annotationsmodel (so only annotate what you want to change, the rest
is automatically generated). So to solve this I would remove all the ereference annotations.

To be sure, did you manually change the annotations model?

The reason that the ContactType enum is generated in a separate package is because its annotation has this eattribute set:
qualifiedClassName="test.ContactType"

so therefore it ends up in the test package and not in the texo.test package.

gr. Martin

On 09/16/2010 12:02 PM, Mark Hoffmann wrote:
> Hi Martin,
>
> there are two new bugs:
> - 325427 regarding the wron classifier id's
> - 325429 regarding some generation problems


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
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: [TEXO] Problem with ClassCastException in ModelPackage [message #623225 is a reply to message #559313] Thu, 16 September 2010 15:20 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Hi Martin,

I gave a detailed answer in the bug#325429.

My intention was to get a result like the Base Package attribute in genmodel.

I just want to generate my model not in the package given from ecore. Instead I want to have it in my projects convention.

This means like in the code, generated by the gemodel, to change the references autoamtically.

So if I had the "base package" attribute in the annotionsmodel, I could simply add the base package before the defined package from the ecore. Thats it. You have to do this for eRefrences as well.

Do you know what I mean?

Regards,
Mark
Re: [TEXO] Problem with ClassCastException in ModelPackage [message #623227 is a reply to message #559313] Thu, 16 September 2010 15:28 Go to previous message
Mark Hoffmann is currently offline Mark HoffmannFriend
Messages: 113
Registered: July 2009
Location: Jena
Senior Member
Martin,

let us close this thread and discuss over the bugs or email

Mark
Previous Topic:[EEF] Ant task to generate models and code
Next Topic:[EEF] Model reload
Goto Forum:
  


Current Time: Thu Mar 28 11:46:40 GMT 2024

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

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

Back to the top