Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Using the EmfModel class
Using the EmfModel class [message #558486] Mon, 13 September 2010 08:47 Go to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi,

I have to following problem:

I created a EmfModel object (org.eclipse.epsilon.emc.emf.EmfModel) and then try to load a model in this object.
Therefore I use the following code:

EglFileGeneratingTemplateFactory factory = new EglFileGeneratingTemplateFactory();
EmfModel emfModel = new EmfModel();
StringProperties properties = new StringProperties();
properties.put(EmfModel.PROPERTY_NAME, name);
properties.put(EmfModel.PROPERTY_METAMODEL_FILE, "file:/" + getFile(metamodel).getAbsolutePath());
properties.put(EmfModel.PROPERTY_MODEL_FILE, "file:/" + getFile(model).getAbsolutePath());
properties.put(EmfModel.PROPERTY_IS_METAMODEL_FILE_BASED, "true");
properties.put(EmfModel.PROPERTY_READONLOAD, "true");
//properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, "false");
emfModel.load(properties, null);

factory.getContext().getModelRepository().addModel(emfModel) ;

I didn't receive an error message when I run my program so I think the loading of my model should work fine.

But my problem is that I'm not able to access any concrete data of the model.

Did I something completely wrong?

If necessary you can see in this thread how the model and the meta model looks like.

http://www.eclipse.org/forums/index.php?t=msg&th=175068& amp;start=0&S=2ba7d260f4a39ac0cb5f2531aa9308d8

Best regards,

Andreas






Re: Using the EmfModel class [message #558503 is a reply to message #558486] Mon, 13 September 2010 09:36 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andreas,

At a first glance your code looks fine. Could you please be a bit more
specific on the "I'm not able to access any concrete data" issue? Are
you 1) getting an exception when you try to access data of the model, 2)
getting back nothing at all, or 3) not sure how to access data of the
model at all?

Cheers,
Dimitris

