Hello Everybody,
sometimes build-in attributes (e.g. artifacts of a StaticChecklistItem), user-defined properties or also helper methods like mediniGetOpposites are giving you a list of elements of different types. With OCL the select-operator for collections is a handy feature to shrink the list to the types which you want to have:
self.mediniGetOpposites('safetyGoal')->select(s| s.oclIsKindOf(dc::DCWorksheet))
This will give you the sequence of all DC Worksheets which are point to a safety goal (and filters out e.g. any other elements like Hara entries which point also to that goal.
If you use JavaScript, a similar behavior can be achieved by using the filter-function of JS Array - you just need to convert the JS list to an array before:
var sheets = self.mediniGetOpposites("safetyGoal").toArray().filter(function (e) {return e instanceof Metamodel.dc.DCWorksheet});
Of course you can define the filter function also based on other criteria.
Happy Scripting
Eckhardt