Home » Archived » M2M (model-to-model transformation) » [QVT-R] public2private example ?
[QVT-R] public2private example ? [message #541608] |
Mon, 21 June 2010 14:38  |
Eclipse User |
|
|
|
Hi there,
Is there anyone who can explain how we can implement the ATL public2private example in QVT-Relations. The entry model is an uml class diagram with 2 public properties and the model in out should be an uml class diagram too, with 2 private properties and theirs getters and setters...
Thank you in advanced,
With regards,
Bler
|
|
| |
Re: [QVT-R] public2private example ? [message #542585 is a reply to message #542450] |
Fri, 25 June 2010 07:32   |
Eclipse User |
|
|
|
Hi Edward,
Since, I just start to learn QVT-Relations, I have been needed for this example to be inspired for an other problem which concerns an uml classes diagram.
In fact, I have a classes diagram with a super-class and some sub-classes, by transformation it, I have/need to move a given operation from the super-class to all its sub-classes, and removing this operation form the super-class.
By reading some QVT-R docs and examples, I done it, it works, but as beginner I'm not sure that it's "high-quality", so I would like that someone check it, or, give me some commentaries, remarks, correct it, ....
So, my implementation looks like this:
transformation classDiagram2classDiagram(source : uml, target : uml) {
-- copies only the super-class
top relation parent2parent {
className : String;
checkonly domain source classS : uml::Class {
name = className
};
enforce domain target classT : uml::Class {
name = className
};
when
{
classS.superClass -> size()= 0;
}
where
{
property2property(classS,classT);
parentOperations2parentOperations(classS,classT);
}
}
-- copies the properties
relation property2property
{
propName : String;
proptype : uml::Type;
checkonly domain source classS : uml::Class {
ownedAttribute = field : uml::Property {
name = propName,
type = proptype
}
};
enforce domain target classT : uml::Class {
ownedAttribute = field : uml::Property {
name = propName,
type = proptype
}
};
}
-- copies all the operation of the super-class except the operation 'oper2'
relation parentOperations2parentOperations {
operationName : String;
operationType : uml::Type;
checkonly domain source classS : uml::Class {
ownedOperation = oprS : uml::Operation {
name = operationName,
type = operationType
}
};
enforce domain target classT : uml::Class {
ownedOperation = oprT : uml::Operation {
name = operationName,
type = operationType
}
};
when
{
operationName <> 'oper2';
}
}
-- Copies all sub-classes including theirs properties, generalisations, and add the operation 'oper2' form the super-class to all these classes
top relation childs2childs {
parentClass : uml::Class;
className : String;
checkonly domain source classS : uml::Class {
name = className,
generalization = genS : uml::Generalization {
general = parentClass
}
};
enforce domain target classT : uml::Class {
name = className,
generalization = genT : uml::Generalization {
general = parentClass
},
ownedOperation = newOperation : uml::Operation {
name = parentClass.getAllOperations()-> at(2).name,
type = parentClass.getAllOperations()-> at(2).type,
-- ...
visibility = uml::VisibilityKind::protected
}
};
when
{
classS.superClass-> size()> 0;
}
where
{
property2property(classS,classT);
}
}
}
I suppose, there are different ways for doing it, so could you give me your opinion, pelase, does it possible to do 'refactoring' on this code, is there any "best way" for realising it,...
Thank you so much,
With regards,
Bler
|
|
|
Re: [QVT-R] public2private example ? [message #542700 is a reply to message #542585] |
Fri, 25 June 2010 12:19   |
Eclipse User |
|
|
|
Hi Bler
I've not checked your example very carefully. It is just very obvious
that the lack of a default deep copy is very restricting.
This was an added value I planned for UMLX, but perhaps QVT needs it.
Regards
Ed Willink
On 25/06/2010 12:32, Bler wrote:
> Hi Edward,
>
> Since, I just start to learn QVT-Relations, I have been needed for this
> example to be inspired for an other problem which concerns an uml
> classes diagram.
> In fact, I have a classes diagram with a super-class and some
> sub-classes, by transformation it, I have/need to move a given operation
> from the super-class to all its sub-classes, and removing this operation
> form the super-class.
>
> By reading some QVT-R docs and examples, I done it, it works, but as
> beginner I'm not sure that it's "high-quality", so I would like that
> someone check it, or, give me some commentaries, remarks, correct it, ....
>
> So, my implementation looks like this:
>
>
> transformation classDiagram2classDiagram(source : uml, target : uml) {
>
> -- copies only the super-class
> top relation parent2parent {
>
> className : String;
> checkonly domain source classS : uml::Class {
> name = className
> };
> enforce domain target classT : uml::Class {
> name = className
> };
> when {
> classS.superClass -> size()= 0;
> }
> where
> {
> property2property(classS,classT);
> parentOperations2parentOperations(classS,classT);
> }
> }
>
> -- copies the properties
> relation property2property {
> propName : String;
> proptype : uml::Type;
> checkonly domain source classS : uml::Class {
> ownedAttribute = field : uml::Property {
> name = propName,
> type = proptype
> }
> };
> enforce domain target classT : uml::Class {
> ownedAttribute = field : uml::Property {
> name = propName,
> type = proptype
> }
> }; }
>
> -- copies all the operation of the super-class except the operation 'oper2'
> relation parentOperations2parentOperations {
> operationName : String;
> operationType : uml::Type;
> checkonly domain source classS : uml::Class {
> ownedOperation = oprS : uml::Operation {
> name = operationName,
> type = operationType
> }
> };
> enforce domain target classT : uml::Class {
> ownedOperation = oprT : uml::Operation {
> name = operationName,
> type = operationType
> }
> };
> when {
> operationName <> 'oper2';
> }
> }
>
> -- Copies all sub-classes including theirs properties, generalisations,
> and add the operation 'oper2' form the super-class to all these classes
> top relation childs2childs {
>
> parentClass : uml::Class;
> className : String;
> checkonly domain source classS : uml::Class {
> name = className,
> generalization = genS : uml::Generalization {
> general = parentClass
> }
>
> };
> enforce domain target classT : uml::Class {
> name = className,
> generalization = genT : uml::Generalization {
> general = parentClass
> },
> ownedOperation = newOperation : uml::Operation {
> name = parentClass.getAllOperations()-> at(2).name,
> type = parentClass.getAllOperations()-> at(2).type,
> -- ...
> visibility = uml::VisibilityKind::protected
> }
> };
> when {
> classS.superClass-> size()> 0;
> }
> where
> {
> property2property(classS,classT);
> }
> }
> }
>
> I suppose, there are different ways for doing it, so could you give me
> your opinion, pelase, does it possible to do 'refactoring' on this code,
> is there any "best way" for realising it,...
>
> Thank you so much,
>
> With regards,
> Bler
|
|
| |
Goto Forum:
Current Time: Sat Jul 05 03:51:13 EDT 2025
Powered by FUDForum. Page generated in 0.04329 seconds
|