Context:
I've created a stereotype to extend Class entity with new properties, e.g. new entity is Risk and it has properties Probability and Severity of type float. I'm also adding a derived property named Magnitude through Risk customization.
Problem:
I want to calculate value of Magnitude automatically based on other properties values, i.e. Magnitude = Severity * Probability. Somehow I feel that OCL should do the job, however I'm unable to figure out how to make it work. I even tried to set OCL expression of derived property to 'self = 0.1', hoping to see that every Risk instance has Magnitude automatically set to 0.1, but it didn't work - value was undefined.
Question:
is it even possible to calculate arithmetic value of derived property using OCL? Or maybe there is even more simple solution?
Thanks!