Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Paolo F Cantoni on March 05, 2019, 12:40:13 pm

Title: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 05, 2019, 12:40:13 pm
The Documentation says:

Code: [Select]
DiagramLinks Attributes

ConnectorID Long Notes: Read/Write The ID of the associated connector.

It is read-write, but under VBScript, it doesn't appear to be.  We have shown that if a change is attempted to ConnectorID, the whole Update (for example, IsHidden, Geometry etc.) will fail.  But if the ConnectorID change is not present (commented out), the rest of the change succeeds.

Can anyone confirm?  (FWIW, it's an .EAPX - Jet4 file)

TIA,
Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 05, 2019, 03:44:12 pm
From what I can see, if you change the ConnectorID or DiagramID it will add or update the record relating to the new pair. It won't change the existing record relating to the old pair.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 05, 2019, 06:07:12 pm
From what I can see, if you change the ConnectorID or DiagramID it will add or update the record relating to the new pair. It won't change the existing record relating to the old pair.

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 06, 2019, 09:32:29 am
The API update is acting on a DiagramID/ConnectorID pair. What I'm saying is that you can't re-point the diagram link via the API.

There IS a new pair. Whatever DiagramID and ConnectorID it has will be a new pair.

From what I can see, it will either replace the diagramlink information that already exists for the target connector id, or it will create a new one.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 06, 2019, 10:06:14 am
The API update is acting on a DiagramID/ConnectorID pair. What I'm saying is that you can't re-point the diagram link via the API.

There IS a new pair. Whatever DiagramID and ConnectorID it has will be a new pair.

From what I can see, it will either replace the diagramlink information that already exists for the target connector id, or it will create a new one.
As far as we could see - with direct, live DB queries if we just changed the ConnectorID, NO new diagramlinks were created.

In my view the API is suspect.

Nowhere that I could see was this behaviour even implied!

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: qwerty on March 06, 2019, 10:22:15 am
Remember that in former EA versions diagramLinks were only created for manipulated connectors. Only recent (since V8 or so) create diagramLinks in all cases. There (might) be dragons.

q.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 06, 2019, 11:52:09 am
Remember that in former EA versions diagramLinks were only created for manipulated connectors. Only recent (since V8 or so) create diagramLinks in all cases. The (might) be dragons.

q.
This is my thinking...  That's why the current behaviour is anomalous. 

The Instance_ID identifies WHICH diagram link is being manipulated (we know so because the SQL Queries need it).  If I change either (or even both) ConnectorID or DiagramID, but not the Instance_ID, then I'm manipulating Where (DiagramID) and How (ConnectorID) I want the specific link to appear.

If it was just a doublet (Tuple of ConnectorID, DiagramID) then why introduce Instance_ID?  To me, it seems the whole process is flawed.

As an aside, after I'd posted the original post. I thought "Hold your horses, Batman!  You've done this before..."  So I went searching through my VBA code (in this case in Excel) only to find we'd done it via SQL statements!  So we've done the same for VBScript.

As usual, I'd like to see a rationale for the current mechanism.

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 06, 2019, 12:32:41 pm
I've only looked as far as seeing that Instance_ID is not used by the API. It reads like it Instance_ID didn't exist when it was written.

I don't know about rationale, but at least this way it doesn't need to try to avoid duplicate entries.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 06, 2019, 04:21:59 pm
I've only looked as far as seeing that Instance_ID is not used by the API. It reads like it Instance_ID didn't exist when it was written.

I don't know about rationale, but at least this way it doesn't need to try to avoid duplicate entries.

"It's broken, "

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 07, 2019, 01:50:59 pm
I just tested it.

If I change the connector ID to another connector that is on the diagram, it updates that connector instead.
If I change it to a connector id to an id that isn't on the diagram the edit is discarded. (Which isn't what I thought it would do initially)

In both cases, it is protecting data integrity. (By not creating a duplicate entry and by not creating an entry that shouldn't exist)

If you want to copy the style to another connector, use AddNew and then copy the values. Regardless of having an Instance_ID, a diagram link is identified by the Diagram and Connector it applies to. You can't change that.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 07, 2019, 06:03:57 pm
I just tested it.

If I change the connector ID to another connector that is on the diagram, it updates that connector instead.
If I change it to a connector id to an id that isn't on the diagram the edit is discarded. (Which isn't what I thought it would do initially)

