Book a Demo

Author Topic: Create UseCase type connector in java  (Read 5104 times)

Jim

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Create UseCase type connector in java
« on: February 26, 2008, 04:09:22 pm »
I'm trying to create a connector in java of type "UseCase". My program crashes if I try to do this, but works if i create one of type "Association".

According to the User Guide "UseCase" is a valid type and if i dump my package to console the connectors I created in Enterprise Architect are of type "UseCase".

Heres my code:

                             connector = (org.sparx.Connector) connectors.AddNew("", "Usecase");
                              connector.SetClientID(ucElement.GetElementID());
                              connector.SetSupplierID(element.GetElementID());
                              connector.SetDiagramID(diagram.GetDiagramID());
                              connector.Update();

It will crash when trying to run the connector.Update() so I don't get any error info from the GetLastError

Any ideas?

Cheers.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Create UseCase type connector in java
« Reply #1 on: February 26, 2008, 04:13:58 pm »
Quote
I'm trying to create a connector in java of type "UseCase". My program crashes if I try to do this, but works if i create one of type "Association".

According to the User Guide [highlight]"UseCase"[/highlight] is a valid type and if i dump my package to console the connectors I created in Enterprise Architect are of type "UseCase".

Heres my code:

                             connector = (org.sparx.Connector) connectors.AddNew("", [highlight]"Usecase"[/highlight]);
                              connector.SetClientID(ucElement.GetElementID());
                              connector.SetSupplierID(element.GetElementID());
                              connector.SetDiagramID(diagram.GetDiagramID());
                              connector.Update();

It will crash when trying to run the connector.Update() so I don't get any error info from the GetLastError

Any ideas?

Cheers.
I think it's case-sensitive... (no pun intended)
« Last Edit: February 26, 2008, 04:14:50 pm by KP »
The Sparx Team
[email protected]

Jim

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Create UseCase type connector in java
« Reply #2 on: February 26, 2008, 04:22:54 pm »
Opps, yeah I originally had:
connector = (org.sparx.Connector) connectors.AddNew("", "UseCase");

but I changed it to "Usecase" just to check if it needed a lower case C. Still crashes "UseCase".

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Create UseCase type connector in java
« Reply #3 on: February 26, 2008, 04:39:24 pm »
Which "connectors" collection are you trying to add to? You should call AddNew() on the client element's connectors collection, then set the supplier id as before.
The Sparx Team
[email protected]

Jim

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Create UseCase type connector in java
« Reply #4 on: February 26, 2008, 04:53:49 pm »
The "connectors" I had was a collection of all the connectors in the package. I just changed it to be the client elements collection and it is still crashing.  :(

Cheers.

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Create UseCase type connector in java
« Reply #5 on: February 26, 2008, 05:00:06 pm »
I'm running out of ideas and I don't know java. If you send in a support request and attach the failing code then someone will have a look at it. The support request form is here.
The Sparx Team
[email protected]

Jim

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Create UseCase type connector in java
« Reply #6 on: February 26, 2008, 05:01:38 pm »
Will do. Thanks for your help.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Create UseCase type connector in java
« Reply #7 on: February 26, 2008, 11:31:31 pm »
Quote
I'm trying to create a connector in java of type "UseCase". My program crashes if I try to do this, but works if i create one of type "Association".

According to the User Guide "UseCase" is a valid type and if i dump my package to console the connectors I created in Enterprise Architect are of type "UseCase".

Heres my code:

                             connector = (org.sparx.Connector) connectors.AddNew("", "Usecase");
                              connector.SetClientID(ucElement.GetElementID());
                              connector.SetSupplierID(element.GetElementID());
                              connector.SetDiagramID(diagram.GetDiagramID());
                              connector.Update();

It will crash when trying to run the connector.Update() so I don't get any error info from the GetLastError

Any ideas?

Cheers.
Hi Jim,

Yes, it should be case sensitive...

What about the following:

Have you tried this with a non-blank name for the connector?

Have you tried the code without the DiagramID line?

David
No, you can't have it!