Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 06:35 Go to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 18
Registered: May 2016
Junior Member
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 06:36]

Report message to a moderator

Re: Using multiple input xmi (tough one model) to generate [message #1734026 is a reply to message #1734020] Fri, 03 June 2016 07:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5577
Registered: July 2009
Senior Member
Hi

Are you asking a question or describing your experiences?

Regards

Ed Willink

On 03/06/2016 07:35, Shimon Zadok wrote:
>
> 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.
Re: Using multiple input xmi (tough one model) to generate [message #1734027 is a reply to message #1734026] Fri, 03 June 2016 07:44 Go to previous messageGo to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 18
Registered: May 2016
Junior Member
I am looking for the way to run the generation on the model with it's dependencies. (this is my first sentence)
Can you help me find what I am looking for?
Re: Using multiple input xmi (tough one model) to generate [message #1734076 is a reply to message #1734027] Fri, 03 June 2016 14:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5577
Registered: July 2009
Senior Member
HI

No. Because I don't know what you mean by generation or by model. This
is the M2T newsgroup so I am expecting to see something that involves
model transformation. I see no M2T tool and just UML files that are very
hard to transform to useful text.

Perhaps https://wiki.eclipse.org/OCL/ForumNetiquette might help you
communicate more fruitfully.

Regards

Ed Willink




On 03/06/2016 08:44, Shimon Zadok wrote:
> I am looking for the way to run the generation on the model with it's
> dependencies. (this is my first sentence)
> Can you help me find what I am looking for?
Re: Using multiple input xmi (tough one model) to generate [message #1734791 is a reply to message #1734076] Sun, 12 June 2016 15:59 Go to previous messageGo to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 18
Registered: May 2016
Junior Member
The tool I am using is acceleo (I thought this forum was for that - only, my mistake).

As acceleo gets only one input file, from my brief investigation of the source of my Generate.java.
I wanted to query the project contributors of acceleo if they have the feature, or intend to add the ability for the tool to accept multiple files and generate according to the templates (mtl files).
Re: Using multiple input xmi (tough one model) to generate [message #1734817 is a reply to message #1734791] Mon, 13 June 2016 10:06 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1843
Registered: July 2009
Senior Member
Shimon,

As long as your files have cross-references to each other (i.e. they're actually one logical model), then giving Acceleo the "top level" one as input (the one that has the cross-references to the others) will have each of them loaded during the generation. I don't know exactly what you're trying to accomplish but if you have a specific scenario in mind that doesn't work, please tell us so that we can understand the issue better.

Laurent Goubet
Obeo
Re: Using multiple input xmi (tough one model) to generate [message #1734870 is a reply to message #1734791] Mon, 13 June 2016 10:06 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1843
Registered: July 2009
Senior Member
Shimon,

As long as your files have cross-references to each other (i.e. they're actually one logical model), then giving Acceleo the "top level" one as input (the one that has the cross-references to the others) will have each of them loaded during the generation. I don't know exactly what you're trying to accomplish but if you have a specific scenario in mind that doesn't work, please tell us so that we can understand the issue better.

Laurent Goubet
Obeo
Re: Using multiple input xmi (tough one model) to generate [message #1734955 is a reply to message #1734870] Tue, 14 June 2016 06:24 Go to previous messageGo to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 18
Registered: May 2016
Junior Member
I have the following model fragment:
index.php/fa/26159/0/

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.
index.php/fa/26160/0/

That 'Int' class is linked into the model, imported from the packate Sql, as seen in the image:
index.php/fa/26161/0/

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 #1734965 is a reply to message #1734955] Tue, 14 June 2016 08:47 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1843
Registered: July 2009
Senior Member
Hi Shimon,

If I'm not mistaken, you're not using the proper mechanisms to access this value. Tagged values (properties from a stereotype) need to be retrieved as such :
[element.getValue(element.getAppliedStereotype('stereotypeName'), 'propertyName')/]

In your case, it should look like :
[aClass.getValue(getDslStereoTypea(aClass), 'instanceClassName')/]

Does that solve the issue?

Laurent Goubet
Obeo

[Updated on: Tue, 14 June 2016 08:48]

Report message to a moderator

Re: Using multiple input xmi (tough one model) to generate [message #1735347 is a reply to message #1734965] Fri, 17 June 2016 13:34 Go to previous messageGo to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 18
Registered: May 2016
Junior Member
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 08:31 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1843
Registered: July 2009
Senior Member
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
Previous Topic:Define variable in a template
Next Topic:[Acceleo] Custom Acceleo metamodel
Goto Forum:
  


Current Time: Thu Jan 18 06:23:49 GMT 2018

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

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