Book a Demo

Author Topic: MDG and auto number  (Read 3985 times)

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
MDG and auto number
« on: June 04, 2020, 07:56:19 pm »
Hi
I am developing a MDG profile and an element within it is called Goal and extends the Activity element.
What I am hoping to achieve is that when users of the MDG create a Goal element the name should be auto numbered and be of the for G1, G2 etc.
Is this possible?

Thanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: MDG and auto number
« Reply #1 on: June 04, 2020, 08:01:05 pm »
IIRC: Yes. There's a setting for element numbering (depends on your version where...). You need to have a _metatype set for your goal and that will determine the numbering scheme.

However, depending on your configuration the number will not necessarily be unique and you have to take additional measures (like script/add-in).

q.

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
Re: MDG and auto number
« Reply #2 on: June 04, 2020, 08:34:04 pm »
Thanks for your reply
I have imported the profile into a model but my Goal element does not appear in the Type field of the  Auto Name Counters dialog
Is it supposed to?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: MDG and auto number
« Reply #3 on: June 04, 2020, 09:24:39 pm »
My bad. Should have looked before :-/ The drop down only contains a predefined set and does not include own metatypes. However, if you create new elements they appear as <metatype><num> where num is sequenced from 1. You will need some add-in to make your naming follow other rules.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: MDG and auto number
« Reply #4 on: June 04, 2020, 09:29:19 pm »
P.S. I looked into my Inside book and it notes that t_trxtypes has autocounter info which might be used. Will test later...

q.

P.P.S Does not seem to work. You can extend the list of auto-counters by adding values to t_objecttypes. But when applying them - nothing happened. So, add-ins are needed.
« Last Edit: June 04, 2020, 10:03:30 pm by qwerty »

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
Re: MDG and auto number
« Reply #5 on: June 05, 2020, 06:07:54 pm »
Hi
Thanks for that.

I have some experience of addins but do not know how I would keep track of the numbering over different EA sessions

Do you know a method?

THanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: MDG and auto number
« Reply #6 on: June 05, 2020, 06:58:48 pm »
Well, I'd probably just use the entry in t_trxtypes which defines the format and the current number. You can get almost unique numbers that way, but not for 100% (like EA could not).

So what you need to do is to run a regular cross check and a manual rework of found duplicates. There should not be many in any case (depending on the configurations it's more and more unlikely). But you must not neglect it. That's the main point.

You could even run a cross check for duplicates each time you create a new number at little cost (SQL can do that efficiently).

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG and auto number
« Reply #7 on: June 05, 2020, 07:13:55 pm »
It's fairly simple to get the maximum number of a certain type of element using an SQL Query, and then add 1 for the next one.

If you put the ID in something like the alias, or a tagged value it is really easy.
If you choose to put the ID somewhere in the name like

"UC - 001 - Some functional Name"

Then you'll have to parse the '001' out of the name, but still quite doable and really fast in SQL.

You can make your life a whole lot easier if you always pre-pend your ID's with zeroes ('0015' instead of '15') as that will allow you to use alphabetic ordering.
Otherwise you'll have to convert the ID strings to a numeric format like integer an then do a max()

Geert

GrahamL

  • EA User
  • **
  • Posts: 111
  • Karma: +2/-0
    • View Profile
Re: MDG and auto number
« Reply #8 on: June 05, 2020, 09:25:30 pm »
Thanks everyone