Book a Demo

Author Topic: How to access a package from its package element  (Read 7564 times)

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
How to access a package from its package element
« on: October 30, 2014, 04:27:52 pm »
Given Package "B" residing in Package "A":

When I access the EA.Element instance in "B":
    Dim B as EA.Package ...
    Dim E as EA.Element = B.Element

And then try to access package "B" again from the attributes of E:
    Dim B_pkgID as Integer = E.PackageID

I do not get the same Integer value as B.PackageID.

Does anyone know how to get back to a Package from its owned Element (note that the Package's corresponding Element object ID is what is cached in the Client and Supplier ends of a Connector object.

The EA GUI seems to know how to do this. The API, however, does not.
Have I discovered a bug here???

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to access a package from its package eleme
« Reply #1 on: October 30, 2014, 04:29:26 pm »
Oh, I forgot to mention : the value of E.PackageID returned by the API is actually A.PackageID, not B.PackageID!

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: How to access a package from its package eleme
« Reply #2 on: October 30, 2014, 04:50:45 pm »
I think when an element has a package ID, that indicates the package that it is IN, but when a package has a package ID, that indicates the package that it IS. So E.PackageID should be the same as B.ParentID. I think. Maybe.

[edit]But E and B should have the same GUID[/edit]
« Last Edit: October 30, 2014, 05:09:20 pm by KP »
The Sparx Team
[email protected]

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: How to access a package from its package eleme
« Reply #3 on: October 30, 2014, 09:12:18 pm »
I think this is the way it works.

Element.PackageID  :  returns the package that "owns" the element
Package.PackageID  :  returns its own packageID

Element.parentID  :  returns the package that "owns" the element - Does not return an element if that is the parent of the current element.
Package.parentID  : returns the package that "owns" this package
« Last Edit: October 30, 2014, 09:27:12 pm by Stenvang »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to access a package from its package eleme
« Reply #4 on: October 30, 2014, 09:36:02 pm »
Actually the GUID of a package element is the same as that of package.element. So you can find it back by
Code: [Select]
Repository.GetPackageByGUID (package.element.guid)
q.

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to access a package from its package eleme
« Reply #5 on: October 31, 2014, 07:34:47 am »
Using the Package Element's GUID to retrieve the Package itself works fine!

So ...

Package.GUID = Package.Element.GUID

And ...

Package.Element.PackageID = Package.ParentID
Package.Element.ParentID = 0

Weird, but that is how the API works.

Hey! Where the heck is this documented, anyway?????

Thanks for the help, all  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: How to access a package from its package eleme
« Reply #6 on: October 31, 2014, 09:24:29 am »
Some of it might be in the help but well hidden (thanks to Mickeysoft's help technology). Quite a bit I gathered in my Inside book (there was a real need for it  ;)).

q.

Jeff Bartels

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: How to access a package from its package eleme
« Reply #7 on: October 31, 2014, 12:21:39 pm »
I would like to know more about that book - what is the complete title?

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: How to access a package from its package eleme
« Reply #8 on: October 31, 2014, 03:16:42 pm »
Inside Enterprise Architect. Click on the title in qwerty's post footer, just above your question.
« Last Edit: October 31, 2014, 03:17:35 pm by RoyC »
Best Regards, Roy

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 access a package from its package eleme
« Reply #9 on: November 04, 2014, 06:42:43 pm »
Quote
Using the Package Element's GUID to retrieve the Package itself works fine!

So ...

Package.GUID = Package.Element.GUID

And ...

Package.Element.PackageID = Package.ParentID
Package.Element.ParentID = 0

Weird, but that is how the API works.

Hey! Where the heck is this documented, anyway?????

Thanks for the help, all  :)
Actually most of it is documented in the help file:
Quote
  • Element.PackageID: A local ID for the Package containing this element.
  • Element.ParentID: If this element is a child of another, used to set or retrieve the ElementID of the other element; if not, returns 0.
  • Package.Element: The associated element object; use to get/set common information such as Stereotype, Complexity, Alias, Author, Constraints, Tagged Values and Scenarios
  • Package.PackageID: The local Package ID number. Valid only in this model file.
  • Package.ParentID: The ID of the package that is the parent of this one. 0 indicates this package is a model (that is, it has no parent).
Only the "trick" that the GUID's of the Package object and the Element object are the same is not documented.

Geert