Author Topic: Adding Realization via script  (Read 4682 times)

D. Schmid

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Adding Realization via script
« on: July 21, 2015, 07:42:48 pm »
Hi @all,

I'm currently trying to add a realization from a class to an interface with a script.

Unfortunatelly this:

Code: [Select]
     
var eRealization;
eRealization = eClass.Realizes.AddNew (eInterface.ElementID, "Interface");
eRealization.Update ();
eClass.Realizes.Refresh();
eClass.Update();
eClass.Refresh ();
won't work

also this:

Code: [Select]
var eAssociation as EA.Connector;
eAssociation = eClass.Connectors.AddNew ("", "Realization");
eAssociation.SupplierID = eInterface.ElementID;
eAssociation.Direction = "Source -> Destination";
eAssociation.Update();
will throw an error at the update saying the Realization is not allowed "class --> interface"

How can I add a realization to a class using a script? In both cases the interface will also be created by the script.

Regards

Dominik
Using EA 12 (1215) | C | C++ | C# | Java | UML 2

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Adding Realization via script
« Reply #1 on: July 22, 2015, 07:23:53 am »
I tried this with V9.3 and it worked. V12 failed. Looks like a bug. Will do a bit more testing.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Adding Realization via script
« Reply #2 on: July 22, 2015, 07:31:31 am »
I remember a recent similar thread. Turn off Tools/Options/Links(/Strict Connector Syntax and it works again. Still smells like a bug as the connector looks more than legal (it's even offered in the quick linker). Go ahead and send a bug report.

q.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: Adding Realization via script
« Reply #3 on: July 22, 2015, 10:26:14 am »
The second code snippet is the correct approach but it stopped working with EA 12, I think. It should have been fixed at 12.0.1213. From the readme:

Quote
Creation of new Realization connectors from automation restored

If it is still failing in a later edition, please send a bug report including the failing code snippet. And, as qwerty states, switching off Strict Connector Syntax is a work-around.
The Sparx Team
[email protected]

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Adding Realization via script
« Reply #4 on: July 22, 2015, 07:16:37 pm »
I don't have the very latest V12. I tested with 1208.

q.

D. Schmid

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Adding Realization via script
« Reply #5 on: July 23, 2015, 03:43:40 pm »
Hi @all,

thank you for the quick Responses. The Workaround is working fine. I will test the script using 1215 today and will send a quick Feedback here and if necessary a little Bug Report. We currently use 1210 and there it didn't work.

Regards

Dominik
Using EA 12 (1215) | C | C++ | C# | Java | UML 2

D. Schmid

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Adding Realization via script
« Reply #6 on: July 24, 2015, 03:43:42 pm »
Hi again,

short Update. Just tested with 1215 and all works fine. Thank you all.

Regards

Dominik
Using EA 12 (1215) | C | C++ | C# | Java | UML 2