Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » propertyGetter.invoke
propertyGetter.invoke [message #14453] Wed, 25 March 2009 19:07 Go to next message
Anne is currently offline Anne
Messages: 37
Registered: July 2009
Member
Hi,

I am using EOL and I am trying to get the values of a set of properties of
a specific model element. The properties are in a Sequence.

I use the following EOL code:

for (i in self) {
Model.propertyGetter.invoke(modElement, i.name);
}

This seems to work fine for undefined properties and properties that
return one model element. I noticed that I get a NullPointerException for
the property that returns more than one element. I guess the problems lies
with evoke() which returns an Object instead of a Set!?

Is there a workaround for the problem or am I making a mistake?

Thanks a lot in advance and regards,
Anne
Re: propertyGetter.invoke [message #14485 is a reply to message #14453] Thu, 26 March 2009 15:38 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Anne,

That's quite creative! I've never thought that someone would use this in
that way :) (Another alternative would be to call the eGet method:
modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));)

Regarding the error, I've tried with both single and multi-valued
properties but I can't seem to be able to reproduce this. Would it be
possible to share a minimal working example (eol + ecore + sample model)
that demonstrates this - obviously unwanted - behaviour?

Cheers,
Dimitris

Anne Keller wrote:
> Hi,
>
> I am using EOL and I am trying to get the values of a set of properties
> of a specific model element. The properties are in a Sequence.
>
> I use the following EOL code:
>
> for (i in self) {
> Model.propertyGetter.invoke(modElement, i.name);
> }
>
> This seems to work fine for undefined properties and properties that
> return one model element. I noticed that I get a NullPointerException
> for the property that returns more than one element. I guess the
> problems lies with evoke() which returns an Object instead of a Set!?
>
> Is there a workaround for the problem or am I making a mistake?
>
> Thanks a lot in advance and regards,
> Anne
>
Re: propertyGetter.invoke [message #14515 is a reply to message #14485] Fri, 27 March 2009 10:27 Go to previous messageGo to next message
Anne is currently offline Anne
Messages: 37
Registered: July 2009
Member
Hi Dimitri,

thanks a lot for the help! Using

modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));

works like a charm.

I will get an example with the error to you shortly.

Thanks again and regards,
Anne
Re: propertyGetter.invoke [message #14667 is a reply to message #14515] Mon, 30 March 2009 10:59 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Anne,

Thanks a lot for isolating the problem and sending me the example! I
just had a look into this and found/fixed a nasty bug (which you most
probably don't want to know more about :) ). I've committed the changes
to the SVN and uploaded a new binary version (0.8.4.200903301146) in the
interim update site
(http://download.eclipse.org/modeling/gmt/epsilon/interim/).

The new version also includes a new epsilon.emf.loadRegisteredMetamodel
task which allows you to load metamodels from the EMF EPackage registry.
In your case, you can use it to replace:

<epsilon.loadModel name="UML_model" type="EMF">
<parameter name="modelFile" value="${basedir}/UML.ecore"/>
<parameter name="metamodelFile" value="${basedir}/CMOF.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="true"/>
<parameter name="storeOnDisposal" value="false"/>
<parameter name="aliases" value="UML"/>
</epsilon.loadModel>

with:

<epsilon.emf.loadRegisteredMetamodel name="UML_model" aliases="UML"
metamodeluri="http://www.eclipse.org/uml2/2.1.0/UML"/>

and save the time needed to read UML.ecore from the filesystem.

Cheers,
Dimitris

Anne Keller wrote:
> Hi Dimitri,
>
> thanks a lot for the help! Using
>
> modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));
>
> works like a charm.
>
> I will get an example with the error to you shortly.
>
> Thanks again and regards,
> Anne
>
>
Re: propertyGetter.invoke [message #14697 is a reply to message #14667] Tue, 31 March 2009 15:14 Go to previous message
Anne is currently offline Anne
Messages: 37
Registered: July 2009
Member
Cool, thanks!

Anne
Re: propertyGetter.invoke [message #566119 is a reply to message #14453] Thu, 26 March 2009 15:38 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Anne,

That's quite creative! I've never thought that someone would use this in
that way :) (Another alternative would be to call the eGet method:
modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));)

Regarding the error, I've tried with both single and multi-valued
properties but I can't seem to be able to reproduce this. Would it be
possible to share a minimal working example (eol + ecore + sample model)
that demonstrates this - obviously unwanted - behaviour?

Cheers,
Dimitris

Anne Keller wrote:
> Hi,
>
> I am using EOL and I am trying to get the values of a set of properties
> of a specific model element. The properties are in a Sequence.
>
> I use the following EOL code:
>
> for (i in self) {
> Model.propertyGetter.invoke(modElement, i.name);
> }
>
> This seems to work fine for undefined properties and properties that
> return one model element. I noticed that I get a NullPointerException
> for the property that returns more than one element. I guess the
> problems lies with evoke() which returns an Object instead of a Set!?
>
> Is there a workaround for the problem or am I making a mistake?
>
> Thanks a lot in advance and regards,
> Anne
>
Re: propertyGetter.invoke [message #566135 is a reply to message #14485] Fri, 27 March 2009 10:27 Go to previous message
Anne is currently offline Anne
Messages: 37
Registered: July 2009
Member
Hi Dimitri,

thanks a lot for the help! Using

modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));

works like a charm.

I will get an example with the error to you shortly.

Thanks again and regards,
Anne
Re: propertyGetter.invoke [message #566250 is a reply to message #14515] Mon, 30 March 2009 10:59 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Anne,

Thanks a lot for isolating the problem and sending me the example! I
just had a look into this and found/fixed a nasty bug (which you most
probably don't want to know more about :) ). I've committed the changes
to the SVN and uploaded a new binary version (0.8.4.200903301146) in the
interim update site
(http://download.eclipse.org/modeling/gmt/epsilon/interim/).

The new version also includes a new epsilon.emf.loadRegisteredMetamodel
task which allows you to load metamodels from the EMF EPackage registry.
In your case, you can use it to replace:

<epsilon.loadModel name="UML_model" type="EMF">
<parameter name="modelFile" value="${basedir}/UML.ecore"/>
<parameter name="metamodelFile" value="${basedir}/CMOF.ecore"/>
<parameter name="isMetamodelFileBased" value="true"/>
<parameter name="readOnLoad" value="true"/>
<parameter name="storeOnDisposal" value="false"/>
<parameter name="aliases" value="UML"/>
</epsilon.loadModel>

with:

<epsilon.emf.loadRegisteredMetamodel name="UML_model" aliases="UML"
metamodeluri="http://www.eclipse.org/uml2/2.1.0/UML"/>

and save the time needed to read UML.ecore from the filesystem.

Cheers,
Dimitris

Anne Keller wrote:
> Hi Dimitri,
>
> thanks a lot for the help! Using
>
> modElement.eGet(modElement.eClass().getEStructuralFeature(i. name));
>
> works like a charm.
>
> I will get an example with the error to you shortly.
>
> Thanks again and regards,
> Anne
>
>
Re: propertyGetter.invoke [message #566269 is a reply to message #14667] Tue, 31 March 2009 15:14 Go to previous message
Anne is currently offline Anne
Messages: 37
Registered: July 2009
Member
Cool, thanks!

Anne
Previous Topic:Using Collection.excluding(item)
Next Topic:ant build
Goto Forum:
  


Current Time: Tue Oct 21 03:48:24 GMT 2014

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

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