Book a Demo

Author Topic: Automation Interface: Attribute Types  (Read 7081 times)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Automation Interface: Attribute Types
« on: May 10, 2009, 02:13:26 pm »
Hi!


Well I've finally taken the plunge into the Automation Interface.

I've written (well actually, Dan did in case he's reading this, but I'm the one who'll be doing the maintenance) a Java program to reverse-engineer one of our proprietary configuration languages.

This language has 'structs' which contain 'fields.' The fields in turn have a type, but structs cannot contain other structs, nor can fields contain other fields. In other words, the type system is very simple.

I have created a Profile to represent these entities in UML.

Now here's the problem. I can generate all the 'field' UML classes just fine, and also all the 'struct' UML classes. But the attributes in the 'struct' classes don't get the right types.

The class for a 'struct' is, of course, intended to use the 'field' classes for its attribute types. But while the name matches in the generated model, the actual reference is missing.

I've tested this by renaming a 'field' class which is being used in a 'struct' class. Normally when you do this, EA updates the type name in the using class. In my case this doesn't happen, indicating that the attribute type is not correctly referenced.

If I go into the dialog and set the attribute type to the exact same one by selecting it from the list, the test works.

The 'struct' and 'field' classes are in two packages, but I tried putting them in the same package and that didn't make a difference.

When I create my 'struct' class, I use the org.sparx.Attribute.SetType() method, simply specifying the name of the previously generated 'field' class.

What should I be doing?

Thanks,


/Uffe
« Last Edit: May 10, 2009, 02:28:34 pm by Uffe »
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #1 on: May 11, 2009, 01:23:32 pm »
Call SetClassifier().  This takes the ID of the class that is the type, you probably need to call both.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #2 on: May 11, 2009, 03:44:17 pm »
Hi!

Thanks. Problem: all my created classes return 0 for GetClassifier(). Am I in charge of setting these myself, or is there a way to get EA to assign them automagically?

/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #3 on: May 12, 2009, 09:44:01 am »
The attribute classifier corresponds to the target class object id.  You would use the object classifier if you actually had an object element.
« Last Edit: May 12, 2009, 09:44:30 am by simonm »

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #4 on: May 12, 2009, 09:19:09 pm »
Hey again,


Cheers for that, works beautifully.

I didn't immediately understand what you meant, so here's a clarification in case anyone else stumbles onto this thread and is as dense as me (yeah, I know... not likely).

Let's say class C contains an attribute A of type T, where T is another class. You should then set A.ClassifierID = T.ElementID. This sets the reference correctly. A.Type should be set to T.Name.


However, I also have a situation where I need to set a class tagged value to refer to a previously created class in the same way, but I'm running into a different issue there. The TaggedValue class has no SetClassifierID, only a SetElementID, and the PropertyID has no Set() method.

For a class C containing a tagged value of type T (specified in the profile using the taggedValue connector), where T again is a different class, I create the taged value by calling
Code: [Select]
TaggedValue Tag = C.GetTaggedValues.AddNew("TagName", "T");If I stop here, I get the tag but the reference isn't correct. But when I add
Code: [Select]
Tag.SetElementID(T.GetElementID());what happens is the tag isn't created. Or possibly it is removed just after, either way my class C in the resulting model does not have the tag TagName. No exception is thrown and GetLastError() gives me an empty string.

Any hints?


/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #5 on: May 13, 2009, 08:31:52 am »
The ElementID of a tag is the owner.  You may find that you've added the tag to the wrong element.

To create a tagged value referring to another element you will need to set its value to the guid of the other element.

EA will display the name (and stereotype) of the target element if you add the information from the RefGUID tagged value type into the notes.  (See http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/predefinedtaggedvaluetypes.html)

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #6 on: May 14, 2009, 06:25:07 pm »
Ooooh yeah, that works too.

Thanks!

Ran into a problem though, but I'm opening a separate topic for that.


/Uffe
My theories are always correct, just apply them to the right reality.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Automation Interface: Attribute Types
« Reply #7 on: May 14, 2009, 11:46:45 pm »
OK, one final question:

Is there any way I can set a RefGUID tag in a Model Transformation Template?

In a template, I create two classes C1 and C2. C2 has a RefGUID stereotype, whose value should be C1 - but I can't get at C1's GUID, only its name.

Any chance?


/Uffe
My theories are always correct, just apply them to the right reality.