Opposite of "target"

Hello,
let’s take the following example:


The requirement on the diagram level is a NodeList, using “target” will return the actual element (requirement).
I am tring to obtain the NodeList from the requirement.
I have tried the followings:

selection.eInverse('target')

No result. The M2DOC interpreter shows nothing.

selection.eInverse(viewpoint::DRepresentationElement)

Same result.
I tried other iterations such as :

selection.eInverse(viewpoint::DRepresentation)
selection.eInverse(viewpoint::Representation)
selection.eInverse(viewpoint::DRepresentationDescriptor)
selection.eInverse(viewpoint::DView)

Same thing.

How should I proceed? Thanks.
Ps. i am using 3.1.0

In the context of Sirius, M2Doc reuse the crossreferencer installed by Sirius to implement eInverse(). This crossreferencer only reference semantic cross references and not semantic to diagram references.

You have two options here:

  • tell M2Doc to install its own crossreferencer by setting the InstallCrossReferenceAdapter option to true in the generation configuration (the .genconf file). This can can be time consuming depending on the size of your model.

  • You can use the following expression to get the representations a semantic element is visible on:

    viewpoint::DRepresentation.allInstances().representationElements->select(re | re.target = semanticElement)
    

    This expression can also be time consuming, you probably want to cache the result using a let statement if you plan to use the result more than once.

1 Like

How is that time consuming? Does it require actually further configurations other than adding this?
image

Something like that?
m:let Z=viewpoint::DRepresentation.allInstances().representationElements->select(re | re.target = ‘Requirements::Requirement’)
m:let T=viewpoint::DRepresentation.allInstances().representationElements->select(re | re.target = ‘diagram::DNodeList’)

It’s time consuming at generation time. M2Doc will install a new crossreferencer that will need to compute all cross references in the model. But it might not be an issue in your case.

The semantic element needs to be a model object not a String, in your example it was the selection. Of course you can adapt the condition according to your needs. If you want to select on the type you can use:

viewpoint::DRepresentation.allInstances().representationElements->select(re | re.oclIsKindOf(diagram::DNodeList) and re.target = semanticElement)

If you want only representation element that are diagram::DNodeList and represent the given semantic element.

viewpoint::DRepresentation.allInstances().representationElements->select(re | re.target.oclIsKindOf(Requirements::Requirement))

If you want all representation elements that represent Requirements::Requirement.

1 Like