0

I am trying to get this calculation to work in OCL, it has to say that if there is a cancelation present, it should give 'geannuleerd' and if there is a betaaldatum present it should give 'definitief'. My question is: I need for this if-else-then statement a boolean, but I can't find out whether self.annuleringsdatum-> notEmpty() is enough or that there should be an = TRUE behind it.

What I have now is underneath, if you know whether this should work or whether the boolean statement is not correct yet, please answer :)

ontext Reservering::status
derive:     if  self.annuleringsdatum -> notEmpty() 
then    self.status = 'geannuleerd'
if  self.betaaldatum -> notEmpty()
then    self.status = 'definitief'
else    self.status = 'voorlopig'
endif

1 Answers1

0

Certainly not "= TRUE" unless "TRUE" is defined by your metamodel. You could do "= true" if you like typing, but it is redundant since notEmpty() has a Boolean return type. I suspect that you are being confused by the nested "if"s that each require their own "endif". (Eclipse OCL prototypes an "elseif" that would make your example more readable and the multiple "endif"s unnecessary.)

Ed Willink
  • 1,205
  • 7
  • 8