eclipseumlqvt

How to get an OrderedSet of OccurrenceSpecifications from a Lifeline in QVTo?


From the diagram on page 570 of the UML spec I concluded that a Lifeline should have the events property, holding an OrderedSet(OcurrenceSpecification). Unfortunately it is not there, at least in the QVTo implementation that I use.

All I have is the coveredBy property, serving me with an (unordered) Set(InteractionFragment). Since my transformation relies on the correct order of MessageOcurrenceSpecification I somehow need to implement myself what I expected to be implemented by the missing events property.

This is what I have so far:

helper Lifeline::getEvents (): OrderedSet(OccurrenceSpecification) {

    return self.coveredBy->selectByKind(OccurrenceSpecification)->sortedBy(true);
}

Obviously sortedBy(true) does not get me far, but I don't know any further. Who can help?

All I could find so far were other people struggling with the same issue years ago, but no solution:


Solution

  • Based on the answer by Vincent combined with input from a colleague of mine I came up with the following solution for QVTo:

    -- -----------------------------------------------------------------------------
    -- Polyfill for the missing Lifeline::events property
    
    query Lifeline::getEvents (): OrderedSet(OccurrenceSpecification) {
    
        return self.interaction.fragment
                ->selectByKind(OccurrenceSpecification)
                ->select(os: OccurrenceSpecification | os.covered->includes(self))
                ->asOrderedSet();
    }