Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » how to use primitiveTypes, OclAny, OclVoid in ATL rules(primitiveTypes, OclAny, OclVoid)
how to use primitiveTypes, OclAny, OclVoid in ATL rules [message #1105180] Mon, 09 September 2013 13:25 Go to next message
Tahar gh is currently offline Tahar gh
Messages: 9
Registered: September 2012
Junior Member
Hi

When trying to realize a transformation from a meta-model PIMM to a meta-model PSMM, I've encoutred two difficulties:

1- how can I include and use primitivetypes in an ATL rule?

2- is there a general type (like Object in UML) that I can use in an ATL rule?


for the first question, I've done as follow :
----------------------


helper def : primitiveTypesPackage : PSMM!Package = OclUndefined;

--- I've created a package of primitivetypes

rule addPrimitiveTypesPackage() {
to
ptPac : PSMM!Package (
name <- 'PrimitiveTypes'
),

stringType : PSMM!PrimitiveType (-- -> (thisModule.primitiveTypesPackage.classifiers)(
name <- 'String'
),
integerType : PSMM!PrimitiveType (-- -> (thisModule.primitiveTypesPackage.classifiers)(
name <- 'Integer'
),
booleanType : PSMM!PrimitiveType (-- -> (thisModule.primitiveTypesPackage.classifiers)(
name <- 'Boolean'
),
commentType : PSMM!PrimitiveType (-- -> (thisModule.primitiveTypesPackage.classifiers)(
name <- 'Real'
),

do {
stringType.package <- thisModule.primitiveTypesPackage;
integerType.package <- thisModule.primitiveTypesPackage;
booleanType.package <- thisModule.primitiveTypesPackage;
commentType.package <- thisModule.primitiveTypesPackage;
}

}


--- And I've used them like this :

helper def : getPrimitiveType(typeName : String) : PSMM!PrimitiveType = PSMM!PrimitiveType.allInstances()->select(t | t.name=typeName)->first();

rule createProperties() {
to
prop: PSMM!Property(
name <- 'itsGroup',
lower <- 1,
upper <- 1,
visibility <- #public,
type <- thisModule.getPrimitiveType('String')
),

...

}

Is this correct? and how Can I indicate the following pathmaps:

'String' -> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String'
'Integer' -> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Integer'
'Boolean' -> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#Boolean'
'Comment' -> 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String'

and this, in order to get in the xmi file representing the target model, an href value for each primitiveType used, for exemple if 'String' is used I must get : href = 'pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String' in the definition of this type in the xmi file representing the tarhet model


NB: - Rather than creating primitiveTypes as I've done? Is it possible to import them and access to the?, if yes, how?


- If I want to use OclVoid to indicate that an operation return nothing, the following helper is it correct?

helper def : OclVoid : PSMM!PrimitiveType = OclUndefined;



for the second question, I've done as follow :
-----------------------


rule createProperties() {
to
prop: PSMM!Property(
name <- 'valuesToReturn',
visibility <- #private,
lower <- 0,
upper <- -1,
type <- OclAny
),

...

}

however this is not acceptable and I get this error :
org.eclipse.m2m.atl.engine.emfvm.VMException: java.lang.Class cannot be cast to org.eclipse.uml2.uml.Type

How Can I affect a general type to a property, to indicate that this property can receive any value?

Thank you in advance
Re: how to use primitiveTypes, OclAny, OclVoid in ATL rules [message #1105267 is a reply to message #1105180] Mon, 09 September 2013 16:00 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 604
Registered: July 2009
Senior Member
Hello,

Please, avoid posting several times the same question on the forum.
This will not make the answers arriving faster, and simply makes the search of already posted questions/answers more difficult for the community.
Thanks in advance.


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: how to use primitiveTypes, OclAny, OclVoid in ATL rules [message #1105481 is a reply to message #1105267] Mon, 09 September 2013 23:25 Go to previous message
Tahar gh is currently offline Tahar gh
Messages: 9
Registered: September 2012
Junior Member
sorry, I duplicated my post having thought the previous one was not received!
Previous Topic:Using a integer iterator
Next Topic:Slightly offtopic: graphical representation of XMI model
Goto Forum:
  


Current Time: Mon Sep 22 22:25:15 GMT 2014

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

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