Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » how to give an Ecore DataType to an attribute
how to give an Ecore DataType to an attribute [message #22911] Tue, 14 July 2009 16:12 Go to next message
Ali Gondal is currently offline Ali GondalFriend
Messages: 13
Registered: July 2009
Junior Member
Hi;

I want to transform a model to an ecore metamodel(EM), but I am having a
problem in giving Ecore EString type to an EAttribute.

Here is my simple rule:

rule testRule
transform sf : FM!FeatureModel
to tf : EM!EPackage {

tf.name := sf.name;

for(f in FM.allInstances)
{
var ec : new EM!EClass;
ec.name:=f.name;
tf.eClassifiers.add(ec);
if(f.isTypeOf(Feature) or f.isTypeOf(Group))
{
var card : new EM!EAttribute;
card.name := 'Cardinality';
--var eType : new EM!ETypeParameter;
--eType.name := 'EString';
--card.eType := eType;
card.eType := EString; -- this gives the error, even EM.EString doesnt
work

--card.eAttributeType := eType;
card.lowerBound := f.Min;
card.upperBound := f.Max;
ec.eAttributes.add(card);
}
}
}

I dont want to do it through the variable eType as I want to use Ecore's
built-in data type. I've just started using EMF/ETL and hence this basic
question:)

Any help would be great.

cheers
--Ali
Re: how to give an Ecore DataType to an attribute [message #22956 is a reply to message #22911] Tue, 14 July 2009 16:28 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Ali,

In this case you need to add Ecore as a third model to your
transformation in the launch configuration (Models->Add->Registered EMF
Package and select http://www.eclipse.org/emf/2002/Ecore as the
metamodel URI and set the name to Ecore)

Then you can get EString like this:

card.eType := Ecore!EDataType.all.selectOne(dt|dt.name = 'EString');

Cheers,
Dimitris

Ali Gondal wrote:
> Hi;
>
> I want to transform a model to an ecore metamodel(EM), but I am having a
> problem in giving Ecore EString type to an EAttribute.
>
> Here is my simple rule:
>
> rule testRule transform sf : FM!FeatureModel
> to tf : EM!EPackage {
>
> tf.name := sf.name;
> for(f in FM.allInstances) {
> var ec : new EM!EClass;
> ec.name:=f.name;
> tf.eClassifiers.add(ec); if(f.isTypeOf(Feature)
> or f.isTypeOf(Group))
> {
> var card : new EM!EAttribute;
> card.name := 'Cardinality';
> --var eType : new EM!ETypeParameter;
> --eType.name := 'EString';
> --card.eType := eType;
> card.eType := EString; -- this gives the error, even
> EM.EString doesnt work
>
> --card.eAttributeType := eType;
> card.lowerBound := f.Min;
> card.upperBound := f.Max;
> ec.eAttributes.add(card); }
> }
> }
>
> I dont want to do it through the variable eType as I want to use Ecore's
> built-in data type. I've just started using EMF/ETL and hence this basic
> question:)
>
> Any help would be great.
>
> cheers
> --Ali
>
Re: how to give an Ecore DataType to an attribute [message #23041 is a reply to message #22956] Tue, 14 July 2009 16:36 Go to previous message
Ali Gondal is currently offline Ali GondalFriend
Messages: 13
Registered: July 2009
Junior Member
Many thanks for your help and quick response.

--Ali
Re: how to give an Ecore DataType to an attribute [message #570894 is a reply to message #22911] Tue, 14 July 2009 16:28 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Ali,

In this case you need to add Ecore as a third model to your
transformation in the launch configuration (Models->Add->Registered EMF
Package and select http://www.eclipse.org/emf/2002/Ecore as the
metamodel URI and set the name to Ecore)

Then you can get EString like this:

card.eType := Ecore!EDataType.all.selectOne(dt|dt.name = 'EString');

Cheers,
Dimitris

Ali Gondal wrote:
> Hi;
>
> I want to transform a model to an ecore metamodel(EM), but I am having a
> problem in giving Ecore EString type to an EAttribute.
>
> Here is my simple rule:
>
> rule testRule transform sf : FM!FeatureModel
> to tf : EM!EPackage {
>
> tf.name := sf.name;
> for(f in FM.allInstances) {
> var ec : new EM!EClass;
> ec.name:=f.name;
> tf.eClassifiers.add(ec); if(f.isTypeOf(Feature)
> or f.isTypeOf(Group))
> {
> var card : new EM!EAttribute;
> card.name := 'Cardinality';
> --var eType : new EM!ETypeParameter;
> --eType.name := 'EString';
> --card.eType := eType;
> card.eType := EString; -- this gives the error, even
> EM.EString doesnt work
>
> --card.eAttributeType := eType;
> card.lowerBound := f.Min;
> card.upperBound := f.Max;
> ec.eAttributes.add(card); }
> }
> }
>
> I dont want to do it through the variable eType as I want to use Ecore's
> built-in data type. I've just started using EMF/ETL and hence this basic
> question:)
>
> Any help would be great.
>
> cheers
> --Ali
>
Re: how to give an Ecore DataType to an attribute [message #570944 is a reply to message #22956] Tue, 14 July 2009 16:36 Go to previous message
Ali Gondal is currently offline Ali GondalFriend
Messages: 13
Registered: July 2009
Junior Member
Many thanks for your help and quick response.

--Ali
Previous Topic:how to give an Ecore DataType to an attribute
Next Topic:EuGENia link attributes
Goto Forum:
  


Current Time: Sat Apr 27 01:15:14 GMT 2024

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

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

Back to the top