Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xtend/XPand] Strange behaviour of checks(The checks do not trigger the types)
[Xtend/XPand] Strange behaviour of checks [message #652772] Sun, 06 February 2011 16:03 Go to next message
Muba  is currently offline Muba
Messages: 20
Registered: November 2009
Junior Member
Hi,

I wanted to validate my psmModel, before I generate any Code, but no constraint is being triggered.

Here my workflow:
<workflow>
	<property file="src/workflow/workflow.properties"/>

	<property name="model" value="topcased.conpract/src/model/ConpractPIM_Model.uml" />
	<property name="modelDetail" value="topcased.conpract/src/model/ConpractPIM_ModelDetail.uml" />
	<property name="psmModel" value="topcased.conpract/src/model/ConpractPSM_Model.uml" />
	<property name="PIMprofile" value="topcased.conpract/src/model/ConpractPIM.profile.uml" />
	<property name="PSMprofile" value="topcased.conpract/src/model/ConpractPSM.profile.ecore" />
	<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=".."/>
	
	<!-- read the model -->
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/${model}" />
		<modelSlot value="model" />
	</component>
	
	<!-- PIM to PSM transformation -->
	<component class="org.eclipse.xtend.XtendComponent">
		<metaModel class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
			<profile value="platform:/resource/${PIMprofile}" />
		</metaModel>
		<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>
		<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel" />
		<invoke value="extensions::pim2psmTransformation::transform(model)"/>
		<outputSlot value="psmModel" />
		<globalVarDef name="pim2psm" value="${pim2psm.properties}"/>
	</component>
			
	<!-- write psmModel to file -->
	<component id="write" class="org.eclipse.emf.mwe.utils.Writer">
		<useSingleGlobalResourceSet value="true"/>
		<modelSlot value="psmModel"/>
		<uri value="platform:/resource/${psmModel}" />
	</component>
	
	<!-- check the psmModel -->
	<component class="org.eclipse.xtend.check.CheckComponent">
		<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel" >
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>
		<checkFile value="check::main" />
		<expression value="psmModel.eAllContents" />
		<!--<emfAllChildrenSlot value="psmModel" />-->
	</component>
			
			
	<!-- directory clean --> 
	<component id="dirCleaner" class="org.eclipse.emf.mwe.utils.DirectoryCleaner" directory="${src-gen}"/>
	
	<!--  generate code -->
	<component id="generator" class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>
		<expand
			value="template::main::main FOR psmModel" />
		<outlet path="${src-gen}" >
			<postprocessor
				class="org.hybridlabs.source.formatter.JavaImportBeautifier"
				organizeImports="true"
				format="false"/>
			<postprocessor 
				class="org.eclipse.xpand2.output.JavaBeautifier" 
				configFile="workflow/format.xml" />
		</outlet>
		<globalVarDef name="psm2code" value="${psm2code.properties}"/>
		<fileEncoding value="UTF-8" />
		<prSrcPaths value="${src-gen}" />
	</component>
</workflow>


Here my check file
import ConpractPSM;

context ConpractPSM::Entity ERROR "1":
	false;
	
context Object if this.metaType == Entity ERROR "2":
	false;
	
context Entity ERROR "3":
	false;


The strange thing is that the second constraint works, but I do not want to use this workaround if possible, but rather work with either the first or third constraint.

Does anyone know where the problem is?

Generating the code is no problem, and I can access the ConpractPSM types in Xtend and XPand without any problems. Within my check file the auto completion feature also works for the ConpractPSM metamodel.
Re: [Xtend/XPand] Strange behaviour of checks [message #652777 is a reply to message #652772] Sun, 06 February 2011 16:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6298
Registered: July 2009
Senior Member
Hi,

from the docs ( http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. xpand.doc/help/Check_language.html)

Quote:

emfAllChildrenSlot Name of a workflow slot that contains an EMF object, which has to be validated including all child elements that it contains. This property only works in conjunction with EMF based models.

expression This property allows to set a check expression for the validation component. This property only works in conjunction with non-EMF based models.



~ Christian
Re: [Xtend/XPand] Strange behaviour of checks [message #652778 is a reply to message #652777] Sun, 06 February 2011 16:54 Go to previous messageGo to next message
Muba  is currently offline Muba
Messages: 20
Registered: November 2009
Junior Member
Hi,

whether I use
<expression value="psmModel.eAllContents" />

or
<emfAllChildrenSlot value="psmModel" />

the result is the same in both cases. Only the second constraint is getting triggerd.

So it actually should be working with emfAllChildrenSlot, since my psmModel is EMF based, but somehow it does not.
Well the metamodel of the psmModel is PSMprofile which is a EMF model, so psmModel could be called EMF based, right?
Re: [Xtend/XPand] Strange behaviour of checks [message #652780 is a reply to message #652778] Sun, 06 February 2011 17:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6298
Registered: July 2009
Senior Member
Hi,

Maybe the problem is that you instantiate the metamodel more than once.

<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>

...

<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>


...


<metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</metaModel>



can you try something like this (instantiate once / reference where needed)

<bean id = "mm" class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
			<metaModelFile value="platform:/resource/${PSMprofile}" />
		</bean>


...

<metaModel idref="mm" />

...

<metaModel idref="mm" />


....

<metaModel idref="mm" />


if this does not help can you provide a minmal exampe that reproduces the problem? ecore/xmi/workflow?

~ Christian

[Updated on: Sun, 06 February 2011 17:12]

Report message to a moderator

Re: [Xtend/XPand] Strange behaviour of checks [message #652781 is a reply to message #652780] Sun, 06 February 2011 17:18 Go to previous message
Muba  is currently offline Muba
Messages: 20
Registered: November 2009
Junior Member
Hi,

it works now.

Once again you solved the problem Wink.

Thanks.

Best regards,
Muba
Previous Topic:passing parameters from one block to another
Next Topic:[XPand] questions in using AROUND
Goto Forum:
  


Current Time: Wed Sep 17 05:40:42 GMT 2014

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

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