M2DOC Requirements Folder

Hi everyone,

I’m having real difficulty exporting a set of requirements contained within a requirements folder and I was hoping someone might know what command(s) to use. I seem to be able to extract the list of requirements using the Sirius interpreter, but the command fails in M2Doc. It doesn’t appear to like the .ReqIFLongName = ‘Folder 1’ used on the requirements folder and returns a very long list of errors of the sort “Feature ReqIFLongName not found in EClass …”

I’m using:
Capella 5.1.0
M2Doc 3.2.1
Requirements VP add-on

Below is a diagram of my project structure


Here’s the commands I’m using:
Sirius interpreter:
aql:self.containedSystemAnalysis.eAllContents()->select(a | a.ReqIFLongName = ‘Folder 1’).eAllContents()->filter(Requirements::Requirement).ReqIFText

m:self.containedSystemAnalysis.eAllContents()->select(a | a.ReqIFLongName = ‘Folder 1’).eAllContents()->filter(Requirements::Requirement).ReqIFText

If I don’t include the statement “->select(a | a.ReqIFLongName = ‘Folder 1’).eAllContents()” it works, however, it exports requirements across all folders as expected. I only want those from Folder 1.

I’m a relative newbie when it comes to M2Doc so please be explicit in you responses.

Many Thanks!

So in classic fashion, I spent the best part of a day and half trying to figure this out and the moment I post to the forum I solve it.

I think in my original M2Doc command it was assessing the ReqIFLongName attribute of every element in the System Analysis section of the model. Not every element has a ReqIFLongName attribute, however, and it was throwing an error for every element which is why I was getting a lot of errors. By filtering for requirements folders first and then selecting the one that had the ReqIFLongName = ‘Folder 1’ it worked.

Here’s the amended command:
m:self.containedSystemAnalysis.eAllContents()->filter(Requirements::Folder)->select(a | a.ReqIFLongName = ‘Folder 1’).eContents()->filter(Requirements::Requirement)

1 Like

Yes the filter is needed because the service eAllContents() returns a collection of EObject and this EClass doesn’t have an EAttribute name. A more efficient way to do this would be:

self.containedSystemAnalysis.ownedExtensions->filter(Requirements::Folder)->select(a | a.ReqIFLongName = ‘Folder 1’).ownedRequirements

This use EReferences defined in the Capella metamodel and requirement metamodel.

1 Like

Hi Yvan,

Thanks for your reply. I’m all for learning more efficient ways of extracting the data. Some of these models can get quite large and running a for loop across essentially every element in the model is not good!

I did have an issue with your code however. As written, although it ran without error, it didn’t return any data. Please correct me if I’m wrong, but I think the .ownedExtensions statement simply returned the fact that I’m using the requirements VP and not its actual contents. When I modified the code as per the following, that then returned the data. I this what you expect or have I missed something?

self.containedSystemAnalysis.ownedExtensions.eContents()->filter(Requirements::Folder)->select(a | a.ReqIFLongName = ‘Folder 1’).ownedRequirements

Yes I forgot a level with the requirement module:

self.containedSystemAnalysis.ownedExtensions->filter(Requirements::Module).eContents(Requirements::Folder)->select(a | a.ReqIFLongName = ‘Folder 1’).ownedRequirements

You can also apply the filter directly to eAllContents() or eContents() as shown above.

Brilliant. Thank you :slightly_smiling_face:

1 Like