Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Thomas Arnbjerg on November 04, 2023, 01:48:48 am

Title: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Thomas Arnbjerg on November 04, 2023, 01:48:48 am
I have a a class with the attributes 'left', 'right', 'middle' as seen in the project explorer.

When I iterate over the attributes in Java script the order is 'left', 'middle', 'right'.

Is there a way to avoid this?? - It basically blows up my ability to autogenerate serialization/deserialization code for classes.
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Geert Bellekens on November 04, 2023, 02:10:07 am
Yes, if you Ctrl+Arrow UP on an attribute in the Features window, you'll get a popup message asking if you want to disable alphabetic sorting.

Geert
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Farkas on November 06, 2023, 08:39:33 pm
Hi,

Another way: Start | Appearance | Preferences  -> Object -> untick 'Sort Features by Stereotype' (in the right column)
I hope this will effect javascript iteration as well, not just the appearance on the screen.

Farkas
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Thomas Arnbjerg on November 07, 2023, 12:13:24 am
Thanks for the suggestions.

The order of attributes in Java Script seems to be always alphabetical - i.e. does not necessarily match the presentation order in EA.
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Farkas on November 07, 2023, 09:43:17 pm
Maybe you can try sorting it by EA.Attribute.Pos field.
(https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/attribute.html)

Farkas
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Thomas Arnbjerg on December 11, 2023, 08:31:13 pm
I think this issue is also related to the master-replica implementation. We work in replicas, which are synchronized with the master. The retrieval order follows the insertion order in the database so if synchronization order adds new elements to the master in a different order than the insertion order in the replica the retrieval order is different in the master. This is propagated to any new replicas.
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Geert Bellekens on December 11, 2023, 09:44:45 pm
I think this issue is also related to the master-replica implementation. We work in replicas, which are synchronized with the master. The retrieval order follows the insertion order in the database so if synchronization order adds new elements to the master in a different order than the insertion order in the replica the retrieval order is different in the master. This is propagated to any new replicas.
Don't do master-replica.

Use any other method, but don't user master-replica.

Geert
Title: Re: Is it possible to disable alphabetic sorting?? - blows up my autogenerated code
Post by: Paolo F Cantoni on December 11, 2023, 09:48:48 pm
I think this issue is also related to the master-replica implementation. We work in replicas, which are synchronized with the master. The retrieval order follows the insertion order in the database so if synchronization order adds new elements to the master in a different order than the insertion order in the replica the retrieval order is different in the master. This is propagated to any new replicas.
Don't do master-replica.

Use any other method, but don't use master-replica.

Geert
Wot' 'e sed!

Think of Geert as Yul Bynner in that famous ad he made just before he died...  "Whatever you do, don' smok!"

Paolo