Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: RIL on December 14, 2014, 08:59:22 am

Title: Tagged Values for Roles?
Post by: RIL on December 14, 2014, 08:59:22 am
Hi all,
I have EA10 Ultimate which does not have TVs for Roles (which is a showstopper for my code generation, which needs to regard several additional properties for association roles).

Does any later version of EA introduced TVs for roles?

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 14, 2014, 09:46:25 pm
Can you tell us how you create a Role?

q.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 15, 2014, 12:31:53 pm
Quote
Can you tell us how you create a Role?

Sorry, "roles" are of course implicit in the model ("target" and "source"), I actually meant to say that for these (roles/association-ends) it seems that I cannot apply a meta class as to make the TVs be inserted automagically for a stereotype (it works only for the association itself, not for the association ends).

That means that I'd have to define all TVs manually for each association end (role), but I need more than ten TVs for each role so that's not an option really.

Is this fixed in later versions than EA10?

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: Eve on December 15, 2014, 03:49:09 pm
In the current version, applying the stereotype will automatically add all the tagged values. I think you can also drag a stereotype extending an AssociationRole from the toolbox to the end of an existing connector to apply it.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 15, 2014, 07:41:33 pm
OK, hopefully I can test this with the EA11 trial before upgrading?
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 16, 2014, 12:04:18 am
I guess that should work. (My above question was due to a too late evening - I was looking for some Role element ::))

q.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 16, 2014, 05:27:06 am
Quote
I guess that should work. (My above question was due to a too late evening - I was looking for some Role element ::))

I wrote the first question at a too late hour too. :)

I tried EA11, and yes, now it works. That is, the TVs are now attached to each end role (instead of only to the Association itself) and moreover,  when right-clicking on a Stereotype in the ToolBox I can update that Stereotype in the entire model.

3 more problems:

1. Now to figure out how to create new model elements (classes, attributes, operations and links) with the correct Stereotypes included already from creation!
Q: Any good tutorials out there?

2. I have a broken link between Stereotypes and UML Types (in Settings | UML Types) which also is stuck in the Stereotype-list and so it cannot be removed. (The delete button is disabled when the broken one is selected). I can create a new copy and delete the new one, but not the broken one. This causes two identical Stereotypes to show up when defining Stereotypes in model elements .
Q: How can I remove a broken link between Stereotype & UML Type?

3. For some reason TVs without a value or default value (should be void) suddenly returns the following crap value instead of an empty string: "$ea_notes=". TVs with valid values returns its value as expected, only the empty TVs returns this strange crap ("$ea_notes="). This odd "value" started to show up after I had updated the Stereotypes as described in the beginning of this post.

Q: Any clue about why this is, and most important, how do I fix this? (I have hundreds of reads of TVs in my code generation so I hesitate to add an additional check
if TV != "" and TV != "$ea_notes=" ... :)

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: RIL on December 16, 2014, 07:22:30 am
Hm, isn't there any patches for EA10* fixing this hassle with Stereotypes?

I mean, $699 is pretty much only for fixing that little bug (EA10 Ultimate ->EA11).

No upgrade prices either?

// Rolf Lampa

* I have EA 10.0.1006
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 16, 2014, 09:00:51 am
1. Isn't that simply creating a MDG (or using an existing one) and dragging the element/stereotype in question onto the diagram?

2. I haven't heard of such broken links so far. Probably you should report that as bug (link bottom right of this page). Also try deleting the connector from the Relations window. Will that work? As a last resort: write a script or SQL to get rid of it.

3. no idea. I stopped using this crude macros years ago in favor of scripts.

Bonus question: you're probably pissed here. I just have corporate and that 60€ are affordable anyway (even if I dislike some of the "updates").

q.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 16, 2014, 09:09:51 am
1. Well yes, but if I drag a, say, "<<myAssociation>>" to the diagram, then my new association should also have its Stereotypes set for the association ends to "<<myRole>>", but now the Stereotype fields are empty for the association ends after the association is created.

