[Xpand] Problem with creating model elements from Java [message #494784] |
Mon, 02 November 2009 11:16  |
Eclipse User |
|
|
|
Hi,
I am working with a MDD tool, that is based on oAW and I am trying to create new model elements with Java during the model-to-code transformation.
However, I faced the problem, that I cannot instanciate new model elements, because they exist only as Java Interfaces in the model code. The documentation of oAW mentions in a very short passage, that one should use "DataFactory", to create new model elements from Java, but it then only references to the EMF documentation for further details, where I did not find any further information.
My problem is, that I did not find out, how to use this "DataFactory": I did not find it in the API documentation, nor via Eclipse's code completion feature.
So maybe one of you can explain to me, how I can instantiate new model elements from Java.
Thank you in advance!
Best regards,
Dominik
|
|
|
|
|
Re: [Xpand] Problem with creating model elements from Java [message #495268 is a reply to message #494784] |
Wed, 04 November 2009 07:57   |
Eclipse User |
|
|
|
Hi,
with the help of Karsten, I am now able to instantiate new objects during the model-to-code transformation. However, a new problem has arisen at this point:
The objects, I instantiate will be put in a list, that is an attribute of an already existing model element. But later in the M2C transformation, the workflow stops and puts an error to the console, stating that my newly created objects "[are] not contained in a resource".
Does anyone of you have an idea, what I did wrong? In my opinion, these objects should be contained in the list, where I put them and so there should be a transitive containment relation up to the root element of my model. However, there seems to be some kind of problem...
Thank you in advance for your help!
Dominik
|
|
|
Re: [Xpand] Problem with creating model elements from Java [message #495421 is a reply to message #495268] |
Wed, 04 November 2009 13:58   |
Eclipse User |
|
|
|
Hi.
Dominik Sojer <sojer@in.tum.de> writes:
> The objects, I instantiate will be put in a list, that is an attribute of an
> already existing model element. But later in the M2C transformation, the
> workflow stops and puts an error to the console, stating that my newly
> created objects "[are] not contained in a resource".
>
> Does anyone of you have an idea, what I did wrong? In my opinion, these
> objects should be contained in the list, where I put them and so there
> should be a transitive containment relation up to the root element of my
> model.
There should be, yes. But is it really there? Your list - I assume you've got
a reference with multiplicity of ..*? Check whether the containment attribute
on that reference is set, otherwise there's a 'gap' in your containment
relations.
HTH
Volker
--
* Volker Wegert * http://www.volker-wegert.de/contact *
The computer revolution is over. The computers won.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04397 seconds