Book a Demo

Author Topic: Connect Connector to Class using ProxyConnector  (Read 6600 times)

kmeier

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Connect Connector to Class using ProxyConnector
« on: November 20, 2018, 05:32:13 pm »
Hi experts,

we are coding an Addin which allows a third party datamodel description to be imported to EA.

Now we need to attach a class to an connector as shown in the following picture:



I already found out, that we need a "ProxyConnector" Element which represents the "source" connector "demo" and link both by setting the ClassifierID on the Element.
Then the "Dependency" Connector can be created between the "ProxyConnector" and the class C.
I evaluated this by trying to analyse the model of the picture. But now I'm stuck. The following (c#) code does all I could figure out, but still when I use that and pull the classes into a diagram, the dependency between the "demo" connector and class C is NOT shown.

Can someone tell me, what is wrong?

Code: [Select]
// create the three classes
var clsA = (Element) package.Elements.AddNew("A", "Class");
var clsB = (Element) package.Elements.AddNew("B", "Class");
var clsC = (Element) package.Elements.AddNew("C", "Class");
clsA.Update();
clsB.Update();
clsC.Update();

// create the assiciation between A and B
var conn = (Connector) clsA.Connectors.AddNew("demo", "Association");
conn.SupplierID = clsB.ElementID;
conn.Update();

// create the ProxyClass for the connector
var clsPrx = (Element) package.Elements.AddNew("ProxyConnector", "ProxyConnector");
clsPrx.ClassfierID = conn.ConnectorID;
clsPrx.Update();

// now try to "link" the ProxyConnector to class C
var link = (Connector) clsPrx.Connectors.AddNew("", "Dependency");
link.SupplierID = clsC.ElementID;
link.Update();
link.SupplierEnd.Containment = "Unspecified"; // added by comparing values
link.SupplierEnd.IsChangeable = "none"; // added by comparing values
link.SupplierEnd.IsNavigable = true;
link.SupplierEnd.Update();

link.ClientEnd.Containment = "Unspecified"; // added by comparing values
link.ClientEnd.IsChangeable = "none"; // added by comparing values
link.ClientEnd.Update();

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connect Connector to Class using ProxyConnector
« Reply #1 on: November 20, 2018, 06:52:58 pm »
You'll have to compare your results in the database with those when you do it manually.
Make sure to also look in the t_xref. You might be missing some magic dust here or there.

I've never actually created those proxy connectors in code myself.

Geert

kmeier

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connect Connector to Class using ProxyConnector
« Reply #2 on: November 20, 2018, 07:24:28 pm »
Is there an easy way to do this?
(I needed several steps to open it in access 365).

Anyway: There are in fact some small differences in the connector table. There is no entry in t_xref.

The main differences seem to be the columns "SourceTS" and "DestTS". EA stores the value "instance" to them - but how do I do this by API?
....or is it relevant at all?


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connect Connector to Class using ProxyConnector
« Reply #3 on: November 20, 2018, 07:56:27 pm »
I use a free tool called AnySQL Maestro to connect to .eap files.

Not sure if the SourceTS and DestTS fields are relevant. The best way to know for sure it to update the database and find out.
Not sure what these fields are supposed to mean, so I'm not sure if there is an API field that corresponds.

If all else fails you can always use the nuclear option: Repository.Execute, but make sure that you know what you are doing. Once you go there you are on your own (not supported by Sparx)

Geert

kmeier

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connect Connector to Class using ProxyConnector
« Reply #4 on: November 21, 2018, 12:08:38 am »
Ok - seems as the classifierID is not stored correctly. There the repository.Execute helps.

Code: [Select]

// create the ProxyClass for the connector
var clsPrx = (Element) package.Elements.AddNew("ProxyConnector", "ProxyConnector");
clsPrx.ClassifierID = conn.ConnectorID; // THIS SEEMS NOT TO WORK CORRECTLY
clsPrx.Update();
// THIS ensures the classifier ID is correct
repository.Execute("UPDATE t_object SET Classifier_guid='" + conn.ConnectorGUID + "' WHERE Object_ID=" + clsPrx.ElementID + ";");

Bug or Feature? :-)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Connect Connector to Class using ProxyConnector
« Reply #5 on: November 21, 2018, 12:26:11 am »
Bug or Feature? :-)
Does it matter? I would report it anyway.
The worst that could happen is that Sparx refuses to do anything about it.

Geert

kmeier

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Connect Connector to Class using ProxyConnector
« Reply #6 on: November 22, 2018, 01:36:37 am »
Done so - Support says: there is currently no other way. API will be extended eventually but is not yet scheduled.

thank you for your help Geert!