Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Michael Hafner on October 09, 2011, 12:05:35 am

Title: Access Generalization Sets via Automatation?
Post by: Michael Hafner on October 09, 2011, 12:05:35 am
Dear all,
I need to read out information about generalization sets via script, but I seem unable to figure out how. I've tried connector attributes "Properties" and "CustomProperties" so far. Can it be done in EA9?

(I need to collect all classes which are elements of the same powertype to put them into a diagram.)

Thanx
Michael
Title: Re: Access Generalzation Sets via Automatation?
Post by: qwerty on October 10, 2011, 08:10:38 am
Read element.Connectors
For each connector check if the Type == "Generalization"
Figure out the opposite from conn.ClientID and .SupplierID (the one which is not element.ElementID)

q.
Title: Re: Access Generalization Sets via Automatation?
Post by: Michael Hafner on October 11, 2011, 04:39:10 am
Dear q,
thanks for your reply, but I think, there is a misunderstanding - my problem is not the identification of connectors of the type "Generalization".

You can (via the EA-client) assign to a Generalization one or more Generalization Sets (right click, "Advanced...", "Generalization Set").
A Generalization Set groups together a set of subclasses according to some criterion, e.g. a dimension or principium divisionis. (For the subclasses "Blue", "Green", "Red" of "Ball", the generalization set would be something like "Color"). Associated to a generalization set is (or may be (should be)) one Powertype, the instances of which are the members of the generalization set.

And it is information about this powertype I need to read out. I think, the information is stored in Table t_xref, but I don't know how to obtain it via the API.

Best,
Michael




Title: Re: Access Generalization Sets via Automatation?
Post by: Geert Bellekens on October 11, 2011, 06:30:06 pm
Wow, I had never heard about these generalization sets before.
Is that a known concept in UML? I don't understand what it is used for... :-[

Anyway, since this is a pretty exotic feature it probably isn't exposed in the API. What I usually do in these cases is use Repository.SQLQuery() to get the information I need directly from the database.

Geert
Title: Re: Access Generalization Sets via Automatation?
Post by: Michael Hafner on October 12, 2011, 02:44:17 am
Thanks, Geert - that's precisely what I needed! I, for my part, hadn't looked into the Repository class deeply enough to know about the SQL-Function. That's great information (I really love EA :-))!

- Yes, the Generalization Set is a UML concept. You can look it up in
http://www.omg.org/spec/UML/2.2/Superstructure/PDF, page 72f.
It may sound arcane, but if you are working with ontologies where you can't avoid multiple generalization, it comes in handy.

UML's example is about Persons being specialized by gender (Subclasses Male/Female) as opposed to specialization by employment status.

I use it for things like MediaObjects, where you need quadruple specialization with powertypes for, say, SignalType (Analog/Digital), Mode (Audio/Video...), Genre (Music/Speech...), and MediaType (Carrier/File...) to end up with the Analog_Audio_Music_Carrier, the Digital_Audio_Music_Carrier etc. Generalization sets help you to group together the associated relationships (resp. subclasses).

Thank-you very much indeed for pointing out this function to me!
Michael












Title: Re: Access Generalization Sets via Automatation?
Post by: Geert Bellekens on October 12, 2011, 06:18:38 pm
I just skimmed the part about GeneralizationSet in the superstructure, and oh boy, am I glad we don't use that :o (and I'm even happier I don't have to explain that concept in a training)
I'm really having difficulties seeing how an object can be both a "Male Person" as an "Employee".
Are there programming languages that allow an object to be of two types at the same time?

Geert


Title: Re: Access Generalization Sets via Automatation?
Post by: Michael Hafner on October 12, 2011, 07:53:33 pm
Well... - I think, the underlying concept is easy; we do this all the time on an everyday basis. "This Brunello is wonderful, but it's to expensive for me." - So obviously there are pricing levels as well as quality aspects to consider:

Generalization Set Price_Level { Expensive_Wine, Cheap_Wine }
Generalization Set Wine_Quality { Wonderful_Wine, Awful_Wine }

I think, multiple inheritance is indispensible in models dealing with semantics. And it might be practical for analytic models, even if you do have to resolve the multi-hierarchy into a mono-hierarchy during design. A matter of taste, I guess. It resembles de-normalization: After having normalized everthing by the book, you decide which tables you actually do need (and how many you can afford in terms of performane etc.).

I, for my part, do not really see the necessity to distinguish between powertype and generalization set. Outside UML (and programming), the terms "class" and "set" are often used more or less synonymously (not counting stuff like "ultimate classes"). Inside UML, a class isn't a set, but a descriptor for a set (outside: a UML::Class would be a specification of the class or set). So if sets go by their classes in UML - why suddenly use the set (generalization set) and the class (powertype) instead of just assigning a powertype?

Thanks again, M.
Title: Re: Access Generalization Sets via Automatation?
Post by: Eve on October 13, 2011, 08:38:26 am
t depends if you want the difference specified in the class model or object model. I think in general people deal with it more naturally in the object model by use of instantiating an association/property. In your wine example to two enumerations.

Instantiating an object model is more flexible, especially in terms of changing those properties dynamically. (eg. Your Brunello is on an amazing sale.) but there's no reason why you wouldn't want to use both. (sparkling/not, red/white plus the associations mentioned)

Title: Re: Access Generalization Sets via Automatation?
Post by: mrks on October 15, 2011, 07:37:50 pm
Quote
Repository.SQLQuery()

... can you give an example on this? - cheers
Title: Re: Access Generalization Sets via Automatation?
Post by: Geert Bellekens on October 15, 2011, 08:04:02 pm
https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EAWrappers/Operation.cs
Title: Re: Access Generalization Sets via Automatation?
Post by: mrks on October 15, 2011, 08:25:01 pm
Hi Geert - that looks pretty cool, ...

I have never heard about the add in framework before - it is currently confusing me a bit, can you please clearify... is this an extension or alternative to using the templates?
Title: Re: Access Generalization Sets via Automatation?
Post by: Geert Bellekens on October 16, 2011, 01:41:32 am
The add-in framework is a library on top of the EA API.
Amongst others there's also an add-in template class that you can extend.

More info on my blog.
http://geertbellekens.wordpress.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/
http://geertbellekens.wordpress.com/2011/02/16/the-complete-enterprise-architect-csharp-add-in-template/
http://geertbellekens.wordpress.com/2011/02/08/testing-and-debugging-your-enterprise-architect-csharp-add-in/

Geert
Title: Re: Access Generalization Sets via Automatation?
Post by: mrks on October 19, 2011, 05:21:56 am
Thanks! your blogs seem to be very useful!

I will give it a try later. for now I hope to find a more easy solution to read the link Source property - cheers!