Author Topic: GetByName is broken?!?  (Read 8843 times)

dserodio

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
GetByName is broken?!?
« on: May 16, 2005, 11:30:24 am »
I'm trying to use the GetByName methos in the Packages collection, but it gives me an error:

-2147417851, The server threw an exception.

And it doesn't work with any name, even the name returned by EA itself:

packs = Model.GetAt(0).Packages
pack.GetByName(packs.GetAt(0).Name)

Is this method broken? ???
Correctness is clearly the prime quality. If a system does not do what it is supposed to do, then everything else about it matters little. - Bertrand Meyer

TomO

  • EA Administrator
  • EA User
  • *****
  • Posts: 79
  • Karma: +6/-0
  • EA - Bridging the gap between Business and IT
    • View Profile
    • Sparx Systems
Re: GetByName is broken?!?
« Reply #1 on: May 16, 2005, 07:54:03 pm »
Quote
I'm trying to use the GetByName methos in the Packages collection, but it gives me an error:

-2147417851, The server threw an exception.

And it doesn't work with any name, even the name returned by EA itself:

packs = Model.GetAt(0).Packages
pack.GetByName(packs.GetAt(0).Name)

Is this method broken? ???


Hello dserodio,
No this method is not broken, it just doesn't exist :-) The best way to get a package by its name would be to loop through all the packages in the repository and compare their names. The reason for this is that there is no guarantee that a package name will be Unique.
Another option that you do have is the Repository.GetPackageByID and .GetPackageByGuid(). Both will return a single package.

-Tom

charge

  • EA User
  • **
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: GetByName is broken?!?
« Reply #2 on: May 20, 2005, 05:43:43 am »
ahum...

I'm using it and it works fine.

If you add elements, you have to refresh the package first !

thomaskilian

  • Guest
Re: GetByName is broken?!?
« Reply #3 on: May 20, 2005, 06:14:39 am »
There's probably a missunderstanding: one is talking about getting packages by name and the other of package contents :o

dserodio

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GetByName is broken?!?
« Reply #4 on: May 20, 2005, 06:38:29 am »
Quote

Hello dserodio,
No this method is not broken, it just doesn't exist :-)
...


Errrr, then why is it documented on EA's Help, under
Automation and Scripting / The Automation Interface / Reference / Repository / Collection ?

Or is the packages collection not a Collection with a capital C?
Correctness is clearly the prime quality. If a system does not do what it is supposed to do, then everything else about it matters little. - Bertrand Meyer

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: GetByName is broken?!?
« Reply #5 on: May 20, 2005, 07:02:27 am »
Quote

Errrr, then why is it documented on EA's Help, under
Automation and Scripting / The Automation Interface / Reference / Repository / Collection ?

Or is the packages collection not a Collection with a capital C?


You mean the documentation is inconsistent with the code?

(Couldn't resist)

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

thomaskilian

  • Guest
Re: GetByName is broken?!?
« Reply #6 on: May 20, 2005, 07:47:13 am »
Quote
Dear Mr Killan,

You're right, only Models, Packages, Elements and Diagrams collections
support the GetByName method, all other collections should return
"Action not supported."

In these cases it is necessary to iterate though the collection testing
the name value explicitly.

Regards,

Phil Bachmann
Sparx Systems

> -----Original Message-----
> From: Thomas Kilian [mailto:[email protected]]
> Sent: Tuesday, 9 November 2004 1:05 AM
> To: sparxsupport
> Subject: Bug Report - Automation: Issues Collection faulty
>
> The following Bug Report was submitted by Thomas Kilian
> (mailto:[email protected]) on Mon Nov  8 07:04:59 MST 2004.
> --------------------------------------------------------------
> -----------------
>
> ENVIRONMENT DETAILS
>
> EA Version:  4.1
> Build No:  739
> Repository Type:  .EAP
> Operating System:  Windows 2000
> Service Pack:  4
>
> --------------------------------------------------------------
> -----------------
>
> ISSUE DETAILS
>
> Subject:  
>
> Automation: Issues Collection faulty
>
>
> Details:  
>
> The method GetByName does not return a result on
> Repository.Issues The same applies to .Tasks (and others?)
>
>
> Steps to Reproduce:  
>
> see bug details

dserodio

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: GetByName is broken?!?
« Reply #7 on: May 20, 2005, 02:08:58 pm »
Thanks for the clarification, Thomas.
But I still don't understand: if it's so simple to implement GetByName functionality, why do I have to implement it? Shouldn't all collections support this method, for consistency at least?

I understand TomO's rationale, but if I am asking for a package by name, it's because I know that in my model, package names are unique (at the same hierarchical level, at least).

Also, Phil Bachmann's response to Thomas' bug report said that "only Models, Packages, Elements and Diagrams collections support the GetByName method", but TomO says that Packages don't support it.

Finally, whatever the outcome, please update the documentation accordingly. Thomas filed the bug against v4.1 and 4.51's documentation still doesn't mention it.
Correctness is clearly the prime quality. If a system does not do what it is supposed to do, then everything else about it matters little. - Bertrand Meyer

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: GetByName is broken?!?
« Reply #8 on: May 20, 2005, 06:22:18 pm »
Quote
Thanks for the clarification, Thomas.
But I still don't understand: if it's so simple to implement GetByName functionality, why do I have to implement it? Shouldn't all collections support this method, for consistency at least?

I understand TomO's rationale, but if I am asking for a package by name, it's because I know that in my model, package names are unique (at the same hierarchical level, at least).

Also, Phil Bachmann's response to Thomas' bug report said that "only Models, Packages, Elements and Diagrams collections support the GetByName method", but TomO says that Packages don't support it.

Finally, whatever the outcome, please update the documentation accordingly. Thomas filed the bug against v4.1 and 4.51's documentation still doesn't mention it.


Consistency? consistency? wherefore art thou consistency?

I'm a one track record, I know.... But play me and see what beautiful music results!

Paolo
« Last Edit: May 22, 2005, 11:09:37 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +54/-3
    • View Profile
Re: GetByName is broken?!?
« Reply #9 on: May 22, 2005, 09:35:22 pm »
Quote
Also, Phil Bachmann's response to Thomas' bug report said that "only Models, Packages, Elements and Diagrams collections support the GetByName method", but TomO says that Packages don't support it.


It's actually Models, Packages, Elements, Diagrams and TaggedValues collections that support GetByName(), the last named since build 760. I have amended the help accordingly.

If Packages.GetByName() isn't working for you, could you post up a few lines of code and I'll try it here, see if I can figure out why.
« Last Edit: May 22, 2005, 09:36:19 pm by KP »
The Sparx Team
[email protected]