Andreas wrote:
> Hi,
>
> I have to following problem:
>
> I created a EmfModel object (org.eclipse.epsilon.emc.emf.EmfModel) and
> then try to load a model in this object. Therefore I use the following
> code:
>
> EglFileGeneratingTemplateFactory factory = new
> EglFileGeneratingTemplateFactory();
> EmfModel emfModel = new EmfModel();
> StringProperties properties = new StringProperties();
> properties.put(EmfModel.PROPERTY_NAME, name);
> properties.put(EmfModel.PROPERTY_METAMODEL_FILE, "file:/" +
> getFile(metamodel).getAbsolutePath());
> properties.put(EmfModel.PROPERTY_MODEL_FILE, "file:/" +
> getFile(model).getAbsolutePath());
> properties.put(EmfModel.PROPERTY_IS_METAMODEL_FILE_BASED, "true");
> properties.put(EmfModel.PROPERTY_READONLOAD, "true");
> //properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, "false");
> emfModel.load(properties, null);
>
> factory.getContext().getModelRepository().addModel(emfModel) ;
>
> I didn't receive an error message when I run my program so I think the
> loading of my model should work fine.
> But my problem is that I'm not able to access any concrete data of the
> model.
> Did I something completely wrong?
> If necessary you can see in this thread how the model and the meta model
> looks like.
> http://www.eclipse.org/forums/index.php?t=msg&th=175068& amp;start=0&S=2ba7d260f4a39ac0cb5f2531aa9308d8
>
>
> Best regards,
>
> Andreas
>
>
>
>
>
>
>
Re: Using the EmfModel class [message #558517 is a reply to message #558503] Mon, 13 September 2010 10:46 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

thanks for your quick responce.

At the moment I try to access the data from the model with the following statment:

for(EObject eo : emfModel.allContents()){
System.out.println(eo.eAllContents());
}

But everything I get are empty brackets like
[]
[]
[]
[]
[]
[]
[]
[]
...

Regards,

Andreas

Re: Using the EmfModel class [message #558521 is a reply to message #558517] Mon, 13 September 2010 10:52 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andreas,

I'm a bit confused. Do you need to query your model using Java or using
one of the languages of Epsilon?

Cheers,
Dimitris

Andreas wrote:
> Hi Dimitris,
>
> thanks for your quick responce.
> At the moment I try to access the data from the model with the following
> statment:
>
> for(EObject eo : emfModel.allContents()){
> System.out.println(eo.eAllContents());
> }
>
> But everything I get are empty brackets like
> []
> []
> []
> []
> []
> []
> []
> []
> ..
>
> Regards,
>
> Andreas
>
>
Re: Using the EmfModel class [message #558524 is a reply to message #558521] Mon, 13 September 2010 11:19 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

mainly I want to use EGL to acess the data and generate a HTML Report from them.
But at the moment I just play around and try different solution to access the data.
At the moment it seems to me, that the problem is somewhere around the loading of the model (creation of the EmfModel class).

Regards,

Andreas

[Updated on: Mon, 13 September 2010 11:19]

Report message to a moderator

Re: Using the EmfModel class [message #558525 is a reply to message #558524] Mon, 13 September 2010 11:21 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andreas,

Have you perhaps had a look at the following example?

http://eclipse.org/gmt/epsilon/examples/index.php?example=or g.eclipse.epsilon.examples.standalone

Cheers,
Dimitris

Andreas wrote:
> HI Dimitris;
>
> mainly I want to use EGL to acess the data and generate a HTML Report
> from them. But at the moment I just play around and try different
> solution to access the data. At the moment it seems to me, that the
> problem is somewhere around the loading of the model (creation of the
> EmfModel class).
> Regards,
>
> Andreas
Re: Using the EmfModel class [message #558528 is a reply to message #558525] Mon, 13 September 2010 11:36 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

yes I know this example.
More or less I took the part to load my model (creation of the EmfModel class) from this example.

But how could this example solve my issue? My problem is that my object emfModel of the type EmfModel does not contain the concrete data from the model I want to read.

Regards,

Andreas
Re: Using the EmfModel class [message #558564 is a reply to message #558528] Mon, 13 September 2010 14:02 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Ok now I'm able to access my model within a EGL template.
See
http://www.eclipse.org/forums/index.php?t=msg&th=175068

But I still cannot understand, why I'm not able to access the concrete data in the emfModel object.

[Updated on: Mon, 13 September 2010 14:04]

Report message to a moderator

Re: Using the EmfModel class [message #558574 is a reply to message #558564] Mon, 13 September 2010 14:33 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
To access the data of the model using Java you'll need to use the
reflective EMF API (eGet(), eSet() etc.) Below is a link to a tutorial
explaining bits of this

http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/

but the definitive reference for this is the EMF book

http://amzn.to/b9pToU

Cheers,
Dimitris

Andreas wrote:
> Ok now I'm able to access my model within a EGL template. See
> http://www.eclipse.org/forums/index.php?t=msg&th=175068& amp;start=0&S=aa208ef9c763f612a307bff9f6567a4a
>
>
> But I still cannot understand, why I'm not able to access the concrete
> data in the emfModel object.
Re: Using the EmfModel class [message #558717 is a reply to message #558574] Tue, 14 September 2010 08:12 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

thank you for the hint. I will have a look on it.

Regards,

Andreas
Re: Using the EmfModel class [message #593712 is a reply to message #558503] Mon, 13 September 2010 10:46 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

thanks for your quick responce.

At the moment I try to access the data from the model with the following statment:

for(EObject eo : emfModel.allContents()){
System.out.println(eo.eAllContents());
}

But everything I get are empty brackets like
[]
[]
[]
[]
[]
[]
[]
[]
...

Regards,

Andreas
Re: Using the EmfModel class [message #593738 is a reply to message #593712] Mon, 13 September 2010 10:52 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andreas,

I'm a bit confused. Do you need to query your model using Java or using
one of the languages of Epsilon?

Cheers,
Dimitris

Andreas wrote:
> Hi Dimitris,
>
> thanks for your quick responce.
> At the moment I try to access the data from the model with the following
> statment:
>
> for(EObject eo : emfModel.allContents()){
> System.out.println(eo.eAllContents());
> }
>
> But everything I get are empty brackets like
> []
> []
> []
> []
> []
> []
> []
> []
> ..
>
> Regards,
>
> Andreas
>
>
Re: Using the EmfModel class [message #593751 is a reply to message #558521] Mon, 13 September 2010 11:19 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
HI Dimitris;

mainly I want to use EGL to acess the data and generate a HTML Report from them.
But at the moment I just play around and try different solution to access the data.
At the moment it seems to me, that the problem is somewhere around the loading of the model (creation of the EmfModel class).

Regards,

Andreas
Re: Using the EmfModel class [message #593761 is a reply to message #558524] Mon, 13 September 2010 11:21 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andreas,

Have you perhaps had a look at the following example?

http://eclipse.org/gmt/epsilon/examples/index.php?example=or g.eclipse.epsilon.examples.standalone

Cheers,
Dimitris

Andreas wrote:
> HI Dimitris;
>
> mainly I want to use EGL to acess the data and generate a HTML Report
> from them. But at the moment I just play around and try different
> solution to access the data. At the moment it seems to me, that the
> problem is somewhere around the loading of the model (creation of the
> EmfModel class).
> Regards,
>
> Andreas
Re: Using the EmfModel class [message #593772 is a reply to message #558525] Mon, 13 September 2010 11:36 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

yes I know this example.
More or less I took the part to load my model (creation of the EmfModel class) from this example.

But how could this example solve my issue? My problem is that my object emfModel of the type EmfModel does not contain the concrete data from the model I want to read.

Regards,

Andreas
Re: Using the EmfModel class [message #593803 is a reply to message #593772] Mon, 13 September 2010 14:02 Go to previous messageGo to next message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Ok now I'm able to access my model within a EGL template.
See
http://www.eclipse.org/forums/index.php?t=msg&th=175068& amp;start=0&S=aa208ef9c763f612a307bff9f6567a4a

But I still cannot understand, why I'm not able to access the concrete data in the emfModel object.
Re: Using the EmfModel class [message #593809 is a reply to message #593803] Mon, 13 September 2010 14:33 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
To access the data of the model using Java you'll need to use the
reflective EMF API (eGet(), eSet() etc.) Below is a link to a tutorial
explaining bits of this

http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/

but the definitive reference for this is the EMF book

http://amzn.to/b9pToU

Cheers,
Dimitris

Andreas wrote:
> Ok now I'm able to access my model within a EGL template. See
> http://www.eclipse.org/forums/index.php?t=msg&th=175068& amp;start=0&S=aa208ef9c763f612a307bff9f6567a4a
>
>
> But I still cannot understand, why I'm not able to access the concrete
> data in the emfModel object.
Re: Using the EmfModel class [message #593876 is a reply to message #558574] Tue, 14 September 2010 08:12 Go to previous message
Andreas is currently offline Andreas
Messages: 33
Registered: September 2010
Location: Germany
Member
Hi Dimitris,

thank you for the hint. I will have a look on it.

Regards,

Andreas
Previous Topic:[EWL] Specify the position of an element
Next Topic:Error when adding a model to a newly created launch configuration for an evl file
Goto Forum:
  


Current Time: Tue Oct 21 05:30:23 GMT 2014

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

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