Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: tweber on June 26, 2024, 05:24:57 am

Title: Class operation parameter types
Post by: tweber on June 26, 2024, 05:24:57 am
I have two classes, "Class1" with a single operation, "oper(param:Class2[0..*])", and Class2, which contains a single attribute, name:string.  I've tried to bind the type of the parameter, 'param', to Class2, but the fact that it's an array keeps it from binding.  I've not found any way to add multiplicity to the parameter param.  Need help with a way to bind Class2 with multiplicity to the parameter.   
Title: Re: Class operation parameter types
Post by: tweber on August 30, 2024, 05:16:27 am
Is there anyone who can tell me how to add multiplicity to an operation parameter type?
Title: Re: Class operation parameter types
Post by: qwerty on August 31, 2024, 08:33:22 am
I'd guess it's either or. If you select the type then you have no multiplicity. Or you use a string which does not reference a classifier. Alternatively you could model a class like list that represents sort of an array.

q.
Title: Re: Class operation parameter types
Post by: ea0522 on September 03, 2024, 03:41:27 pm
Have you tried using a connector between the parameter and Class2?
With connectors, you can define multiplicity on either end.
Title: Re: Class operation parameter types
Post by: Takeshi K on September 03, 2024, 06:18:58 pm
Hello tweber,

You can specify the multiplicity of parameters, but currently EA does not seem to support displaying the specified multiplicity like method(p1 : Class2[1..*]).

1. select the Class in the diagram
2. select the target operation in the Class (you can select an operation when you select the owing Class)
3. double-click the operation to open the propety dialog of the operation
4. you can specify the multiplicity from the Parameter group in the dialog



Title: Re: Class operation parameter types
Post by: tweber on September 03, 2024, 10:11:26 pm
I just got the answer from Sparx support.  I can't specify the cardinality (multiplicity) of a parameter in an operation.
Title: Re: Class operation parameter types
Post by: Geert Bellekens on September 03, 2024, 10:22:38 pm
I just got the answer from Sparx support.  I can't specify the cardinality (multiplicity) of a parameter in an operation.
Well, they are wrong. You can definitely enter the multiplicity of a parameter following the instructions of Takeshi

Geert
Title: Re: Class operation parameter types
Post by: tweber on September 04, 2024, 03:05:18 am
Agreed.  I can see the info in the t_xref table.  That said, I'm  trying to figure out how to access (or change) the same info in a jscript script.  Appreciate any help.  TIA.
Title: Re: Class operation parameter types
Post by: qwerty on September 04, 2024, 07:32:30 am
t_xref's content is only sparsely accessible from the API. In most cases a SQL query is the way to go. For manpulating it you have to fall back to repository.execute(<sql>). Always remember that this is like playing with an unsecured weapon. Know what you're doing and throughly test it in a playground first!

q.
Title: Re: Class operation parameter types
Post by: tweber on September 04, 2024, 09:27:08 pm
This is what I've determined so far.  The info I need is hidden within parameter.TypeInfoProperties. Each element within is a TypeInfoProperty.  I've accessed so far by indexing through TypeInfoProperties.items(i). The issue is that while I can access the TypeInfoProperty.Name, not all of the TypeInfoProperty.Value values appear (the booleans do, as well as 'direction', but the others appear as undefined values).  Again, TIA.
Title: Re: Class operation parameter types
Post by: qwerty on September 05, 2024, 06:24:26 am
I'm no more that deep in the matter since I'm retired (and tired of Sparx at all). I'll see if I can get up to digging into this once more.

q.
Title: Re: Class operation parameter types
Post by: philchudley on September 05, 2024, 09:01:00 pm
Here's what I found in t_xref for a test parameter multiplicity of 1..*

XrefID,Name,Type,Visibility,Namespace,Requirement,Constraint,Behavior,Partition,Description,Client,Supplier,Link,

{D8433594-6904-416a-B247-DA7EC76655B5},CustomProperties,parameter property,Public, , , , ,0,@PROP=@NAME=lower@ENDNAME;@TYPE=Integer@ENDTYPE;@VALU=1@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=upper@ENDNAME;@TYPE=UnlimitedNatural@ENDTYPE;@VALU=*@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=isUnique@ENDNAME;@TYPE=Boolean@ENDTYPE;@VALU=0@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;,{4E9BC795-3D5A-4eb7-A916-65648B6F004E},<none>, ,

The multiplicity encapsulated within the Description field is here:

@PROP=@NAME=lower@ENDNAME;@TYPE=Integer@ENDTYPE;@VALU=1@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;@PROP=@NAME=upper@ENDNAME;@TYPE=UnlimitedNatural@ENDTYPE;@VALU=*@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;

t_xref.Client is the GUID of the operation parameter

t_xref.Type = parameter property

So

1) Extract required row(s) from t_xref using a SQL Query
2) Split t.xref.Description into its parts using ; storing in a String[]
3) Extract the info you want from the String[] using subscripts (you can work out the value from the above example) ...


Hope this helps

