Book a Demo

Author Topic: How to get the objectType from an ID  (Read 6060 times)

tonySparx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
How to get the objectType from an ID
« on: February 02, 2010, 01:44:40 am »
Hi all,

I need to get objectType from an object ID, i.e. I have an object ID and I want to know what kind of object that is (otElement, otConnector and so on)?

I've already read the userGuide, but I suppose don't exists a method like " objectType getObjectByID(int ID)"...

Is there a way to implement my need in EA?

kind regards

Antonio

"everything is possible, but there are things more likely than others..." © all rights reserved

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: How to get the objectType from an ID
« Reply #1 on: February 02, 2010, 09:12:29 am »
No, the ID isn't unique across all types.
The Sparx Team
[email protected]

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 get the objectType from an ID
« Reply #2 on: February 02, 2010, 06:14:21 pm »
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: How to get the objectType from an ID
« Reply #3 on: February 03, 2010, 08:54:15 am »
You do have two options in the following scenarios:

1. If it's the currently selected item you can call GetContextItemType()
2. If it's the currently selected item in the tree you can call GetTreeSelectedItemType()
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

tonySparx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: How to get the objectType from an ID
« Reply #4 on: February 06, 2010, 09:30:17 pm »
Quote
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert

Thanks to all for help,

Geert, would be unique or IS unique? :D I've not found anything about this difference on the EA userguide...

"everything is possible, but there are things more likely than others..." © all rights reserved

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 get the objectType from an ID
« Reply #5 on: February 06, 2010, 10:53:18 pm »
Tony,

"should", but with EA you never know ;)

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to get the objectType from an ID
« Reply #6 on: February 07, 2010, 12:37:58 pm »
Quote
Quote
Antonio,

In that case you'll need to use the GUID property.
That would be (by its nature) unique amongst all objects.

Geert

Thanks to all for help,

Geert, would be unique or IS unique? :D I've not found anything about this difference on the EA userguide...

As a Data Architect, Tony, I learnt a LONG time ago that the term unique MUST always be accompanied by the context in which one is asserting uniquenesss...

For example, within a table such as t_object, the Object_ID is unique, but not across tables.  A GUID or UUID is notationally unique but only if you don't assign it to more than one entity.

Personally, I'd probably create a t_GUID table that had the GUID as the primary key, then the entity type (it was assigned to), and the entityID.  That way, I'd end up with a self-consistency mechanism that would assist in ensuring I didn't allocate the same GUID to more than one entity  (not that, so far, EA does).

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