Skip to main content



      Home
Home » Modeling » OCL » OCL expression not evaluated(oclIsUndefined works in a loop but not in ->select(exp) or exists->select(exp) )
OCL expression not evaluated [message #1841901] Wed, 02 June 2021 10:57 Go to next message
Eclipse UserFriend
Hi,

I want to use OCL in Acceleo.

I have an OrderedSet of an EClass called OutputSection.
OutputSection has an Feature called Memory.

If I iterate trough the OrderedSet I am able to use oclIsUndefined
[for (os : OutputSection | OutputSections())]
	[if (os.Memory.oclIsUndefined())]
		- Outputsection [os.name/] is not associated with memory
	[/if]
[/for]


If I use oclIsUndefined in a select or exists statement, it is ignored. Exists always returns false.
	OutputSections()->exists(Memory.oclIsUndefined())

I use the same approach a lot in the same project and never experienced this behavior.

OCL versions:
index.php/fa/40578/0/


For now I solved this issue by passing the OrderedSet to Java:
[query public Consistency_OsWoMem(rootModel : MulticoreRootModel) : Boolean = 	invoke('ReportGen.requests.generationServices', 'Consistency_OsWoMem(java.util.List)', Sequence{OutputSections()->asSequence()}) /]

	public boolean Consistency_OsWoMem(java.util.List<safetySystem.Linkage.OutputSection> ListOs)
	{
		for (safetySystem.Linkage.OutputSection outputSection : ListOs) {
			if(outputSection.getMemory()==null)
				return true;
		}
		
		return false;
	}
  • Attachment: OCL_v.JPG
    (Size: 30.57KB, Downloaded 351 times)

[Updated on: Wed, 02 June 2021 11:38] by Moderator

Re: OCL expression not evaluated [message #1841913 is a reply to message #1841901] Wed, 02 June 2021 17:03 Go to previous message
Eclipse UserFriend
Hi

2018 is a bit old, but since Acceleo re-uses the Classic OCL which is pretty stable it is unlikely to make a difference,

When I evaluate

OrderedSet{1,null,2,null}->select(oclIsUndefined())->size()


in my workspace the result is 1 as I would expect. This suggests that null is working consistently.

Perhaps the Acceleo wrapping is malfunctionality.

More likely you are not actually doing what you think you are. Unless you can empathize the bug you will need to use a debugger.

In the absence of a repro, my best guess is that OutputSections() does not return what you expect and that your plumbing via invoke has performed a corrective conversion.

Regards

Ed Willink

[Updated on: Wed, 02 June 2021 17:04] by Moderator

Previous Topic:Issue with mdt-ocl-Update sites
Next Topic:Calling an EMF Java function from OCL constraint
Goto Forum:
  


Current Time: Sun Jul 06 06:21:03 EDT 2025

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

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

Back to the top