In both cases, it is protecting data integrity. (By not creating a duplicate entry and by not creating an entry that shouldn't exist)

If you want to copy the style to another connector, use AddNew and then copy the values. Regardless of having an Instance_ID, a diagram link is identified by the Diagram and Connector it applies to. You can't change that.
Then the documentation had better be fixed - especially since a Sparxian was "led astray" ;)

We believe we have a genuine Use Case for using the Instance_ID in the same way that we can "replace" a diagram object, by changing the ObjectID without changing the Instance_ID.
 
We do NOT break data integrity (I am an Information/Data Architect, after all).

For us, it's now moot. We're using direct SQL to achieve our required outcome in this instance.  What we are actually (physically) doing in the repository is identical to our conceptual view.

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Geert Bellekens on March 07, 2019, 07:06:49 pm
Given the way the API works and automatically creates/deletes Diagramlinks depending on the relations between the elements of the DiagramObjects on the diagram,  I think both diagramID as connectorID should be set to readonly.

The current behavior is weird at best :-X

Geert
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 08, 2019, 10:10:46 am
I agree the behavior is weird. I'm just describing how it is.

Always hesitant to change existing functionality in the API.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Geert Bellekens on March 08, 2019, 03:28:31 pm
Always hesitant to change existing functionality in the API.

I can fully support that.
I have run into some changes to the API in the past, breaking my add-ins or script.

Geert
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 08, 2019, 08:41:48 pm
Always hesitant to change existing functionality in the API.

I can fully support that.
I have run into some changes to the API in the past, breaking my add-ins or script.

Geert
I can't see ANY rationale for explicitly using the current behaviour in ANY existing user code.  So "fixing it" to subsume the current behaviour on disk for existing tuples, but including the new (expected) behaviour when there is no existing tuple for the diagram, to me, is just an API extension which CANNOT break any existing user code.  Now it may cause some issues on the Sparx side of the API, but my argument would be that that would be caused by existing defects in the existing API.

Everybody (even me) agrees that the current behaviour is weird.  I'm prepared to stand by my assertion that "it's broke, ".

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 12, 2019, 09:33:31 am
I can't see ANY rationale for explicitly using the current behaviour in ANY existing user code.
Copying the style properties from one diagramlink to another.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 12, 2019, 10:33:23 am
I can't see ANY rationale for explicitly using the current behaviour in ANY existing user code.
Copying the style properties from one diagramlink to another.
No, I meant with respect to the two IDs.  Obviously, copying properties doesn't require changing the ID, merely synchronising the properties.

Our Use Case is similar.   In our case, it's moving the properties from one connector to another (new) connector.  We want to discard the previous connector from the diagram.

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Eve on March 12, 2019, 10:53:49 am
I was providing an example of how an existing client could be using the existing behavior. Currently anyone can copy the complete style from one diagram link to another by changing the connector id and/or diagram id and calling update.
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: Paolo F Cantoni on March 14, 2019, 11:33:58 am
I was providing an example of how an existing client could be using the existing behaviour. Currently, anyone can copy the complete style from one diagram link to another by changing the connector id and/or diagram id and calling update.
I was thinking about this and this isn't an example of a Use Case, its an example of an Abuse Case.

It violates so many data integrity concepts...  It smacks to me of the "Streaker's Defence" - "It seemed like a good idea at the time, your honour..."

The table is defined with Instance_ID as the primary key and the tuple DiagramID, ConnectorID is NOT defined as a unique key.  So there is no concept of the DiagramID, ConnectorID defining a link.  (In fact, we've noticed occasional duplicate link errors when running the integrity checker - so they might be caused by the faulty API also).

The API needs to respect these rules.  Otherwise, we as users can't expect anything to work.  As it is we've discovered we issued a specific instruction, only to find the API decided to do something else...

"It's a bug, "

Paolo
Title: Re: Is DiagramLinks.ConnectorID in VBScript read/write
Post by: qwerty on March 14, 2019, 05:31:12 pm
My experience with Sparx is just that there's no point in discussing things like that with them. "James," (seems a fit for the partner of  since I don't know her) "the discussion is futile".

q.

P.S. Oh what a coincidence that this post was my 10^4th.