YD

Hello Community,

I have encountered an interesting problem and I hope anyone could solve it.

I would like to get the object list in a model with the function ObjOccList.

The function could indeed get all the object back, but every time the the objects returned from the function are in different order. For example I have 3 objects in the model name"A,B,C". When I try to get the object with ObjOccList,

it will return "A,B,C" at the first time and "B,A,C" at the second time.

Is there any variable of this function that I could set to fix the order of the object?

Thank you in advance!

by Robert Goldenbaum
Badge for 'Question Solver' achievement
Posted on Fri, 02/01/2019 - 13:50

Hi,

no, this is not possible. You just have to sort the list - either according to name, or by Y-X position etc.

oObjOccList = ArisData.sort(oObjOccList, Constants.SORT_Y, Constants.SORT_X, g_nLoc)

0
by Kay Fischbach
Posted on Fri, 02/01/2019 - 14:10

The server doesn't take a list it has somewhere and hand it to you, instead you can imagine it like a bunch of files spread out on a desk (similar to your object occurrences sitting at different x and y coordinates in your model). When you call the method the server just stacks the files on top of each other, grabbing random ones from all over the table, and hands you the complete stack of files. It doesn't care about sorting them at all, all that matters for it is that is as fast as possible.

After you were handed the stack of paper (an array containing the object occurrences), you are the one that is responsible for sorting them. You can do so in two ways (as far as I know).

You can either use an ARIS method, ArisData.sort(...), which allows you to sort by certain criteria:

e.g.

var arrayNowSorted = ArisData.sort(selModel.ObjOccList(), Constants.SORT_X, Context.getSelectedLanguage());

 

Or you can go the JavaScript way of sorting an array containing objects, with a custom sorting method. This allows you to sort by basically any information of the objects you can somehow access. The Javascript way changes the original array, so assign it to a variable first.

e.g.

var soonToBeSortedArray = selModel.ObjOccList();

soonToBeSortedArray.sort(function(a,b){
    return a.X() - b.X()
});

For this example I used the X() method from the ObjectOcc class, but as I said earlier, you can use it to sort by anything. E.g. you could use a.ObjDef().Attribute(...).getValue() to get a value from an attribute and sort by that.

 

As far as I can tell, the ArisData.sort() method also accepts methods as arguments and you could do your custom sorting through that too.

 

0
by Ye Ding Author
Posted on Mon, 02/11/2019 - 16:27

Hi Kay and Robert,

you are right!

I have tried to sort the object and it now works as I expected!

Thank you!

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks
  • Profile picture for user frankweise
  • Profile picture for user Henrik Buckler
  • Profile picture for user UffeK
  • SS
  • MZ
  • PacMan

Leaderboard

|
Nobody has collected any points yet this week. This is your chance to become one of the top 5 on this week's leaderboard.
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock