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 |
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
|
|
| | |
Goto Forum:
Current Time: Tue Mar 19 11:02:11 GMT 2024
Powered by FUDForum. Page generated in 0.02192 seconds
|