|
|
|
|
|
|
|
Re: model merging [message #1008769 is a reply to message #1008114] |
Wed, 13 February 2013 20:25 |
|
Op 09-02-13 09:46, Claudio Persico schreef:
> Thanks for your reply,
>
> only the profile application is the same for both models. For the rest they
> are tipically different classes. Does this make any difference from the ATL
> point of view?
>
> Thanks in advance,
>
> Claudio Persico
You need to specify which element to copy into your output model in case there
are duplicates (i.e. occurrences in both input models).
In addition, copying stereotype applications is hard. EMFTVM makes this a bit
easier by allowing reflective copying of stereotype applications. That way you
can use a standard UML copy transformation:
http://soft.vub.ac.be/viewvc/UML2CaseStudies/uml2cs-transformations/transformations/UML2Copy.atl?view=markup
Note that the above transformation copies only a single input model. You'll
need to adapt each rule (by search-and-replace) to look like this:
rule Comment {
from s : UML2!"uml::Comment" (thisModule.inElements->includes(s))
...
}
and define thisModule.inElements like so:
helper def : inElements : Set(UML2!"ecore::EObject") =
UML2!"ecore::EObject".allInstancesFrom('IN')->union(
UML2!"ecore::EObject".allInstancesFrom('IN2'))->asSet();
This way, the transformation copies all elements from IN and IN2, but not PROFILE.
Regards,
Dennis
Cheers,
Dennis
|
|
|
|
|
Re: model merging [message #1009270 is a reply to message #1008988] |
Thu, 14 February 2013 19:50 |
|
Op 14-02-13 09:57, Claudio Persico schreef:
> Thank you for your reply,
>
> I'm trying to make it works with EMFTVM as Dennis nicely suggested. I
> successfully copied my classes from IN2 in IN1 but they appear outside the
> uml:model.
> I would like to have classes from model 2 (IN2) belonging to uml:model of
> model 1 (IN1). Tipically I do this whit a resolveTemp, but this time I'm not
> able to do this.
>
> Any suggestion?
>
> Thank you in advance.
>
> Claudio
So you indeed have duplicates which need sorting out:
- The two UML2!Model elements at the root of each model
- Each UML2!Package with the same (qualified) name in each model
You need to adapt your inElements helper and the Model and Package rules for this:
uses lib::UML2; -- get this from
http://soft.vub.ac.be/viewvc/UML2CaseStudies/uml2cs-transformations/transformations/lib/UML2.atl?view=markup
helper def : inElements : Set(UML2!"ecore::EObject") =
UML2!"ecore::EObject".allInstancesFrom('IN')->union(
UML2!"ecore::EObject".allInstancesFrom('IN2')->select(e |
e.from('IN').oclIsUndefined()))->asSet();
helper context UML2!"ecore::EObject" def : from(model : String) :
UML2!"ecore::EObject" =
OclUndefined; -- base case: equivalent EObjects cannot be found back
helper context UML2!"uml::Package" def : from(model : String) :
UML2!"uml::Package" =
let packs : Sequence(UML2!"uml::Package") =
UML2!"uml::Package".allInstancesFrom(model)->select(p |
p.umlQualifiedName = self.umlQualifiedName)
in
if packs->isEmpty() then
OclUndefined
else
packs->first()
endif;
helper context UML2!"uml::Model" def : from(model : String) : UML2!"uml::Model" =
UML2!"uml::Model".allInstancesFrom(model)->first();
rule Model {
from s : UML2!"uml::Model" (thisModule.inElements->includes(s))
using {
s2 : UML2!"uml::Model" = s.from('IN2');
}
to t : UML2!"uml::Model" (
__xmiID__ <- s.__xmiID__,
name <- s.name,
visibility <- s.visibility,
viewpoint <- s.viewpoint,
eAnnotations <- s.eAnnotations,
ownedComment <- s.ownedComment,
clientDependency <- s.clientDependency,
nameExpression <- s.nameExpression,
elementImport <- s.elementImport,
packageImport <- s.packageImport,
ownedRule <- s.ownedRule,
templateParameter <- s.templateParameter,
templateBinding <- s.templateBinding,
ownedTemplateSignature <- s.ownedTemplateSignature,
packageMerge <- s.packageMerge,
packagedElement <- s.packagedElement->union(
if s2.oclIsUndefined() then
Sequence{}
else
s2.packagedElement->select(e | thisModule.inElements->includes(e))
endif),
profileApplication <- s.profileApplication)
}
rule Package {
from s : UML2!"uml::Package" in IN (s.oclIsTypeOf(UML2!"uml::Package")
and thisModule.inElements->includes(s))
using {
s2 : UML2!"uml::Package" = s.from('IN2');
}
to t : UML2!"uml::Package" (
__xmiID__ <- s.__xmiID__,
name <- s.name,
visibility <- s.visibility,
eAnnotations <- s.eAnnotations,
ownedComment <- s.ownedComment,
clientDependency <- s.clientDependency,
nameExpression <- s.nameExpression,
elementImport <- s.elementImport,
packageImport <- s.packageImport,
ownedRule <- s.ownedRule,
templateParameter <- s.templateParameter,
templateBinding <- s.templateBinding,
ownedTemplateSignature <- s.ownedTemplateSignature,
packageMerge <- s.packageMerge,
packagedElement <- s.packagedElement->union(
if s2.oclIsUndefined() then
Sequence{}
else
s2.packagedElement->select(e | thisModule.inElements->includes(e))
endif),
profileApplication <- s.profileApplication)
}
Here I've just started with packagedElement, but you may want to merge/filter
other containment references as well (e.g. profileApplication).
Regards,
Dennis
Cheers,
Dennis
|
|
|
|
Re: model merging [message #1009810 is a reply to message #1009530] |
Fri, 15 February 2013 19:10 |
|
Op 15-02-13 10:28, Claudio Persico schreef:
> Thank you so much for your reply and efforts,
>
> The UML2 API java are the last resort to me. I will try them lastly.
>
> Meanwhile I've made this changes:
>
> 1) added libraries UML2 and Strings (referenced by UML2)
> 2) commented previous rules Model and Package
> 3) added new rules Model and Package you provided (thanks again)
> 4) modified helpers you provided because they give me an error. I think this
> is because the name of the helpers if "from", that is a keyword, so I modified
> this in "comesFrom" in the helper and obviously in all callings (is this
> correct?)
>
> Now It gives me this error:
>
>
> org.eclipse.m2m.atl.emftvm.util.VMException:
> java.lang.UnsupportedOperationException:
> UML2!Class::comesFrom(#native!java.lang.String)
> at static EMFTVM!ExecEnv::inElements: Set (staticValue:
> null)@0#2(platform:/resource//ecore2locale/UML2Copy.atl#[207:116-207:133])
> Local variables: [e = _OB0ToGSkEeKEuaD-A95eUA:UML2!Class]
> at public org.eclipse.m2m.atl.emftvm.util.LazyList
> org.eclipse.m2m.atl.emftvm.util.LazyList.select(org.eclipse.m2m.atl.emftvm.CodeBlock)
>
> Local variables: []
> at static EMFTVM!ExecEnv::inElements: Set (staticValue:
> null)#9(platform:/resource//ecore2locale/UML2Copy.atl#[207:2-207:163])
> Local variables: []
> at rule
> Model@matcher#3(platform:/resource//ecore2locale/UML2Copy.atl#[229:4-229:40])
> Local variables: [s: UML2!uml::Model = protections:UML2!Model]
> at static EMFTVM!ExecEnv::main() :
> Object(platform:/resource//ecore2locale/UML2Copy.atl)
> Local variables: []
>
>
> But I don't understand what this means.
> Have I made something wrong?
>
> Thank you in advance,
>
> Claudio
Ah yes, I remember! UML2 got refactored such that its metaclasses no longer
inherit from EObject. You'll need to rewrite your helpers to use OclAny where
you specified EObject before (I called them equivFrom now):
helper context OclAny def : equivFrom(model : String) : OclAny =
OclUndefined; -- base case: equivalent EObjects cannot be found back
helper context UML2!"uml::Package" def : equivFrom(model : String) :
UML2!"uml::Package" =
let packs : Sequence(UML2!"uml::Package") =
UML2!"uml::Package".allInstancesFrom(model)->select(p |
p.umlQualifiedName = self.umlQualifiedName)
in
if packs->isEmpty() then
OclUndefined
else
packs->first()
endif;
helper context UML2!"uml::Model" def : equivFrom(model : String) :
UML2!"uml::Model" =
UML2!"uml::Model".allInstancesFrom(model)->first();
Dennis
Cheers,
Dennis
|
|
|
|
Powered by
FUDForum. Page generated in 0.04629 seconds