Home » Modeling » M2T (model-to-text transformation) » Using multiple input files (though one model) to generate(Generating from model that uses profile files and other imported model)
Using multiple input files (though one model) to generate [message #1734020] |
Fri, 03 June 2016 02:35  |
Eclipse User |
|
|
|
I am looking for the way to run the generation on the model with it's dependencies.
For example, Using papyrus:
main.uml - the main model file with imported elements (that have profiles linked to them)
dsl.uml - the imported model of a Domain Specific Language primitives/class-types
dsl.profile.uml - the profile (having special stereotypes) that the dsl uses to define the DSL primitives/class-types.
This might be looked as a follow-up to my need to drill down to the source realizations and definitions of the classes/stereotypes, while reaching the edge that contains a certain property like 'instanceName' and resolving it to say 'int' like in c.
[Updated on: Fri, 03 June 2016 02:36] by Moderator
|
|
| | | | | | |
Re: Using multiple input xmi (tough one model) to generate [message #1734955 is a reply to message #1734870] |
Tue, 14 June 2016 02:24   |
Eclipse User |
|
|
|
I have the following model fragment:

My desire is to be able to percolate down the to the origin of the class
and then to the primitive type and last but not least to the InstanceClassName
of the 'SqlDataType'.
Which is from the profile set on the 'Int' class, as seen in the image.

That 'Int' class is linked into the model, imported from the packate Sql, as seen in the image:

This way
[template public generateSqlType(aClass : Class)]
"""
Using query
PrimitiveType Name: [getDslPrimitiveType(aClass).name /]
Its Stereotype Name: [getDslStereoType(aClass).name /]
getDslStereoTypea: "[getDslStereoTypea(aClass) /]"
[getDslStereoType(aClass).eContents()->at(2).oclAsType(Property).name /]:::::::: "[getDslStereoType(aClass).eContents()->at(2).oclAsType(Property) /]"
[getDslStereoType(aClass).eContents() /]
Iterating all over the class dependencies
[for (aDependency : Dependency | aClass.clientDependency) ]
aDependency: [aDependency /]
[for (aSupplier : NamedElement | aDependency.supplier) ]
aSupplier [aSupplier /]
[for (aPrimitiveType : PrimitiveType | aSupplier->filter(PrimitiveType)) ]
aPrimitiveType [aPrimitiveType /]
[for (aStereoType : Stereotype | aPrimitiveType.getAppliedStereotypes()) ]
aStereoType [aStereoType /]
aStereoType.name [aStereoType.name /]
[/for]
[/for]
[/for]
[/for]
[let aPrimitiveType : PrimitiveType = aClass.clientDependency->asSequence()->first().supplier->filter(PrimitiveType)->asSequence()->first() ]
[let aStereoType : Stereotype = aPrimitiveType.getAppliedStereotypes()->asSequence()->first() ]
PrimitiveType NamedElement: [aPrimitiveType.name /] StereoType: [aStereoType.name /]
[if (aStereoType.name.equalsIgnoreCase('SqlDataType')) ]
############
[if (aClass.oclAsType(Class).hasStereotype('PythonDataType'))]
############
[/if]
[if (aClass.hasStereotype('SqlDataType'))]
############
[/if]
[/if][/let][/let]
"""
My desire is to not need to evaluate the type of the DSL I use so
stricly as follows:
[if (aClass.name.equalsIgnoreCase('String'))]
VARCHAR(1024)
[elseif (aClass.name.equalsIgnoreCase('Integer'))]
INTEGER(10)
[elseif (aClass.name.equalsIgnoreCase('BigInteger'))]
INTEGER(10)
[elseif (aClass.name.equalsIgnoreCase('Float'))]
FLOAT(10)
[elseif (aClass.name.equalsIgnoreCase('Date'))]
DATE
[/if]
[/template]
The output of the generation is as follows:
# xxxxType: Integer
# 1
# 1.2
xxxxType """
Using query
PrimitiveType Name: Int
Its Stereotype Name: SqlDataType
getDslStereoTypea: ""
instanceClassName::::::: "org.eclipse.uml2.uml.internal.impl.PropertyImpl@741b3bc3 (name: instanceClassName, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)"
org.eclipse.uml2.uml.internal.impl.PropertyImpl@3efe7086 (name: base_PrimitiveType, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)org.eclipse.uml2.uml.internal.impl.PropertyImpl@741b3bc3 (name: instanceClassName, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)
Iterating all over the class dependencies
aDependency: org.eclipse.uml2.uml.internal.impl.RealizationImpl@3f792b9b (name: <unset>, visibility: <unset>)
aSupplier org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@58a55449 (name: Int, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false)
aPrimitiveType org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@58a55449 (name: Int, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false)
aStereoType org.eclipse.uml2.uml.internal.impl.StereotypeImpl@62e70ea3 (name: SqlDataType, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
aStereoType.name SqlDataType
PrimitiveType NamedElement: Int StereoType: SqlDataType
############
"""
INTEGER(10)
I need the way to access the information that is set as a value for the instanceClassName (Which is INT).
The longest I could reach is this (you can see this in the complete output above):
instanceClassName::::::: "org.eclipse.uml2.uml.internal.impl.PropertyImpl@741b3bc3 (name: instanceClassName, visibility: <unset>) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)"
|
|
| |
Re: Using multiple input xmi (tough one model) to generate [message #1735347 is a reply to message #1734965] |
Fri, 17 June 2016 09:34   |
Eclipse User |
|
|
|
I am sorry, but it didn't.
This a better focused (printing the variables without outside code):
[template public generateSqlType(aClass : Class)]
"""
Iterating all over the class dependencies
[for (aDependency : Dependency | aClass.clientDependency) ]
aDependency.name: [aDependency.name /]
aDependency Dump: [aDependency /]
[for (aSupplier : NamedElement | aDependency.supplier) ]
aSupplier.name: [aSupplier.name /]
aSupplier Dump: [aSupplier /]
PrimitiveType Suppliers:
[for (aPrimitiveType : PrimitiveType | aSupplier->filter(PrimitiveType)) ]
aPrimitiveType.name [aPrimitiveType.name /]
aPrimitiveType Dump: [aPrimitiveType /]
[for (aStereoType : Stereotype | aPrimitiveType.getAppliedStereotypes()) ]
aStereoType Dump: [aStereoType /]
aStereoType.name: [aStereoType.name /]
[aStereoType.eContents()->at(2).oclAsType(Property).name /]::::::: "[aStereoType.eContents()->at(2).oclAsType(Property) /]"
[/for]
[/for]
Class Suppliers:
[for (aaClass : Class | aSupplier->filter(Class)) ]
aaClass.name [aaClass.name /]
aaClass Dump: [aaClass /]
[for (aStereoType : Stereotype | aaClass.getAppliedStereotypes()) ]
aStereoType Dump: [aStereoType /]
aStereoType.name: [aStereoType.name /]
[/for]
[/for]
[/for]
[/for]
[let aPrimitiveType : PrimitiveType = aClass.clientDependency->asSequence()->first().supplier->filter(PrimitiveType)->asSequence()->first() ]
[let aStereoType : Stereotype = aPrimitiveType.getAppliedStereotypes()->asSequence()->first() ]
PrimitiveType NamedElement: [aPrimitiveType.name /] StereoType: [aStereoType.name /]
[if (aStereoType.name.equalsIgnoreCase('SqlDataType')) ]
a [aPrimitiveType.getStereotypeApplication(aStereoType) /]
b [aPrimitiveType.getStereotypeApplication(aStereoType).eAllContents() /]
[getValue(aStereoType, 'instanceClassName') /]
SqlDataType
[/if]
[if (aStereoType.name.equalsIgnoreCase('PythonDataType'))]
[getValue(aStereoType, 'instanceClassName') /]
PythonDataType
[/if]
[/let][/let]
"""
[/template]
The output is:
"""
Iterating all over the class dependencies
aDependency.name:
aDependency Dump: org.eclipse.uml2.uml.internal.impl.RealizationImpl@3f792b9b (name: <unset>, visibility: <unset>)
aSupplier.name: Int
aSupplier Dump: org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@2449cff7 (name: Int, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false)
PrimitiveType Suppliers:
aPrimitiveType.name Int
aPrimitiveType Dump: org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@2449cff7 (name: Int, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false)
aStereoType Dump: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@68d6972f (name: SqlDataType, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
aStereoType.name: SqlDataType
Class Suppliers:
PrimitiveType NamedElement: Int StereoType: SqlDataType
a org.eclipse.emf.ecore.impl.DynamicEObjectImpl@43c67247 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@163d04ff (name: SqlDataType) (instanceClassName: null) (abstract: false, interface: false))
b
invalid
invalid
SqlDataType
"""
Please notice that trying to get the value with 'getValue' as a standalone function (without the element) and with the aClass and this doesn't work either
Though the 'Class' I should be using is the aPrimitiveType because this element has the stereotype. But, aPrimitiveType doesn't have the method 'getValue'...
Please notice the line with:
a [aPrimitiveType.getStereotypeApplication(aStereoType) /]
and the output:
a org.eclipse.emf.ecore.impl.DynamicEObjectImpl@43c67247 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@163d04ff (name: SqlDataType) (instanceClassName: null) (abstract: false, interface: false))
this states instanceClassName is null...
What else could I try?
|
|
|
Re: Using multiple input xmi (tough one model) to generate [message #1735714 is a reply to message #1735347] |
Wed, 22 June 2016 04:31  |
Eclipse User |
|
|
|
Hi Shimon,
I honestly don't know what's happening in this case. The stereotype seems to be found, but a "string" it's supposed to hold isn't? This is an UML question more than an Acceleo one tbh.
Just in case, have you properly initialized the UML resource set before loading the models? You're supposed to use "UMLResourcesUtil.init(ResourceSet)" (or follow the instructions in the UML FAQ to initialize your resource set for standalone use in the generated acceleo launcher's "registerPackages" class. I'm not that familiar with UML, but I guess you also have to register the "sql" profile the same way?
Laurent Goubet
Obeo
|
|
|
Goto Forum:
Current Time: Sat Aug 23 01:07:09 EDT 2025
Powered by FUDForum. Page generated in 0.12763 seconds
|