Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Changing UML Property Datatype
[ATL] Changing UML Property Datatype [message #100158] Wed, 18 February 2009 11:38 Go to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
I'm attempting to change all of a source models's UML properties from
unset to a UML PrimitiveType of String in the target model.

The transformation I have written seems to do this but the underlying XMI
is totally different to that of a property type set using the UML editor.
Basically the type being set using my transformation isn't the proper UML2
PrimitiveType. I need the types to be set properly.

My transform is as follows...

module SetDefaultAttributeTypes; -- Module Template
create OUT : UML refining IN : UML;

rule AssignDataTypeToProperty
{
from
s : UML!Property
(
s.name.equals('test')
)
to
out : UML!Property
(
name <- s.name.debug(),
isLeaf <- s.isLeaf,
isStatic <- s.isStatic,
isOrdered <- s.isOrdered,
isUnique <- s.isUnique,
isReadOnly <- s.isReadOnly,
isDerived <- s.isDerived,
isDerivedUnion <- s.isDerivedUnion,
eAnnotations <- s.eAnnotations,
ownedComment <- s.ownedComment,
clientDependency <- s.clientDependency,
nameExpression <- s.nameExpression,
datatype <- pt,
upperValue <- s.upperValue,
lowerValue <- s.lowerValue,
templateParameter <- s.templateParameter,
end <- s.end,
deployment <- s.deployment,
redefinedProperty <- s.redefinedProperty,
defaultValue <- s.defaultValue,
subsettedProperty <- s.subsettedProperty,
association <- s.association,
qualifier <- s.qualifier
),
pt : UML!DataType
(
name <- 'String'
)
}

As you can see i'm using the refining mode of ATL 3.0. This shouldn't
matter in the context of my fundamental problem. Any help appreciated!
Thanks,
Ronan
Re: [ATL] Changing UML Property Datatype [message #100186 is a reply to message #100158] Wed, 18 February 2009 12:38 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hi i don't really know to do that but "i think"

1) it's normal it's not the same as uml editor because you create a new
data type for each property

2) the simplest solution you create once the data type in model rule for
example and you reference it in other rule (resolveTemp)

3) if you want to use data type from UML2 Primitive type it's here that
i'm not sure. you should have two input model, your uml and the
primitive types. and you should create a helper getting the
corresponding type in second uml file and maybe you should use eSet
function of ATL (@see wiki for use)

Ronan a écrit :
> Hi,
> I'm attempting to change all of a source models's UML properties from
> unset to a UML PrimitiveType of String in the target model.
> The transformation I have written seems to do this but the underlying
> XMI is totally different to that of a property type set using the UML
> editor. Basically the type being set using my transformation isn't the
> proper UML2 PrimitiveType. I need the types to be set properly.
>
> My transform is as follows...
>
> module SetDefaultAttributeTypes; -- Module Template
> create OUT : UML refining IN : UML;
>
> rule AssignDataTypeToProperty
> {
> from s : UML!Property
> (
> s.name.equals('test')
> )
> to
> out : UML!Property
> (
> name <- s.name.debug(),
> isLeaf <- s.isLeaf,
> isStatic <- s.isStatic,
> isOrdered <- s.isOrdered,
> isUnique <- s.isUnique,
> isReadOnly <- s.isReadOnly,
> isDerived <- s.isDerived,
> isDerivedUnion <- s.isDerivedUnion,
> eAnnotations <- s.eAnnotations,
> ownedComment <- s.ownedComment,
> clientDependency <- s.clientDependency,
> nameExpression <- s.nameExpression,
> datatype <- pt,
> upperValue <- s.upperValue,
> lowerValue <- s.lowerValue,
> templateParameter <- s.templateParameter,
> end <- s.end,
> deployment <- s.deployment,
> redefinedProperty <- s.redefinedProperty,
> defaultValue <- s.defaultValue,
> subsettedProperty <- s.subsettedProperty,
> association <- s.association,
> qualifier <- s.qualifier
> ),
> pt : UML!DataType
> (
> name <- 'String'
> )
> }
>
> As you can see i'm using the refining mode of ATL 3.0. This shouldn't
> matter in the context of my fundamental problem. Any help appreciated!
> Thanks,
> Ronan
>




Re: [ATL] Changing UML Property Datatype [message #100293 is a reply to message #100186] Thu, 19 February 2009 10:15 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Thanks for the suggestions. Some thoughts on your ideas...
1) Yep it creates a new type for every match, this is not the behaviour I
want but I think I have seen posts related to this elsewhere on the
newsgroup. I will report back.

2) This sounds like a viable solution to #1

3) This also sounds like an interesting solution

I have had to ditch my idea of using ATL 3 in refining mode as it does not
support called or lazy rules. I'm going to perform a type by type match
like the one at
http://ssel.vub.ac.be/viewvc/UML1CaseStudies/uml1cs-transfor mations/ModelCopy.atl?view=markup
In my opinion the refining mode is not ready for anything but the simplest
transformation.

