I am attempting to get an array of object Occurrences on a model that are of certain types. I have defined the types in an array. However, the ObjOccListFilter only seems to allow one type, and not an array. I'm not able to use the ObjDefListByTypes routine due to symbol types used later in the report.
Anyone have a nifty work-around, or am I missing something?
Just to check if I got this right:
The "int[]" needs to contain a list of symbol numbers. These numbers can be found in the Configuration view of ARIS Architect.
If you for instance want to include the symbols for Application system type, ARIS model and Artifact, then it would look like this:
ObjOccListBySymbol([33, 248, 1596]);
Thanks very much!
To explain, I want to get the Object Occurrences of a set of type numbers defined in an array (Constants.OT_FUNC, etc.), irrespective of symbol type. At a later stage in the loop I need to filter out a specific symbol type, which is why I need to work with the Object Occurrences, not definitions. However, there is no ObjectOccListByType function, and the ObJectOccListFilter only allows for a single object type rather than a set.
I have managed to get it to work by hard-coding in the object types, but that's 2nd prize.
Dieter
In case you ever run into a situation where you want to filter an array of object occurrences (e.g. the result of a previous filter operation) you can also define a filter function like
/**
* Filters an array of object occurrences with an array of object type numbers
* @param {ObjOcc[]} objOccsArr - an array of unfiltered object occurrences
* @param {ObjOcc[]} objTypeNumbersArr - an array of permitted object type numbers
* @return {ObjOcc[]} - the filter result
**/
function objOccListFilterMultipleTypes(objOccsArr, objTypeNumbersArr) {
var typeNrFilterSet = new java.util.HashSet(); //using HashSet for O(1) constant lookup times
for each (var objTypeNumber in objTypeNumbersArr) {
typeNrFilterSet.add(objTypeNumber); //add the type numbers to HashSet
}
/**
* Returns whether the type number of an occurrence exists in the previously defined typeNrFilterSet
* @param {ObjOcc} someOcc - occ whose object type should be evaluated
* @return {boolean} - true if the passed object occurrence has a permitted object type, otherwise false
*/
function filterOccWithTypeNumFilterSet(someOcc) {
return typeNrFilterSet.contains(someOcc.ObjDef().TypeNum());
}
return objOccsArr.filter(filterOccWithTypeNumFilterSet);
}