Phil
Title: Re: Class operation parameter types
Post by: tweber on September 05, 2024, 10:27:58 pm
Appreciate the replies.  I've seen the t_xref output.  I'm trying to determine how to  modify this information in a script (jscript preferable, but I can probably determine the equivalent from a vbScript).  I'm concentrating on the TypeInfoProperties class, as parameter appears to hold the lowerBound and upperBound info there.  I've tried to output in a jscript, but appear to be missing something.
Title: Re: Class operation parameter types
Post by: qwerty on September 06, 2024, 06:52:42 am
You can use repository.execute("UPDATE ..."). This is an undocumented feature but it works. In ordrer to create new entries you can use any GUID generator where needed.

Again: this might clobber your DB so test in a sandbox extensively!

q.
Title: Re: Class operation parameter types
Post by: tweber on September 06, 2024, 09:09:08 pm
If it were for me, I wouldn't worry about using an undocumented feature.  However, I can't chance blowing up the model we have.  There has to be a way to do this using parameter attributes.
Title: Re: Class operation parameter types
Post by: Geert Bellekens on September 06, 2024, 09:50:44 pm
If it were for me, I wouldn't worry about using an undocumented feature.  However, I can't chance blowing up the model we have.  There has to be a way to do this using parameter attributes.
Not every aspect of the EA model is exposed in the API. For some things you don't have any other choice.
If you know what you are doing and test properly it should be OK.
Not sure if this is one of those cases though. I'll have a closer look when I find the time..

Geert
Title: Re: Class operation parameter types
Post by: Geert Bellekens on September 07, 2024, 12:03:49 am
I did a bit of digging and wrote a small test script

Code: [Select]
function testParameterMultiplicity()
dim operation as EA.Method
set operation = Repository.GetMethodByGuid("{BDE09079-D60A-4cf8-93AA-01057665DC9C}")
dim parameter as EA.Parameter
for each parameter in operation.Parameters
Session.Output "Parameter name: " & parameter.Name
dim i
for i = 0 to parameter.TypeInfoProperties.Count -1
dim propertyItem as EA.TypeInfoProperty
set propertyItem = parameter.TypeInfoProperties.Items(i)
dim propertyValue
propertyValue = propertyItem.Value
Session.Output "property name: " & propertyItem.Name & " property value: " & propertyItem.Value
next
dim updated
updated = parameter.TypeInfoProperties.SetProperty("lowerValue", "0")
Session.Output "updated lowerValue: " & updated
updated = parameter.TypeInfoProperties.SetProperty("isOrdered", "True")
Session.Output "updated isOrdered: " & updated
next
end function

The results in the Session output:

Code: [Select]
[26893073]      Parameter name: param1
[26893094]      property name: direction property value: in
[26893102]      property name: effect property value:
[26893110]      property name: isException property value: False
[26893118]      property name: lowerValue property value:
[26893127]      property name: name property value:
[26893134]      property name: isOrdered property value: True
[26893142]      property name: isStream property value: False
[26893150]      property name: type property value:
[26893159]      property name: isUnique property value: True
[26893166]      property name: upperValue property value:
[26893179]      property name: visibility property value:
[26893186]      updated lowerValue: False
[26893191]      updated isOrdered: True

As you can see there is a lowerValue and a upperValue property, which I assume was meant to represent the lowerBound and upperBound of the multiplicity of the parameter, but unfortunately these properties always return an empty string.
Trying to update them using this properties object doesn't work either. (as opposed to the isOrdered property, which I can update just fine)

I consider this a bug that should be reported to Sparx.
In the meantime, I'm afraid there's no alternative to using Repository.SQLQuery() (for reading) and Repository.Execute() (for updating)

Geert
Title: Re: Class operation parameter types
Post by: tweber on September 07, 2024, 12:38:28 am
I was getting something for the TypeInfoProperties collection in JScript.
param TypeInfoProperty Name : direction
param TypeInfoProperty Value: in
param TypeInfoProperty Name : effect
param TypeInfoProperty Value:
param TypeInfoProperty Name : isException
param TypeInfoProperty Value: false
param TypeInfoProperty Name : lowerValue
param TypeInfoProperty Value: undefined
param TypeInfoProperty Name : name
param TypeInfoProperty Value: undefined
param TypeInfoProperty Name : isOrdered
param TypeInfoProperty Value: false
param TypeInfoProperty Name : isStream
param TypeInfoProperty Value: false
param TypeInfoProperty Name : type
param TypeInfoProperty Value: undefined
param TypeInfoProperty Name : isUnique
param TypeInfoProperty Value: true
param TypeInfoProperty Name : upperValue
param TypeInfoProperty Value: undefined
param TypeInfoProperty Name : visibility
param TypeInfoProperty Value: undefined

Note that except for the booleans, direction, and effect, the other values are undefined, which is strange.
Title: Re: Class operation parameter types
Post by: qwerty on September 07, 2024, 05:25:54 am
Not strange, but simply a bug as Geert mentioned. Report it...

q.
Title: Re: Class operation parameter types
Post by: Paolo F Cantoni on September 09, 2024, 06:33:14 pm
Not strange, but simply a bug as Geert mentioned. Report it...

q.
Wot 'e sed!

Paolo
Title: Re: Class operation parameter types
Post by: tweber on September 09, 2024, 10:09:10 pm
I have asked support about it. 
Title: Re: Class operation parameter types
Post by: qwerty on September 10, 2024, 02:32:25 am
There IS a bug reporting form down here.

q.