Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OCL at0 operator syntax error

Tags:

ocl

Working on a timereport project in MDriven and I have created an instance where an employee has worked ten hours. The Employee class's "attribute.type" is of "timespan" for "HoursWorked".

action:
Employee.create
Employee.allinstances->at0(0) .HoursWorked:= 10:00:00

This code gives me a syntax error. Is the at0 not functioning with "timespan"? If so, which expression should be used in this case to create a certain timespan?

Also, if anyone knows a good, informative wiki with all the OCL expressions and how to correctly write syntax that would be much aprreciated.

like image 935
Gustaf Avatar asked Mar 08 '26 19:03

Gustaf


2 Answers

The issue is that the MDriven action language (based on OCL but with side effects allowed) requires you to separate statements with ;

Try:

action:
Employee.create;  -- notice that semicolon
Employee.allinstances->at0(0).HoursWorked:= TimeSpan.Create(10,00,00)  --NO ; on end statement
like image 190
Hans Karlsen Avatar answered Mar 10 '26 15:03

Hans Karlsen


This question is titled OCL and so the following answer applies:

There is no allinstances in OCL; it is allInstances().

There is no at0() in OCL; it is at() and since OCL is a specification language indexes are 1-based, so a 0 index is invalid.

The OCL expressions and library operations are available in the OMG specification or the online Eclipse help: http://help.eclipse.org/oxygen/topic/org.eclipse.ocl.doc/help/StandardLibrary.html?cp=74_2

However it is clear that you are actually using a non-standard OCL embedded presumably in MDriven, so answers applicable to OCL may not be relevant.

like image 44
Ed Willink Avatar answered Mar 10 '26 16:03

Ed Willink



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!