Thanks,
Ronan
Re: [ATL] Changing UML Property Datatype [message #100359 is a reply to message #100293] Thu, 19 February 2009 14:56 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Just to follow up on this.

I have got the primitive types in the source model now by loading in the
types as a second input model [see
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02239.html ].

I have a skeleton rule to build these in the output model..

rule CopyTypes
{
from s : UML!PrimitiveType
to t : UML!PrimitiveType
(
)
}

However I get an error when I refer to this rule using resolveTemp. I do
the following
type <- thisModule.resolveTemp(s.type,'tx') or
type <- thisModule.resolveTemp(UML!PrimitiveType,'tx')

The compiler complains that the first param is OclUndefined, which it is
in the source model. It is undefined as it is unset, this is the purpose
of my transform i.e. to set this to a datatype in the target model. Any
ideas?

The error in full is...

Operation not found:
OclUndefined.getNamedTargetFromSource(org.eclipse.emf.ecore. impl.EClassImpl,java.lang.String)
ATL VM Stack:
main: #24
local variables: self=thisModule
__exec__: #48
local variables: self=thisModule,
e=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@10b086ea
__applyCopyPropertyWithoutType: 189:11-189:57#200
local variables: self=thisModule,
link=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@10b086ea,
s=org.eclipse.uml2.uml.internal.impl.PropertyImpl@2d7a9077 (name:
SubNetworkId, visibility: protected) (isLeaf: false) (isStatic: false)
(isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false,
isDerivedUnion: false, aggregation: none),
t=org.eclipse.uml2.uml.internal.impl.PropertyImpl@290c06c3 (name:
SubNetworkId, visibility: <unset>) (isLeaf: false) (isStatic: false)
(isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false,
isDerivedUnion: false, aggregation: none),
xx=org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@35697535 (name:
<unset>, visibility: <unset>) (isLeaf: false, isAbstract: false)
resolveTemp: #6
local variables: self=thisModule,
value=org.eclipse.emf.ecore.impl.EClassImpl@6013a567 (name: PrimitiveType)
(instanceClassName: null) (abstract: false, interface: false), name=tx
Re: [ATL] Changing UML Property Datatype [message #100386 is a reply to message #100359] Thu, 19 February 2009 15:52 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
I think it's what i said in previous post
maybe you should use Primitive type as input and do not to try to
transform it and maybe:

use this statement type <-
UML!PrimitiveType.allInstancesFrom('IN')->select(...Integer)


Ronan a écrit :
> Just to follow up on this.
>
> I have got the primitive types in the source model now by loading in the
> types as a second input model [see
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02239.html ].
>
> I have a skeleton rule to build these in the output model..
>
> rule CopyTypes
> {
> from s : UML!PrimitiveType to t : UML!PrimitiveType (
> )
> }
>
> However I get an error when I refer to this rule using resolveTemp. I do
> the following
> type <- thisModule.resolveTemp(s.type,'tx') or type <-
> thisModule.resolveTemp(UML!PrimitiveType,'tx')
>
> The compiler complains that the first param is OclUndefined, which it is
> in the source model. It is undefined as it is unset, this is the purpose
> of my transform i.e. to set this to a datatype in the target model. Any
> ideas?
>
> The error in full is...
>
> Operation not found:
> OclUndefined.getNamedTargetFromSource(org.eclipse.emf.ecore. impl.EClassImpl,java.lang.String)
>
> ATL VM Stack:
> main: #24 local variables: self=thisModule
> __exec__: #48 local variables: self=thisModule,
> e=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@10b086ea
> __applyCopyPropertyWithoutType: 189:11-189:57#200 local variables:
> self=thisModule,
> link=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@10b086ea,
> s=org.eclipse.uml2.uml.internal.impl.PropertyImpl@2d7a9077 (name:
> SubNetworkId, visibility: protected) (isLeaf: false) (isStatic: false)
> (isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false,
> isDerivedUnion: false, aggregation: none),
> t=org.eclipse.uml2.uml.internal.impl.PropertyImpl@290c06c3 (name:
> SubNetworkId, visibility: <unset>) (isLeaf: false) (isStatic: false)
> (isOrdered: false, isUnique: true, isReadOnly: false) (isDerived: false,
> isDerivedUnion: false, aggregation: none),
> xx=org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@35697535 (name:
> <unset>, visibility: <unset>) (isLeaf: false, isAbstract: false)
> resolveTemp: #6 local variables: self=thisModule,
> value=org.eclipse.emf.ecore.impl.EClassImpl@6013a567 (name:
> PrimitiveType) (instanceClassName: null) (abstract: false, interface:
> false), name=tx
>
>




Re: [ATL] Changing UML Property Datatype [message #100455 is a reply to message #100386] Fri, 20 February 2009 14:45 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Yep thanks for that. In fact you need a few things to get this working.

1) You must take the primitive types in as an extra input model. In my
case called INTYPES : UML

2) You must write a rule to copy all these types to the target

rule CopyTypes
{
from s : UML!PrimitiveType
to t : UML!PrimitiveType
(
clientDependency <- s.clientDependency,
collaborationUse <- s.collaborationUse,
eAnnotations <- s.eAnnotations,
elementImport <- s.elementImport,
general <- s.general,
generalization <- s.generalization,
isAbstract <- s.isAbstract,
isLeaf <- s.isLeaf,
name <- s.name.debug(),
nameExpression <- s.nameExpression,
ownedAttribute <- s.ownedAttribute,
ownedComment <- s.ownedComment,
ownedOperation <- s.ownedOperation,
ownedRule <- s.ownedRule,
ownedTemplateSignature <- s.ownedTemplateSignature,
ownedUseCase <- s.ownedUseCase,
owningTemplateParameter <- s.owningTemplateParameter,
package <- s.package,
packageImport <- s.packageImport,
powertypeExtent <- s.powertypeExtent,
redefinedClassifier <- s.redefinedClassifier,
representation <- s.representation,
substitution <- s.substitution,
templateBinding <- s.templateBinding,
templateParameter <- s.templateParameter,
useCase <- s.useCase,
visibility <- s.visibility
)
}

3) Write a helper to manager the type mapping e.g. String, Integer etc

