Requirement allocation

Hello guys. How to get the source elements/target elements of a requirement’s incoming links/outcoming links with m2doc?

If you start from the Requirement itself, you will need to add needed nsURIs to your template using the template properties wizard:

The last one might change depending on the version of ReqIf you are using. But you should see something similar in the list.

Then you can use the following for incoming links:

requirement.eInverse('target')->filter(CapellaRequirements::CapellaOutgoingRelation).source

and for outgoing links:

requirement.ownedRelations->filter(CapellaRequirements::CapellaIncomingRelation).target

You can also use the following for incoming requirements from a CapellaElement:

capellaElement.eInverse('target')->filter(CapellaRequirements::CapellaIncomingRelation).source

and for outgoing requirements:

capellaElement.ownedExtensions->filter(CapellaRequirements::CapellaOutgoingRelation).target
2 Likes


Hi! There’s error in my genereated file. How to avoid it?

There is no cross referencer installed, the cross referencer is used by the eInverse() services and is used has a cache. It should be installed by Sirius (the technology providing graphical representation to Capella). You can ask M2Doc to install its own by adding the following option to your generation conficuration (.genconf file):

  • InstallCrossReferenceAdapter true

You should not have to do this in the context of Capella… Maybe if your requirement is not attached to the Capella model or its resource is not a semantic resource form Sirius it can happen.
Activating this option can have an impact on the performance depending on the size of your Capella model.

1 Like

image
hello! It seems that when the capellaElement is the diagram, error occurs.
how to get the requirement if the capellaElement is the diagram?

I think you need to add Sirius metamodels in your template. Open the template properties wizard on your template and use the nsURI tab to add all nsURIs containing sirius.

1 Like


after I add all sirius service, an extra variable occurs and it is the variable I defined in my template, but now it turns into a fixed value. How to delete it?



After adding these services, I still can’t get the elements.

The .genconf wizard use the list of variables declared in the referenced template. And the template properties wizard compute variables from used varaibles in AQL expressions inside the template. So to remove a varaible you just need to stop using it in the template.

To edit the varaible value in the .genconf, you can select the variable and use the edit button.

And I think since you are on a diagram, you should not need the eInverse() call:

not diagram.target->filter(CapellaRequirements::CapellaIncomingRelation).source->isEmpty()
1 Like

Thank you! So how to get the allocated elements of a diagram?
I tried target->filter(CapellaRequirements::CapellaIncomingRelation),but nothing will be left.


I find that diagram can’t be selected if I start from requirements.

You can list visible elements of a diagram:

.representationElements->select(de | if de.oclIsKindOf(diagram::DDiagramElement) then de.visible else true endif).target

Not sure for the requirement part, but you can try eInverse() to see if a requirement shows up and then only select elements with at least one element from the requirement metamodel.