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
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:)
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)
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
>
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)
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
>