Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [Xtend] constraint on existance(equivalent to oclIsUndefined)
[Xtend] constraint on existance [message #525323] Tue, 06 April 2010 00:54 Go to next message
Eclipse UserFriend
Hi,

I'm using Xtend in a m2m and m2t transformation, and I have errors saying : 'no null' constraint is violated.

I think it comes from an attribute I have in my metamodel, which can be defined (but doesn't have to be defined all the time).


List[Attribute] attributs(Class c) :
	c.classdeclaration.typeSelect(Attribute).composition.select(e| (e!=true || e!=false));

List[Attribute] relations(Class c) :
	c.classdeclaration.typeSelect(Attribute).composition.select(e| (e==true || e==false));


I want to define 2 sets, based on whether composition is defined or not. I tried that, as the oclIsUndefined doesn't exist (as it's Xtend and not ocl), but I still get errors when running the workflow.

6 avr. 2010 10:36:21 org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent invokeInternal
GRAVE: Error in Component  of type org.eclipse.xtend.XtendComponent: 
	EvaluationException : The 'no null' constraint is violated
	object2relationnal::object2relationnal.ext[604,29] on line 19 'this.setColumn(c.attributs())'
	object2relationnal::object2relationnal.ext[484,25] on line 15 'p.classes().createTable()'    
	nofile[0,16] on line 1 'transform(model)'                                                    

6 avr. 2010 10:36:21 org.eclipse.emf.mwe.core.WorkflowRunner executeWorkflow
GRAVE: Workflow interrupted. Reason: The 'no null' constraint is violated


So is there an equivalent to oclIsUndefined in Xtend ? Or does everything need to be defined (and so I have to modify my metamodel) ?
Re: [Xtend] constraint on existance [message #525329 is a reply to message #525323] Tue, 06 April 2010 01:08 Go to previous messageGo to next message
Eclipse UserFriend
I guess you need to check for null before setting the column in
object2relationnal.ext on line 19

(if (c.attributs()!=null) then this.setColumn(c.attributs()))

Sven

Maxime Lecourt schrieb:
> Hi,
>
> I'm using Xtend in a m2m and m2t transformation, and I have errors
> saying : 'no null' constraint is violated.
>
> I think it comes from an attribute I have in my metamodel, which can be
> defined (but doesn't have to be defined all the time).
>
>
>
> List[Attribute] attributs(Class c) :
> c.classdeclaration.typeSelect(Attribute).composition.select( e|
> (e!=true || e!=false));
>
> List[Attribute] relations(Class c) :
> c.classdeclaration.typeSelect(Attribute).composition.select( e|
> (e==true || e==false));
>
>
> I want to define 2 sets, based on whether composition is defined or not.
> I tried that, as the oclIsUndefined doesn't exist (as it's Xtend and not
> ocl), but I still get errors when running the workflow.
>
> 6 avr. 2010 10:36:21
> org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflo wComponent
> invokeInternal
> GRAVE: Error in Component of type org.eclipse.xtend.XtendComponent:
> EvaluationException : The 'no null' constraint is violated
> object2relationnal::object2relationnal.ext[604,29] on line 19
> 'this.setColumn(c.attributs())'
> object2relationnal::object2relationnal.ext[484,25] on line 15
> 'p.classes().createTable()' nofile[0,16] on line 1
> 'transform(model)'
> 6 avr. 2010 10:36:21 org.eclipse.emf.mwe.core.WorkflowRunner
> executeWorkflow
> GRAVE: Workflow interrupted. Reason: The 'no null' constraint is violated
>
> So is there an equivalent to oclIsUndefined in Xtend ? Or does
> everything need to be defined (and so I have to modify my metamodel) ?


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xtend] constraint on existance [message #525349 is a reply to message #525323] Tue, 06 April 2010 06:13 Go to previous messageGo to next message
Eclipse UserFriend
After a few tries I have gotten to another error (the proposition didn't change anything, the error was somewhere else).

That is what my Xtend file look like.
List[Attribute] attributs(Class c) :
	c.classdeclaration.typeSelect(Attribute).select(e| e.composition == null);

List[Attribute] relations(Class c) :
	c.classdeclaration.typeSelect(Attribute).select(e| e.composition != null);

create relationnel::Base transform (metamodel::Package p) :
	this.setTables(p.classes().createTable());

create relationnel::Table createTable (metamodel::Class c) :
	this.setName(c.name) ->
	this.setColumn(c.attributs().createColumn());

create relationnel::Column createColumn(metamodel::Attribute attr) :
	this.setName(attr.name);


now I get this Error:
6 avr. 2010 12:04:40 org.eclipse.emf.mwe.core.container.CompositeComponent internalInvoke
INFO: Writer: Writing model to src-gen/outModel.xmi
6 avr. 2010 12:04:40 org.eclipse.emf.mwe.core.WorkflowRunner executeWorkflow
GRAVE: Workflow interrupted. Reason: Problems writing xmi file to src-gen/outModel.xmi : The object 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1e3cd51 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1833eca (name: Column) (instanceClassName: null) (abstract: false, interface: false))' is not contained in a resource.


What exactly does it the setColumn function do (I have one such function existing for every 'attribute' in my metamodel) ?
When I write c.attributs().createColumn(), does that mean that createColumn will be called for every object in the list returned by c.attributs ?
Re: [Xtend] constraint on existance [message #525367 is a reply to message #525349] Tue, 06 April 2010 07:29 Go to previous messageGo to next message
Eclipse UserFriend
I think Base.tables as well as Table.columns should be containment
references with upper bound -1.
please check your ecore file.

accessing a multi-valued property in emf is done by invoking the getter
and modifying the list.

Sven


Maxime Lecourt schrieb:
> After a few tries I have gotten to another error (the proposition didn't
> change anything, the error was somewhere else).
>
> That is what my Xtend file look like.
>
> List[Attribute] attributs(Class c) :
> c.classdeclaration.typeSelect(Attribute).select(e| e.composition ==
> null);
>
> List[Attribute] relations(Class c) :
> c.classdeclaration.typeSelect(Attribute).select(e| e.composition !=
> null);
>
> create relationnel::Base transform (metamodel::Package p) :
> this.setTables(p.classes().createTable());
>
> create relationnel::Table createTable (metamodel::Class c) :
> this.setName(c.name) ->
> this.setColumn(c.attributs().createColumn());
>
> create relationnel::Column createColumn(metamodel::Attribute attr) :
> this.setName(attr.name);
>
>
> now I get this Error:
> 6 avr. 2010 12:04:40
> org.eclipse.emf.mwe.core.container.CompositeComponent internalInvoke
> INFO: Writer: Writing model to src-gen/outModel.xmi
> 6 avr. 2010 12:04:40 org.eclipse.emf.mwe.core.WorkflowRunner
> executeWorkflow
> GRAVE: Workflow interrupted. Reason: Problems writing xmi file to
> src-gen/outModel.xmi : The object
> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1e3cd51 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@1833eca (name: Column)
> (instanceClassName: null) (abstract: false, interface: false))' is not
> contained in a resource.
>
>
> What exactly does it the setColumn function do (I have one such function
> existing for every 'attribute' in my metamodel) ?
> When I write c.attributs().createColumn(), does that mean that
> createColumn will be called for every object in the list returned by
> c.attributs ?


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [Xtend] constraint on existance [message #525373 is a reply to message #525323] Tue, 06 April 2010 08:11 Go to previous message
Eclipse UserFriend
I had forgotten the containment value.

Sorry.
Previous Topic:[Acceleo] Set type as parameter
Next Topic:[Announce] MoDELS 2010 Call for Papers
Goto Forum:
  


Current Time: Sat Jul 19 20:21:06 EDT 2025

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

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

Back to the top