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 …”
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.
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)
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:
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?