|
|
Re: EReference to another ECore File [message #430989 is a reply to message #430983] |
Tue, 23 June 2009 12:06 |
No real name Messages: 15 Registered: July 2009 |
Junior Member |
|
|
Ed,
thanks for your reply.
Comments below.
Ed Merks wrote:
> Manfred,
> Comments below.
> Manfred wrote:
>> Hello,
>>
>> I import multiple xml schemas, which results in a different ecore file
>> for each of the schemas. After the import i load the coresponding
>> GenModel file and iterate through all EReferences and add the EOpposites.
> There's an ecore:opposite annotation you could use directly in the
> schema instead.
The problem is, i'm looking at a possibly very large number of schema
files, which are not specified by us. So i though manipulating the ecore
files is easier than automatically process the xsd and add the opposites
there.
>> All works perfectly fine as long as the Reference is in one ecore
>> file. When there is a reference from x.ecore to y.ecore than i get a
>> "Unable to resolve proxy" error, when i try to load the model in an
>> editor.
> I guess the question is how did you make the change?
I load the genmodel and iterate through it and for each EReference i find
and where there is no EOpposite i create one:
EReference eOpposite = EcoreFactory.eINSTANCE.createEReference();
reference.setEOpposite(eOpposite);
eOpposite.setEOpposite(reference);
eOpposite.setEType(reference.getEContainingClass());
eOpposite.setName(oppositeName);
reference.getEReferenceType().getEStructuralFeatures().add(e Opposite);
After that i save the changed ecore file.
>> When i look at the GenModel file than the EReference points to the
>> wrong element (in the wrong namespace). I can correct it manually, but
>> i don't know how to do it programmatically.
> Aren't you making these changes in the Ecore file itself?
What i meant was, that i can correct the ecore files manually, when i open
them in a text editor, but i don't know how to do it automatically, when
the EReference points to an element of another namespace.
|
|
|
Re: EReference to another ECore File [message #430990 is a reply to message #430989] |
Tue, 23 June 2009 13:17 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Manfred,
Comments below.
Manfred wrote:
> Ed,
>
> thanks for your reply.
>
> Comments below.
>
> Ed Merks wrote:
>
>> Manfred,
>
>> Comments below.
>
>> Manfred wrote:
>>> Hello,
>>>
>>> I import multiple xml schemas, which results in a different ecore
>>> file for each of the schemas. After the import i load the
>>> coresponding GenModel file and iterate through all EReferences and
>>> add the EOpposites.
>> There's an ecore:opposite annotation you could use directly in the
>> schema instead.
>
> The problem is, i'm looking at a possibly very large number of schema
> files, which are not specified by us. So i though manipulating the
> ecore files is easier than automatically process the xsd and add the
> opposites there.
Whatever is easier is best...
>
>>> All works perfectly fine as long as the Reference is in one ecore
>>> file. When there is a reference from x.ecore to y.ecore than i get a
>>> "Unable to resolve proxy" error, when i try to load the model in an
>>> editor.
>> I guess the question is how did you make the change?
>
> I load the genmodel and iterate through it and for each EReference i
> find and where there is no EOpposite i create one:
>
> EReference eOpposite = EcoreFactory.eINSTANCE.createEReference();
> reference.setEOpposite(eOpposite);
> eOpposite.setEOpposite(reference);
> eOpposite.setEType(reference.getEContainingClass());
> eOpposite.setName(oppositeName);
> reference.getEReferenceType().getEStructuralFeatures().add(e Opposite);
>
> After that i save the changed ecore file.
Do you save both Ecore files?
>>> When i look at the GenModel file than the EReference points to the
>>> wrong element (in the wrong namespace). I can correct it manually,
>>> but i don't know how to do it programmatically.
>> Aren't you making these changes in the Ecore file itself?
>
> What i meant was, that i can correct the ecore files manually, when i
> open them in a text editor, but i don't know how to do it
> automatically, when the EReference points to an element of another
> namespace.
Try doing it with the Sample Ecore Editor and looking at how it saves
the result. Manual text editing is just asking for trouble...
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04535 seconds