Requirement VP Semantic Browser queries for M2Doc

One of the advantages of Capella is the definition of Test Cases as Capabilities or Capability Realizations tracing involved requirements.

Unfortunately there are no M2Doc extensions for the VP Requirement Addon Semantic Browser.

I am working on a small addon implementing missing queries.

There is a minor issue related the activation of the visualization of requirements in the Semantic Browser

image

If it is not activated, associated M2Doc queries are not working.

For sake of completeness, please find below the list of implemented services, with corresponding semantic browser query:

  • myCapellaElement.getAllocatedRequirements() → Allocated Requirements in “Referenced Elements”
  • myCapellaElement.getAllocatingRequirements() → Allocating Requirements in “Referencing Elements”
  • myRequirement.getReferencedByInternalRelation() → Internal Relation in “Referenced Elements”
  • myRequirement.getReferencingByInternalRelation() → Internal Relation in “Referencing Elements”*
  • myAttributeDefinition.getDataType() → Data Type in “Referenced Elements”
  • myRelationType.getRelations() → Relations in “Referencing Elements”

Hello,

thanks for pointing out this thread.

May I ask if you can elaborate more on the “selection” variable you are using to make the query? My self variable does not seem to have the getAllocating/Allocated Requirements method available.

Also, I am not able to visualize Requirements allocation in my semantic browser either. Maybe because I am missing the selected R icon you are showing?

This is the list of icons I have next to the Project explorer tab

image

Thanks in advance for any help!

Hi,

Did you install the requirement addon ?

Yes, I did :slightly_smiling_face:

You should see the R icon in the semantic browser view:

As an alternative to the semantic browser queries, you can use services listed above by @pge62. To have access to those services, you will need to select the Capella package in the template properties wizard.

With M2Doc addons for Capella 7.0.1 you can also call semantic browser queries (see EObject.availableSBQueries() : Sequence{String} and EObject.getSBQuery(String) : Sequence{EObject}).

Thanks, I see that now :slight_smile:

Many thanks also for the feedback on the queries, I’ll have a look :slight_smile:

1 Like

Looks like I have it selected

But still not able to access the service listed in @pge62 post

If I go next on the template properties wizard, that is what I got

Should I select a different variable type?

If you edited your template properties after opening the M2Doc interpreter view, you might need to refresh the template in the view. You can use the yellow arrows button to do so.

I did, but still no luck :confused:

Just for completeness, I am using Capella 7.0.0 and M2Doc version 3.3.4

The method getSBQuery is not available in M2Doc 3.3.4. You should move to version 4.0.0.

I updated both Capella version (to 7.0.1) and M2Doc version to 4.0.0

It seems I was successfully able to migrate my old project to the new version (right click on Project folder in the Project explorer, then Migration->Migrate Project toward current version).

I also installed RP and M2doc add-ons (M2doc version 4.0.0), but it seems in no way I am able to set the M2doc variable. This is what I get from the docx template properties (empty list of variable names)

And also Load resource from the template wizard will have no effect (similarly to what happens in this thread: Creating Variables for Imported Templates with M2Doc)

I tried adding also all nsURIs but seems with no effects.

Do you have any suggestions?

Thanks!

For completeness, this is the list of sw installed within Capella

You probably need to migrate your template. M2Doc statements are now in plain text (not MS Word fields).

Many thanks for your patience, I was able to set the variable now!

Still not sure how to perform the query posted at the beginning of the thread, starting from my self variable and the getSBQuery method.

In the semantic browser shown also by @pge62 at the beginning of this thread (which I report below), I would need the Allocating req

This was as far as I could get

In the link @YvanLussaud was pointing above, it is talking about specifying an EObject and a query name, but can’t really figure out by myself exactly what they are

The EObject is any element from your Capella model. In your case it’s the Capella element you want to retreive requirements from. The String is the query name shown in bold in the semantic browser view. May sure you enabled requirements queries in the semantic browser then you can use the M2Doc interpreter view and select an element from your model:

selection.getSBQuery('Allocating Requirements')

You can change the selection or the name of the query for testing purpose.

I am sorry, I am really new to this and maybe also not very good at understanding.

I just figured out that I have a “selection” variable (which I thought was a user defined alias for self), besides the “self” one and maybe still missing some settings?

What I need at the end btw is to put these queries in a word template to build up a traceability matrix.
Not quite sure at this point, if what we are trying to achieve here is also that or just getting info from currently selected elements within the Semantic browser

The selection variable is defined by the M2Doc interpreter view to bind the current selection. This is useful for testing. When you have something that works for you, you can navigate to this Capella element in your template to execute the same AQL expression. You can also test this expression in the M2Doc interpreter view.

Let say your self variable is the root SystemEngineering and you want to access the root LogicalComponent, you can use the following expression:

self.ownedArchitectures->filter(la::LogicalArchitecture).ownedLogicalComponentPkg.ownedLogicalComponents

AQL use any Ecore metamodel to navigate a model conforming to this metamodel. For Capella most metamodels are available here. You can also use the content assist from the M2Doc interpreter view. And you can access the metamodel of an element (self.eClass()) to get the list of all references and attributes available for that object.

self.eClass().eAllStructuralFeatures

If you are more familiar with Java you can also use the Java code generated by EMF which has the same structure as the metamodel.

The AQL documentation.