Book a Demo

Author Topic: Setting element's PDATA value / Composite elements  (Read 7187 times)

jamesl

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Setting element's PDATA value / Composite elements
« on: September 17, 2012, 07:49:24 pm »
Hi all,

This question could have two answers, depending on whether I'm attempting this the right way round or not.

I'm trying to create composite elements for a diagram, so that when the element appears on the diagram it has the "sideways 8" Composite symbol on it and it can be double-clicked to jump into the sub-diagram.

I've created my element with subtype = 8 (Composite) as according to the automation reference, and added subelements/diagram within it.

Once I've created my main diagram, right-clicking on the element and viewing the "Advanced" menu shows the "Composite" option as already being ticked. However double-clicking the element just brings up the Properties window.

If I untick the Composite option on that menu, the text changes to "Make Composite". If I click that, the element then changes to show the Composite symbol and correctly links to the sub-diagram.

From what I can see at table level, all that's happening on "Make Composite" is that the diagram ID is being added to the element's PDATA1 field. So, how do I get this in there? Presumably either:

  • Write to the PDATA1 field - can't see how to go about this
  • Another method that I'm not aware of

As far as I can see, MISCDATA is read-only, and there is no PDATA access from the automation interface. SQL is SELECT statements only.

Any tips?

Thanks in advance,

James

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting element's PDATA value / Composite elem
« Reply #1 on: September 17, 2012, 08:19:18 pm »
James,

IIRC there is a recent addition to the API that exposes the "make composite" functionality.

If for some reason that doesn't work out, there are a number of (old to very old) posts about this topic that explain how to do it the hard way.

In short it involves using the undocumented method Repository.Execute(SQLString) to execute an SQL command that manipulates data. (insert, update, delete)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #2 on: September 17, 2012, 08:24:01 pm »
Quote
Whenever you check the Advanced/Make Composite flag for elements EA associates the first diagram inside the element with the element (if there is not diagram present, EA creates one).

This connection is persistent even if you move the diagram to somewhere else. While the element composite flag is identfied via

t_object.NType == 8

the according diagram reference is stored in t_xref:

Col - Value
-------------
Description - t_object.ea_guid
Client - t_diagram.ea_guid
Name - DefaultDiagram
Type - element property
Visibility - Public

From my book Inside EA.

q.

jamesl

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #3 on: September 17, 2012, 08:36:17 pm »
Many thanks to both of you for the prompt replies.

Geert -

I cannot seem to find any reference to an API function?

Also, I can't seem to find the Repository.Execute method - it's not showing up as valid in VBA for me. A search of the EA Object Browser via the IDE has nothing for "Execute".

I've tried various forum searches for PDATA, Miscdata, SQL update but can't see anything relevant.


Qwerty -

You say that the link is determined by the t_xref table - yet looking at this table (and t_xrefuser and t_xrefsystem) in my project it is completely empty, even after using "Make Composite" on various elements?

Thanks to you both

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting element's PDATA value / Composite elem
« Reply #4 on: September 17, 2012, 09:05:25 pm »
James,

Look at Element.IsComposite.

I think I mentioned that Repository.Execute is an [highlight]undocumented[/highlight] method. It doesn't show up in intellisense, but it works.

I'll see if I can find that old post again.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting element's PDATA value / Composite elem
« Reply #5 on: September 17, 2012, 09:11:45 pm »
Searching for "Composite" in this forum yielded lots of useful results:

In think this one contains the most info: http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1217982429/0

Geert

PS. you have to use the top left search button, not the top right search field.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #6 on: September 17, 2012, 09:40:45 pm »
Quote
Qwerty -

You say that the link is determined by the t_xref table - yet looking at this table (and t_xrefuser and t_xrefsystem) in my project it is completely empty, even after using "Make Composite" on various elements?

Thanks to you both
The table is t_xref. You should try once again (with an empty project). Apply Make Composite to a single element and you'll find the entry in t_xref.

q.

jamesl

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #7 on: September 17, 2012, 10:11:00 pm »
Geert -

Quote
PS. you have to use the top left search button, not the top right search field.

Ah - that explains why I never find anything useful! :-[ using the wrong search field...that post you've linked to is very helpful and contains everything I need. Maybe your webmaster should remove that extra search field...

I had actually tried setting IsComposite = True, but it didn't appear to work so I assumed it didn't have the complete Make Composite functionality.

My problem seems to be that I was doing this:

  • Adding element
  • Setting SubType = 8 (composite activity)
  • Adding diagram within element
  • Setting IsComposite = true

Remove the second bullet (setting SubType = 8) means it now works - I can only assume that if you've already set this attribute, when you call IsComposite EA thinks it has nothing to do and so silently ends.

Re Repository.Execute I assumed you meant undocumented as in not in EA's docs, as opposed to not listed in Intellisense - my mistake :)


Qwerty - t_xref it's still empty, but I think I know why. The topic that Geert links to suggests that the field usage is different for different element types. To quote:

Quote
For the record, can I just add a warning: the above applies to Components. Other object types do different things (e.g. Activities set t_object.PDATA1 to the DiagramID of the linked diagram) and I suspect this will remain undocumented and we reserve the right to change the representation, etc etc...

...so what you've said is true for some items but not others.


Thank you both for the assistance - EA becomes less of a mystery every day...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Setting element's PDATA value / Composite elem
« Reply #8 on: September 17, 2012, 10:23:55 pm »
Quote
Maybe your webmaster should remove that extra search field...
James, it's not my webmaster, I'm just a user like yourself  :)

Geert

jamesl

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #9 on: September 17, 2012, 10:46:29 pm »
Quote
Quote
Maybe your webmaster should remove that extra search field...
James, it's not my webmaster, I'm just a user like yourself  :)

Geert

With so much knowledge I assumed you must be a developer! This forum is lucky to have users with such in-depth knowledge (to both you and Qwerty)  :)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Setting element's PDATA value / Composite elem
« Reply #10 on: September 18, 2012, 06:34:07 pm »
Quote
Qwerty - t_xref it's still empty, but I think I know why. The topic that Geert links to suggests that the field usage is different for different element types. To quote:

Quote
For the record, can I just add a warning: the above applies to Components. Other object types do different things (e.g. Activities set t_object.PDATA1 to the DiagramID of the linked diagram) and I suspect this will remain undocumented and we reserve the right to change the representation, etc etc...

...so what you've said is true for some items but not others.


Thank you both for the assistance - EA becomes less of a mystery every day...
You're right! I wasn't aware of that fact. Seems I have to update my book in that respect.

Thanks for the pointer.

q.