2

I have some models with date attributes and I want to include ocl for validation and derivation.

Searching on the internet I found some articles and papers referring to date.isBefore(date) or date.before(date) methods but these methods are not recognized in OCL.

Additionally I would like to define derivation such as derivation: endDate + 10;.

Do I have to redefine a Date class with all methods I need ?

Any material or link related to it is welcome.

Sergio Correa
  • 171
  • 1
  • 9

1 Answers1

0

Given that OCL does not define Date, the authors' should have gone the long way round in order to formally define isBefore (and pages are a scarce resource in academic writing ;)

A few “primitive types” including numbers and strings are predefined in UML [RJB98*, p. 394]. The availability of other types like date and money is “system-dependent”. In any case, the semantics of primitive types has to be defined outside UML. (Richters Mark. A Precise Approach to Validating UML Models and OCL Constraints, Universität Bremen, p. 33, 86)

[RJB98] Rumbaugh, Jacobson, and Booch. The Unified Modeling Language Reference Manual. Addison-Wesley, 1998.

While I'm not proficient in EMF, According to this link any Java datatype can be used in your models by declaring it as the instance type of an EDataType for your Ecore model. (See also this reference)

Javier
  • 12,100
  • 5
  • 46
  • 57
  • 1
    I came across these references already but it does not make things clear. Although I have declared new `EDataType` using `java.util.Date`, within OCL, operations such as `>=`, `<` or methods like `data.before(old_data)` are not recognized. Anyway, I really appreciate your help. – Sergio Correa Feb 25 '15 at 19:35