Book a Demo

Author Topic: Object Model and access via java on e.g. Tagged Values  (Read 6470 times)

Pegasus

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Object Model and access via java on e.g. Tagged Values
« on: December 07, 2016, 02:20:41 am »
Hello,

Preferences: I'm not realy familar with java, but need to use it to access via an API to an external applikation (PTCIntegrity)

I try to run from easy to more complex example (based on hyperscript example from Sparx using java)
I try to run first on packages and read TV (if exist) but I get Exception if I try to print of name of Element (package) of a root (Model) package....   I am not sure if I understand API at all.,
Where come e.g. GetPackages() from and how do I get access on e.g. isModel. I don't see this methods in online help (automation interface/Package package, ..)
If I understand right, I do have first getPackages(collection) than iterate with GetAt(idx) collection and call pgk.GetElement() to get access to e.g. TV. To get the TV for one element I do need a new collection TaggedValue filled by element.GetTaggedValues() ?

Where do I went wrong.
Sorry,  if my description isn't well english and confuse, but it reflects my current problem in understandig API
Tanks in advance for support and hints



qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Object Model and access via java on e.g. Tagged Values
« Reply #1 on: December 07, 2016, 03:06:32 am »
Giving an online course on the forum would be rather tricky. What is your code and where does it fail?

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Object Model and access via java on e.g. Tagged Values
« Reply #2 on: December 07, 2016, 12:57:31 pm »
Root (Model) packages are a special case.  They do not have an associated Element class and will not have Tagged Values either.

Pegasus

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Object Model and access via java on e.g. Tagged Values
« Reply #3 on: December 08, 2016, 01:26:47 am »
First, Thanks for hint to specials of root.
Exception bases on an writeto script output and I didn' investigate.

I'm now able to access TV (displayed as Tags Tab), but I don't understand how to access on TV defined in an MDG e.g. SysML1.4 and I don't understand FQName in TV class (filled if e.g. SysML1.4 ?)
What I'm always confused is where to find definiton of e.g GetName() to access Name of e.g. Element, not write Element.Name ...?

I hope for further hints to lift the fog in my thougths

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Object Model and access via java on e.g. Tagged Values
« Reply #4 on: December 08, 2016, 01:32:27 am »
You access TVs from a MDG like any other TV by getting them from the TaggedValues collection. The FQName is just prepended with the MDG name and a "::". You must not use that. Just stick with the simple name you see.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Object Model and access via java on e.g. Tagged Values
« Reply #5 on: December 08, 2016, 08:45:33 am »
I'm now able to access TV (displayed as Tags Tab), but I don't understand how to access on TV defined in an MDG e.g. SysML1.4 and I don't understand FQName in TV class (filled if e.g. SysML1.4 ?)
What I'm always confused is where to find definiton of e.g GetName() to access Name of e.g. Element, not write Element.Name ...?
element.Name vs element.GetName() is just Java convention for properties. It doesn't change the base meaning, just the way that it's accessed. There isn't a duplicated version of the API anywhere that documents GetName() and SetName() instead of the property Name. If you're not familiar with Java, I would probably use a different language to access the API.

Profile tagged values are accessible via the API in the same way as any other tagged value. If you want to know if a particular tag comes from a profile, call tag.GetFQName(). It will include the profile and stereotype in addition to the tag name.