2. :(

3. The crappy results was produced during Code Generation. Is there any other way to generate code?  (I'd really like to be able to generate attributes for outgoing links, for example, but I don't think one can determine the direction of a link (from a Class context) in the Code Gen.  :(

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 16, 2014, 10:03:29 am
1. I haven't been swimming in that water. Maybe one of the Sparxian can help.

q.
Title: Re: Tagged Values for Roles?
Post by: Eve on December 16, 2014, 04:46:06 pm
Quote
2. I have a broken link between Stereotypes and UML Types (in Settings | UML Types) which also is stuck in the Stereotype-list and so it cannot be removed. (The delete button is disabled when the broken one is selected). I can create a new copy and delete the new one, but not the broken one. This causes two identical Stereotypes to show up when defining Stereotypes in model elements .
Q: How can I remove a broken link between Stereotype & UML Type?
Is one coming from a technology imported into your model? You may not be able to see from that list, but if you look in the resources window and find your technology imported there it may be an answer.

Quote
3. For some reason TVs without a value or default value (should be void) suddenly returns the following crap value instead of an empty string: "$ea_notes=". TVs with valid values returns its value as expected, only the empty TVs returns this strange crap ("$ea_notes="). This odd "value" started to show up after I had updated the Stereotypes as described in the beginning of this post.
Pretty sure I remember that some tagged value tables in EA don't have a notes field. That identifier was used to separate notes from the value proper. Not sure why it's showing up for you though.

Quote
Hm, isn't there any patches for EA10* fixing this hassle with Stereotypes?

I mean, $699 is pretty much only for fixing that little bug (EA10 Ultimate ->EA11).

No upgrade prices either?
Only the current version will get any fixes. There is an upgrade pricing, if you haven't receive (or have misplaced) your renewal email then contact our sales department. Additioanlly, each purchase includes a year worth of upgrades.

Quote
1. Well yes, but if I drag a, say, "<<myAssociation>>" to the diagram, then my new association should also have its Stereotypes set for the association ends to "<<myRole>>", but now the Stereotype fields are empty for the association ends after the association is created.
There's no built-in way to specify that associations with one stereotype should cause their roles to be stereotyped too. Or at least not one that I know of.

Quote
3. The crappy results was produced during Code Generation. Is there any other way to generate code?  (I'd really like to be able to generate attributes for outgoing links, for example, but I don't think one can determine the direction of a link (from a Class context) in the Code Gen.  :(
Code gen only calls the Linked Attribute template for associations that it believes need to be generated. But there's no way to customize what those conditions are.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 05:34:28 am
Quote
Quote
2. I have a broken link between Stereotypes and UML Types (in Settings | UML Types) which also is stuck in the Stereotype-list and so it cannot be removed. (The delete button is disabled when the broken one is selected). I can create a new copy and delete the new one, but not the broken one. This causes two identical Stereotypes to show up when defining Stereotypes in model elements .
Q: How can I remove a broken link between Stereotype & UML Type?
Is one coming from a technology imported into your model? You may not be able to see from that list, but if you look in the resources window and find your technology imported there it may be an answer.
No, it looks good in the resource file (only one instance). Thus the broken fragment seems to be an orphan residing in the database.

I'd be thankful for a script (preferably VBscript) accessing and removing the orphan? (name: "bold.attr" (name doesn't show in the edit fields, see fig 1.) with the erroneous stereotype: "property".

Fig 1: Orphan:
(http://imageshack.com/a/img674/2492/tAWOfs.png)

Fig 2: The valid one:
(http://imageshack.com/a/img537/1314/zpSy04.png)



Quote
Quote
3. For some reason TVs without a value or default value (should be void) suddenly returns the crap value instead of an empty string: "$ea_notes=". TVs with valid values returns its value as expected, only the empty TV values returns this strange crap ("$ea_notes="). This odd "value" started to show up after I had updated the Stereotypes as described in the beginning of this post.
Pretty sure I remember that some tagged value tables in EA don't have a notes field. That identifier was used to separate notes from the value proper. Not sure why it's showing up for you though.
No, nothing there. Preview shows this :
Code: [Select]
<TaggedValues>
<Tag name="Bold.CPPName" type="Bold.CPPName" default="" values="" unit="" description=""/>
Both "default" and "values" have (proper) empty strings, no crap in them, so either there's a bug in the importer (probably not, because it looks good in the TV editor after import), or (more probable) in the code generator.  The code generated result :
Code: [Select]
"...,Bold.CPPName=$ea_notes=,..."(the "$ea_notes=" shouldn't there. Expected result should be no value at all).

As you pointed, there is no such thing as a "note" field in the TVs, so one possibility is that someone has planned for a future note field and that that extra note field is referenced, perhaps as an intermediate (extra) Json field when retrieving model element data internally for the code gen?



Quote
Quote
Hm, isn't there any patches for EA10* fixing this hassle with Stereotypes?

I mean, $699 is pretty much only for fixing that little bug (EA10 Ultimate ->EA11).

No upgrade prices either?
Only the current version will get any fixes. ...
The hassle with stereotypes was discussed here (on the forum) long before EA11 came. I had to abandon my projects then, but now again I have even bigger need for supporting special code generation.



Quote
Quote
1. Well yes, but if I drag a, say, "<<myAssociation>>" to the diagram, then my new association should also have its Stereotypes set for the association ends to "<<myRole>>", but now the Stereotype fields are empty for the association ends after the association is created.
There's no built-in way to specify that associations with one stereotype should cause their roles to be stereotyped too. Or at least not one that I know of.
OK, I have made a VBscript that iterates the model and inserts stereotypes for roles where they're missing. Is there a way to run scripts automatically at certain UI events or the alike? Or a quick meny for running scripts for "current" model elements?



(continued, post too long)...
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 05:49:45 am
Continued:

Quote
Quote
3. The crappy results was produced during Code Generation. Is there any other way to
 generate code?  (I'd really like to be able to generate attributes for outgoing links, for
 example, but I don't think one can determine the direction of a link (from a Class
context) in the Code Gen.  :(
Code gen only calls the Linked Attribute template for associations that it believes need to
 be generated. But there's no way to customize what those conditions are.
Event triggers: - Is it possible to call a predefined VBscript from the code generator when an association is detected (and also output any generated "attribute" result strings into the right place, that is, among attributes)?

Transform model?: - Or, another option, would it be possible to "transform" links into attributes into a new (intermediate) model, and then generate the final code from that model?

My own code gen?: - If none of the above, I guess I'm forced to write my own code generator from scratch in VBscript. But I'm afraid that VBscript is very slow and I have very big models to deal with (>250 classes with average 5+ associations and 10+ attributes per class, with average 15+ TVs per model element (class, attributes & links & roles).

Fastest model dump ever?: - What's the fastest way to dump a model into a readable format? Is there any Json exporter for example?

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 17, 2014, 06:35:43 am
Quote
Event triggers: - Is it possible to call a predefined VBscript from the code generator when an association is detected (and also output any generated "attribute" result strings into the right place, that is, among attributes)?

Transform model?: - Or, another option, would it be possible to "transform" links into attributes into a new (intermediate) model, and then generate the final code from that model?

My own code gen?: - If none of the above, I guess I'm forced to write my own code generator from scratch in VBscript. But I'm afraid that VBscript is very slow and I have very big models to deal with (>250 classes with average 5+ associations and 10+ attributes per class, with average 15+ TVs per model element (class, attributes & links & roles).

Fastest model dump ever?: - What's the fastest way to dump a model into a readable format? Is there any Json exporter for example?

// Rolf Lampa
triggers -  I don't know but would guess that no.

transform - I (again) guess that this would be possible. Though I don't like the transformation idea (or the way it is handled in EA) for various reasons.

own generator: I once did that with Perl and it was (at another guess) not too much slower than a native Cxx implementation. Most time is wasted in accessing the database. So if you have an idea what to do you can optimize that quite a lot. Even with the API if you got the idea how EA bundles (or doesn't bundle) queries.

fastest: Likely XMI. This is bound into EA and (likely?) rather optimized. I guess it is feasible to use XSLT to convert it to JSON. But probably (at least for me) it's easier to create the JSON via automation.

q.
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 17, 2014, 06:40:54 am
Quote
Quote
OK, I have made a VBscript that iterates the model and inserts stereotypes for roles where they're missing. Is there a way to run scripts automatically at certain UI events or the alike? Or a quick meny for running scripts for "current" model elements?
You can do that be writing an add-in. It can catch some of the user interaction and do some magic. It's probably possible event with VB if you use WSH (just a good guess again). I was able to do that with Perl at least. However, a language that can compile is preferred as you need to register your add-in.

Add-ins are also useful for on-the-fly interactions as you get them offered via context menu.

q.
Title: Re: Tagged Values for Roles?
Post by: Eve on December 17, 2014, 10:32:45 am
Don't look in your file. I said look in the resource tree for an imported technology. In later versions we've offered an alternate way of importing a technology into a model (more value for your upgrade price) but older versions would have imported the technology by splitting it up across multiple tables, including the stereotypes table. It would then prevent deleting that stereotype because it would invalidate the rest of the technology.

(It's possible that the problem could just be a profile as well)

All EA tagged values allow you to enter notes. (There's a button on the tagged values dialog) to enter them. You won't find the "$ea_notes" in your resource file. It's in the back end database (I'm guessing this problem only applies to your association role tags and parameter tags if you're using them) The GUI knows to look for this hidden identifier. It probably only impacts code generation (but I wouldn't rule out it impacting report generation either)

Regarding code generation from attributes, there is an option I forgot. Add a custom template of type Connector. You then get raw access to all(?) fields of a connector including access to objects at either end. Then you add the appropriate list over it. Just be aware that you need to determine the direction yourself. (eg. connectorStartElemGUID=classGUID)
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 03:20:47 pm
Quote
Don't look in your file. I said look in the resource tree for an imported technology.
Nope, not there. :(

Now what?

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: Eve on December 17, 2014, 05:10:29 pm
Open the search window, go to edit and find the SQL Scratch pad.

Run the following:
Code: [Select]
select * from t_stereotypes where Stereotype='bold.attr'What does that give you? By my theory you would have some contents in VisualType (the last column)
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 05:29:10 pm
Quote
Code: [Select]
select * from t_stereotypes where Stereotype='bold.attr'What does that give you? By my theory you would have some contents in VisualType (the last column)
I get this: (hit!)
No VisualStyle though.

(http://imageshack.com/a/img907/4672/IIzSpd.png)

Can I delete the second item from this SQL editor?

// Rolf Lampa
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 06:00:18 pm
I tried to run the following SQL but nothing changed:

Code: [Select]
delete from t_stereotypes
where Stereotype='bold.attr'
and ea_guid='{090C472D-EEF0-4764-A337-3D757332E3FF}'
Title: Re: Tagged Values for Roles?
Post by: qwerty on December 17, 2014, 06:03:07 pm
You can't run that from the SQL window. It only allows SELECT. Use either a M$ Access client or run the SQL from a VB script that has a
Code: [Select]
Repository.Execute("your sql")statement.

q.
Title: Re: Tagged Values for Roles?
Post by: RIL on December 17, 2014, 06:08:12 pm
Fixed. Many thanks!

// Rolf Lampa