Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVT-R] public2private example ?
[QVT-R] public2private example ? [message #541608] Mon, 21 June 2010 18:38 Go to next message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
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 #542450 is a reply to message #541608] Thu, 24 June 2010 21:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Bler

What particular problem do you have?

Regards

Ed Willink

On 21/06/2010 19:38, Bler wrote:
> 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 11:32 Go to previous messageGo to next message
Bler  is currently offline Bler Friend
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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
Re: [QVT-R] public2private example ? [message #542718 is a reply to message #542700] Fri, 25 June 2010 17:08 Go to previous message
Bler  is currently offline Bler Friend
Messages: 26
Registered: June 2010
Junior Member
Hi Edward,

Thank you for your commentaries...

I can't yet to pronounce about QVT, I just found it, maybe it needs even more... Smile

Regards,
Bler
Previous Topic:Does ecore only supports .xmi models?
Next Topic:[ATL][AML] Where can I find AMLLibrary
Goto Forum:
  


Current Time: Thu Apr 25 21:55:20 GMT 2024

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

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

Back to the top