Book a Demo

Author Topic: Access lower/upper bound/multiplicity of param  (Read 6861 times)

b1256

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Access lower/upper bound/multiplicity of param
« on: March 21, 2013, 11:35:30 pm »
Hello,

How can I access LowerBound, UpperBound or Multiplicity of a parameter from code generation template?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #1 on: March 22, 2013, 08:34:26 am »
I don't think you can.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #2 on: March 22, 2013, 12:49:48 pm »
Wasn't it possible to call an add-in from inside the code gen (haven't iused that for a long time).

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #3 on: March 25, 2013, 08:57:24 am »
Yes, you can call an add-in (search for EXEC_ADD_IN,) but from what I can see it won't help you.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Access lower/upper bound/multiplicity of param
« Reply #4 on: March 26, 2013, 06:22:31 pm »
Even if those fields are not exposed in the API object you can still get them from the database using Repository.SQLQuery()

Geert

smither

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #5 on: March 26, 2013, 09:30:33 pm »
I see why using an add-in might be difficult!  This is another case of where the API does not support all the properties of the model - there is no API method or property to obtain the Multiplicity or the control of orderedness and uniqueness of a parameter.  In the database its squirreled away in the t_xref table (Qwerty .. it's time to document this beast, please), and can be got through an SQL query:
Code: [Select]
select x.Description
from t_xref as x, t_object as o, t_operation as op, t_operationparams as p
where o.Name = "<className>"
and op.Name = "<operationName"
and p.Name = "<parameterName>"
and x.Type = "parameter property"
and op.Object_ID = o.Object_ID
and p.OperationID = op.OperationID
and x.Client = p.ea_guid
which returns a string of the form:
Code: [Select]
@PROP=@NAME=lower@ENDNAME;@TYPE=Integer@ENDTYPE;@VALU=77@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=upper@ENDNAME;@TYPE=UnlimitedNatural@ENDTYPE;@VALU=99@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isOrdered@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=1@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isUnique@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=0@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
Then all you need to do is parse it!  (Or you could request that Sparx extend the api and the field substitution macros to cover this.)
« Last Edit: March 27, 2013, 02:24:15 am by smither »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #6 on: March 26, 2013, 10:43:07 pm »
Quote
Qwerty .. it's time to document this beast, please
It's a beast, you tell it. For that reason I did not dig too deep into t_xref. I still hope for a re-design of the database in some future EA version. But that will likely not be soon. In the meantime I'll take that and gather some more information about t_xref to put it into the book.

q.

b1256

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Re: Access lower/upper bound/multiplicity of param
« Reply #7 on: April 05, 2013, 09:10:01 pm »
Thank you all for your good suggestions and discussion!