Home » Archived » M2M (model-to-model transformation) » [QVT-R] public2private example ?
| |
Re: [QVT-R] public2private example ? [message #542585 is a reply to message #542450] |
Fri, 25 June 2010 11:32 |
Bler Messages: 26 Registered: June 2010 |
Junior Member |
|
|
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 16:19 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
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: Wed Sep 25 22:48:47 GMT 2024
Powered by FUDForum. Page generated in 0.06904 seconds
|