Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand / Xtend] typeSelect() on stereotype does not work
[Xpand / Xtend] typeSelect() on stereotype does not work [message #641832] Sun, 28 November 2010 15:49 Go to next message
Muba  is currently offline Muba Friend
Messages: 20
Registered: November 2009
Junior Member
Hi,

after successfully accessing my Profie in Xpand/Xtend I was wondering how to enable my stereotypes as regular types, so that typeSelect can recognize them?

I have a sample model where one class has the stereotype of "Form". Now I want in xTend do be able to do this
e.eContents.typeSelect(Form)

But currently this does not work. He only finds "Class" as a type, which has "Form" as an applied stereotype.

As far as I can see, the Hibernate Cartridge also has Entity as a stereotype but manages to work with Entity as a type.

I tried to test with the Persistence.profile.uml and the example-model.uml whether I could select all Entities with
e.eAllContents.typeSelect(Entity)

but it did not work either.

So I am thinking there is some option I have to enable to make it work in my project.

Does someone know what I have to do?

Currently I have the following and I get an error, that main for uml::Class is not defined. It is because I am getting back Elements of type "Class" instead of "Form".

List[Form] forms(Model this) :
    this.eContents.typeSelect(Class).select(e|e.getAppliedStereotype("Forms::Form") != null);


«DEFINE main FOR Model»
	«EXPAND main FOREACH forms()»
«ENDDEFINE»

«DEFINE main FOR Form»
	«FILE name+".java"»
		public class «name» {
			
		}
	«ENDFILE»
«ENDDEFINE»


Muba
Re: [Xpand / Xtend] typeSelect() on stereotype does not work [message #641848 is a reply to message #641832] Sun, 28 November 2010 18:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

can you please post your workflow? make sure the profile is configured there.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [Xpand / Xtend] typeSelect() on stereotype does not work [message #641849 is a reply to message #641848] Sun, 28 November 2010 18:28 Go to previous messageGo to next message
Muba  is currently offline Muba Friend
Messages: 20
Registered: November 2009
Junior Member
Here you go:

<?xml version="1.0"?>
<workflow>
	<property name="model" value="muba.googleforms/src/model/Sample.uml" />
	<property name="profile" value="muba.googleforms/src/model/Forms.profile.uml" />
	<property name="src-gen" value="src-gen" />
	
	
	<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true" />
	
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>
	
	<!-- instantiate metamodel -->
	<bean id="mm" class="org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel"/>

	<!-- Profile Model -->
	<bean id="formsProfile" class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
		<profile value="platform:/resource/${profile}" />
	</bean>

	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>
	
	<!-- directory clean --> 
	<component id="dirCleaner" class="org.eclipse.emf.mwe.utils.DirectoryCleaner" directory="${src-gen}"/>
	
	<!--  generate code -->
	<component class="org.eclipse.xpand2.Generator">
		<metaModel idRef="mm"/>
		<metaModel idRef="formsProfile"/>
		<expand
			value="template::template::main FOR model" />
		<outlet path="${src-gen}" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
</workflow>

Re: [Xpand / Xtend] typeSelect() on stereotype does not work [message #641851 is a reply to message #641849] Sun, 28 November 2010 18:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

i use a workflow that looks like this

<workflow>
	
	<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true" />
	
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".." />
	
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/xpand.uml.profile.sample/src/model/test.uml" />
		<modelSlot value="model" />
	</component>
	
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner">
		<directory value="src-gen" />
	</component>
	
	
	<component class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
			<profile value="platform:/resource/xpand.uml.profile.sample/src/model/test.profile.uml" />
		</metaModel>
		<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel" />
		<expand value="template::Template::main FOR model" />
		<outlet path="src-gen" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
	

</workflow>


this works together with a template like

«EXTENSION template::GeneratorExtensions»

«DEFINE main FOR uml::Model»
	«EXPAND main FOREACH this.eAllContents.typeSelect(test::Bean)»
«ENDDEFINE»
«DEFINE main FOR test::Bean»
«FILE getFQPN().replaceAll("\\.","/")+"/"+name+".java"»
package «getFQPN()»;
public class «name» {

}
«ENDFILE»
«ENDDEFINE»

«DEFINE main FOR uml::Element»
«ENDDEFINE»


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sun, 28 November 2010 18:41]

Report message to a moderator

icon14.gif  Re: [Xpand / Xtend] typeSelect() on stereotype does not work [message #641853 is a reply to message #641851] Sun, 28 November 2010 19:15 Go to previous message
Muba  is currently offline Muba Friend
Messages: 20
Registered: November 2009
Junior Member
Wow, it works.

Thanks a lot Christian.


Best regards,
Muba
Previous Topic:[Xpand] Merging several models into one output (file)
Next Topic:eAllContents gone ...
Goto Forum:
  


Current Time: Thu Apr 25 07:09:49 GMT 2024

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

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

Back to the top