Author Topic: Can we set Package.TaggedValues  (Read 7699 times)

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Can we set Package.TaggedValues
« on: July 15, 2009, 04:17:08 am »
Can we set Package.TaggedValues with the automation interface? I was looking through the API and found nothing on it; and I tried it and it didn't work. Is it something I did or is it not supported?

Here is the code that i used:

EA.TaggedValue package_value = (EA.TaggedValue)package.TaggedValues.AddNew("Id", "");

Thanks in Advance,

Alin

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #1 on: July 15, 2009, 09:35:30 am »
Every Package object (with the exception of the root model node) has an associated Element object accessible through the Package.Element property.  You will need to assign the Tags to the TaggedValues collection on the Element object.

Example:

EA.TaggedValue tag = (EA.TaggedValue)package.Element.TaggedValues.AddNew("Id", "");
tag.Value = "1";
tag.Update();

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #2 on: July 15, 2009, 09:39:13 am »
Quote
Every Package object (with the exception of the root model node) has an associated Element object accessible through the Package.Element property.  You will need to assign the Tags to the TaggedValues collection on the Element object.

Example:

EA.TaggedValue tag = (EA.TaggedValue)package.Element.TaggedValues.AddNew("Id", "");
tag.Value = "1";
tag.Update();

Yes thank-you, but how do you add a tagged value to the Package itself, not the element within that package?

Using the automation interface.

Regards,

Alin

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #3 on: July 15, 2009, 09:41:11 am »
Aaron,

EA.TaggedValue package_taggedID = (EA.TaggedValue)package.TaggedValues.AddNew("Id", "");

this would logically create a tagged value for the package, but it does not work cause package does not support it, is there any other way?

Regards,

Alin

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #4 on: July 15, 2009, 10:39:02 am »
Quote
Yes thank-you, but how do you add a tagged value to the Package itself, not the element within that package?
It's not adding tagged values to an element contained by that package.  Each package is represented by an element that contains all the general element properties.  This is where Aaron's example is adding a tagged value.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #5 on: July 15, 2009, 01:40:00 pm »
If you've got the latest build of EA (846) there is an example VB Script included which illustrates how to set a Package's stereotype. See VBScript - Manage Packages Example.vbs: lines 42 - 47.

Alternatively, if you check the Java Example (%EA_INSTALL_DIR%\Code Samples\Java_Sample\src) there is a Java implementation of the same example. See ManagePackagesExample.java: lines 78 - 82.
Best Regards,

Michael

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

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #6 on: July 15, 2009, 09:03:17 pm »
At the risk of an unnecessary repetition...

The way EA handles packages is something you have to get used to, but it makes good sense. There are two 'parts' (for lack of a better word) that cooperate to provide Package functionality. Note that what goes in which part is sometimes a judgment call; Sparx did a pretty good job here but you may have to check the documentation from time to time. Here's how they handle Package capabilities.

Things that are particular to package, including hierarchies of 'inner' packages and such, are features (attributes and methods) of the Package class. This is how you've been handling packages so far. No need to change anything.

Things that are common to all (or most) elements in UML are handled a different way. This sort of thing includes the collection of tagged values, as well as other common properties and methods. In these cases the Package class works like any other Element in EA; Sparx handled this by exposing the 'inner Element' of the Package class, and using that to provide these features.

You will find an Element property of the Package class; this returns an Object that can be cast to type "EA.Element" to your program. This Element is not a 'contained' element, and does not appear in the Elements list of the Package. It is the Package itself! [Check the GUID and you'll see that it matches that of the Package.]

When you need to work with element-like features of the Package class, you access these through the Element property. In your case you would obtain the Element reference via the property, then use AddNew to create the tagged value. Something like

EA.Element packElem = (EA.Element)myPack.Element;
EA.TaggedValue tv = (EA.TaggedValue)packElem.TaggedValues.AddNew("Id","");

...and so on. [Please forgive if I got the punctuation wrong, I'm in a hurry.]

HTH, David
No, you can't have it!

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #7 on: July 16, 2009, 01:55:03 am »
Is there an updated SDK for build 846? And where can I find it in PDF form?

Regards,

Alin

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #8 on: July 16, 2009, 04:00:36 am »
Or is there a changlist for build 846?

Thanks,

Alin Dobre

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #9 on: July 16, 2009, 09:38:46 am »

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #10 on: July 16, 2009, 09:40:46 am »
Thank-You very much Simon.

Regards,

Alin Dobre

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #11 on: July 16, 2009, 09:57:20 am »
Release Notes for build 846: [EDIT: Ahhh - Simon got there while I was checking things out for this reply!]

http://www.sparxsystems.com/products/ea/history.html#846

The SDK forms part of the documentation integrated with the product (click on the Help | Help Contents menu option) - it is the second-to-last main topic.

There is a pdf version of the Help on:

http://sparxsystems.com/bin/EAUserGuide.pdf

We also provide separate pdf documents for each of the main topics (and a couple of the second-level topics) on the Resource Documents web page. HOWEVER, we are working on mechanisms for streamlining the more frequent update of these pdfs, and as these mechanisms are not yet in place, the Resource Documents (and web Help) currently are not updated for the minor releases.
« Last Edit: July 16, 2009, 09:59:00 am by RoyC »
Best Regards, Roy

Alin Dobre

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Can we set Package.TaggedValues
« Reply #12 on: July 16, 2009, 10:01:52 am »
Thanks again Admins

Regards,

Alin Dobre