helper def : mapTypes(in_type : UML!PrimitiveType) : UML!PrimitiveType =
if in_type.oclIsUndefined()
then
UML!PrimitiveType.allInstancesFrom('INTYPES')->select(e|e.name =
'String')->at(1)
endif;

This is an example I will rewrite this helper as a map later.

4) Assign the type to the UML!Property type attribute

type <- thisModule.resolveTemp(thisModule.mapType(s.type),'t')

It seems rather complex but this is the only way i could get this working.
Thanks for all the help and pointers :)

Cheers,
Ronan
Re: [ATL] Changing UML Property Datatype [message #520166 is a reply to message #100455] Thu, 11 March 2010 12:23 Go to previous messageGo to next message
Michael  is currently offline Michael Friend
Messages: 2
Registered: March 2010
Junior Member
hi Ronan,

which model did you takte as input for primitive types? Can't find the right one on the Internet..

Thanks!
Michael

Ronan wrote on Fri, 20 February 2009 09:45
Hi,
Yep thanks for that. In fact you need a few things to get this working.

1) You must take the primitive types in as an extra input model. In my
case called INTYPES : UML

2) You must write a rule to copy all these types to the target

rule CopyTypes
{
from s : UML!PrimitiveType
to t : UML!PrimitiveType
(
clientDependency <- s.clientDependency,
collaborationUse <- s.collaborationUse,
eAnnotations <- s.eAnnotations,
elementImport <- s.elementImport,
general <- s.general,
generalization <- s.generalization,
isAbstract <- s.isAbstract,
isLeaf <- s.isLeaf,
name <- s.name.debug(),
nameExpression <- s.nameExpression,
ownedAttribute <- s.ownedAttribute,
ownedComment <- s.ownedComment,
ownedOperation <- s.ownedOperation,
ownedRule <- s.ownedRule,
ownedTemplateSignature <- s.ownedTemplateSignature,
ownedUseCase <- s.ownedUseCase,
owningTemplateParameter <- s.owningTemplateParameter,
package <- s.package,
packageImport <- s.packageImport,
powertypeExtent <- s.powertypeExtent,
redefinedClassifier <- s.redefinedClassifier,
representation <- s.representation,
substitution <- s.substitution,
templateBinding <- s.templateBinding,
templateParameter <- s.templateParameter,
useCase <- s.useCase,
visibility <- s.visibility
)
}

3) Write a helper to manager the type mapping e.g. String, Integer etc

helper def : mapTypes(in_type : UML!PrimitiveType) : UML!PrimitiveType =
if in_type.oclIsUndefined()
then
UML!PrimitiveType.allInstancesFrom('INTYPES')->select(e|e.name =
'String')->at(1)
endif;

This is an example I will rewrite this helper as a map later.

4) Assign the type to the UML!Property type attribute

type <- thisModule.resolveTemp(thisModule.mapType(s.type),'t')

It seems rather complex but this is the only way i could get this working.
Thanks for all the help and pointers Smile

Cheers,
Ronan

Re: [ATL] Changing UML Property Datatype [message #520771 is a reply to message #100158] Mon, 15 March 2010 09:46 Go to previous message
Michael  is currently offline Michael Friend
Messages: 2
Registered: March 2010
Junior Member
I found a solution.

I changed in the launch configuration (advanced tab) to Regular VM and enabled the checkbox for "allow inter-model references"


Michael
Previous Topic:Problem with references and lazy rules
Next Topic:[QVTO] Unbound mappings not reentrant?
Goto Forum:
  


Current Time: Thu Apr 25 15:53:20 GMT 2024

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

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

Back to the top