UML 2.4.1 RTF Avatar
  1. OMG Issue

UML241 — All single query operations in the spec defined in OCL invalid ?

  • Key: UML241-44
  • Legacy Issue Number: 7550
  • Status: open  
  • Source: Simula Research Laboratory ( Dr. Bran Selic)
  • Summary:

    This seems rather serious, but perhaps some OCL FTF person will reassure me that it's not:

    The UML 2 Superstructure spec defines additional query operations for a number of metaclasses. For example, the following query is defined for the metaclass Element:

    Element::allOwnedElements(): Set(Element);
    allOwnedElements = ownedElement->union(ownedElement->collect(e | e.allOwnedElements()))

    Another example is the query defined for ProtocolTransition:

    context Region::belongsToPSM () : Boolean
    result = if not stateMachine->isEmpty() then
    oclIsTypeOf(ProtocolStateMachine)
    else if not state->isEmpty() then
    state.container.belongsToPSM ()
    else false

    Notice the different forms used to define these two queries. The first one uses the name of the operation to store the result while the second uses the OCL reserved word "result". In the spec, there many queries that use the first form and only three cases of the latter form.

    A review of the OCL spec with respect to this issue – as far as I can tell – indicates that there are three valid ways of specifying a query as shown by the following two examples:

    (1) using body expressions (note the 'body:' prefix in the second line):

    context Element::allOwnedElements(): Set(Element);
    body: ownedElement->union(ownedElement->collect(e | e.allOwnedElements()))

    (2) using postconditions (note the use of the reserved word 'result' following the 'post:' prefix):

    context Element::allOwnedElements(): Set(Element);
    post: result = ownedElement->union(ownedElement->collect(e | e.allOwnedElements()))

    (3) using auxilliary definitions (note the 'def:' prefix in the second line):

    context Element
    def: allOwnedElements(): Set(Element) = ownedElement->union(ownedElement->collect(e | e.allOwnedElements()))

    Unfortunately, neither of the two forms used in the spec conform to any of these formats, which seems to imply that every single query operation in the spec that is defined in OCL is invalid! There are 73 such queries at the moment.

    Can someone from the OCL team shed light on this?

  • Reported: RAS 2.0b1 — Thu, 17 Jun 2004 04:00 GMT
  • Updated: Sun, 8 Mar 2015 14:12 GMT