Book a Demo

Author Topic: How to use Connector.Update right?  (Read 4935 times)

B27

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
How to use Connector.Update right?
« on: November 04, 2010, 05:09:10 pm »
Hello,

I'd like to add a new connector to a package. But I'm getting an error when trying to update the connector. My code looks like this:

Code: [Select]
con = package.Element.Connectors.AddNew("name", "type")
con.Update

The error: OLE error code:61704 in EA
  Internal application error.
HRESULT error code: 0x80020009
Exception error occured.

I am working with Ruby and up till now everything worked fine with the EA API, Update on other collection objects worked as well. So maybe I am doing something wrong here?
Thanks for your help.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use Connector.Update right?
« Reply #1 on: November 04, 2010, 06:07:16 pm »
You have to set the Connector.SupplierID before saving, and the "type" of your connector is not one of the known types.
According to TFM the type should be one of:

Aggregation
Assembly
Association
Collaboration
CommunicationPath
Connector
ControlFlow
Delegate
Dependency
Deployment
ERLink
Generalization
InformationFlow
Instantiation
InterruptFlow
Manifest
Nesting
NoteLink
ObjectFlow
Package
Realization
Sequence
StateFlow
UseCase

Geert

B27

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to use Connector.Update right?
« Reply #2 on: November 04, 2010, 07:16:19 pm »
Thanks for your answer, Geert.
I tried it like you proposed:

Code: [Select]
con = package.Element.Connectors.AddNew("name", "Aggregation")
con.SupplierID = package2.Element.ElementID
con.Update

And I'm getting the same error as before. Tried it with setting the ClientID and SupplierID as well.
« Last Edit: November 04, 2010, 07:24:55 pm by B27 »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use Connector.Update right?
« Reply #3 on: November 04, 2010, 07:24:27 pm »
Why do you use Package.Element.Connectors and not simply Package.Connectors?

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use Connector.Update right?
« Reply #4 on: November 04, 2010, 07:27:09 pm »
Also in a strong typed language you have to cast the object returned by the Collection.AddNew() operation to Connector.
So something like
Code: [Select]
con = (Connector)package.Connectors.AddNew("name", "Aggregation")I'm not sure how that works using Ruby.

Geert

B27

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to use Connector.Update right?
« Reply #5 on: November 04, 2010, 07:27:44 pm »
I had a look at the sample code from Sparx. They use the element and not the package. But I tried it without using element and instead the package.Connectors directly. Doesn't work either.

B27

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to use Connector.Update right?
« Reply #6 on: November 04, 2010, 07:40:44 pm »
As far as I know there is no type-cast like that. But I checked which class type the connector has: IDualConnector. And I think, that's what it's supposed to be.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to use Connector.Update right?
« Reply #7 on: November 04, 2010, 07:57:04 pm »
Then I'm all out of ideas.
Better ask Sparx Support for help.

Geert

B27

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: How to use Connector.Update right?
« Reply #8 on: November 04, 2010, 07:59:10 pm »
Thanks for your help anyway.