Adding tagged values to certain elements

1,345 views
Skip to first unread message

ducatiross

unread,
Dec 15, 2014, 11:36:17 AM12/15/14
to sparx-enterprise-archite...@googlegroups.com
Hi everyone,

I need to add some tags and values to all elements of the Message stereotype in my model.

I have a relatively large number (250+) and I don't want to go through each one by hand adding the three tags I want and the values for each.

What would you suggest is the best way to do this ?

I would normally dive in and do an 'INSERT' statement against the SQL Server table t_objectproperty but I am concerned this will 'break' my model and wondered if there is a better way ? Also, I am a little unsure as to how to generate the ObjectID and ea_GUIDs correctly.

Initially, all Message elements would have the same 3 tags and the same 3 values for each tag.

I'd hoped I could do something at the object type level that would then apply the 3 tags to every instance of that object, but I can't see a quick way to do it.

I'm not a VB or C# programmer so I would be scared of scripting something unless it was at Idiot-capability level  :)

Any ideas much appreciated.

thanks

[original message]

qwerty

unread,
Dec 15, 2014, 12:56:26 PM12/15/14
to sparx-enterprise-archite...@googlegroups.com
If your tags are just stand-alone tags without connection to a MDG you could use a SQL which inserts in t_objectproperties. If the tags are part of a MDG then it's getting tricky...

q.

[original message]

Tomasz

unread,
Dec 16, 2014, 6:46:38 AM12/16/14
to sparx-enterprise-archite...@googlegroups.com
Maybe that C# implementation will help you:


EA.ConnectorTag tag = message.TaggedValues.AddNew("operation_guid", "String");
                       tag.Value = method.MethodGUID;                        
                       tag.Update();

                       message.TaggedValues.Refresh();
                       message.Update();


That's the example how to add Tagged Value to connector element.
But "TaggedValue" is available in other elements too.

[original message]

qwerty

unread,
Dec 16, 2014, 7:15:14 AM12/16/14
to sparx-enterprise-archite...@googlegroups.com
You neither need message.TaggedValues.Refresh (except you want to iterate over the collection in the following) nor message.Update since you have not changed it.

q.

[original message]

ducatiross

unread,
Dec 16, 2014, 9:55:24 AM12/16/14
to sparx-enterprise-archite...@googlegroups.com
Thank you both, but as I don't know any C# I don't really understand this. Is there a way to generate the EA_GUID and Property/Object IDs from a SQL statement ? If not, I may have to learn C# !!
[original message]

qwerty

unread,
Dec 16, 2014, 10:05:59 AM12/16/14
to sparx-enterprise-archite...@googlegroups.com
You can use any programming language you might know :-)

Using SQL is not that difficult. Finding the element GUIDs is
Code:
SELECT ea_guid FROM t_object WHERE t_object.Stereotype = "Message"


Inserting into t_objectproperties would need the column Object_ID as well since that needs to be stored along with the tag info to link it to the element.

q.

[original message]

ducatiross

unread,
Dec 17, 2014, 4:16:25 AM12/17/14
to sparx-enterprise-archite...@googlegroups.com
q. - I am happy selecting existing fields (EA_GUID, Object ID etc) from records using SQL. What I am asking is that if I am to INSERT new records into t_objectproperties for my 3 tags and their values, I need to be able to generate NEW ea_GUIDs and Object_IDs in this table, and I don't know how to do this.

Does the t_objectproperties table have a trigger on it that automatically sets the ea_GUID and Object_ID when a record is inserted into it if the appropriate field is set to NULL ?

If not, how do I generate new ea_GUIDs and Object_IDs ?

thanks for your continued assistance. It's appreciated.

[original message]

qwerty

unread,
Dec 17, 2014, 6:15:26 AM12/17/14
to sparx-enterprise-archite...@googlegroups.com
GUIDs are GUIDs. There are lots of libraries that can generate them. Depending on the language/library of your choice select one GUID generator and use it.

Object_IDs are unique numbers per repository. If haven't tried, but when you omit it on insert the DB should generate it as unique key automatically.

q.

P.S. Just made a test with EAP and there it works.

Code:
Repository.Execute("INSERT INTO t_object (Name, ea_guid) VALUES ('test', '4711')")
Of course you will not see it in the browser, but Object_ID is set automatically.

[original message]

ducatiross

unread,
Dec 17, 2014, 11:25:08 AM12/17/14
to sparx-enterprise-archite...@googlegroups.com
Great thanks q. I will give this a try.
[original message]

ducatiross

unread,
Dec 17, 2014, 12:56:13 PM12/17/14
to sparx-enterprise-archite...@googlegroups.com
OK, I've given this a try in the Project Search window of EA, but whilst it accepts SELECT statements, it doesn't seem to run INSERT statements as I cannot get any records inserted to t_objectproperties.

Here is my statement :-
Repository.execute("insert into t_objectproperties ( Object_id, Property, Value, ea_guid) values (243,'MsgMechanism','Unknown','{EA591C5B-2E8F-4448-8358-31AA96F4B712}' )")
Repository.Update()

Nothing seems to happen.

Nor does it if I run a simple INSERT statement without the Repository.execute method.

I think I need to read your 'Scripting EA' book - qwerty !

[original message]

qwerty

unread,
Dec 17, 2014, 1:15:43 PM12/17/14
to sparx-enterprise-archite...@googlegroups.com
This is a VB statement. Run it in a VB script. You must not supply the object_id, it is created automatically.

There is no Repository.Update. Leave that away.

q.

[original message]

ducatiross

unread,
Dec 18, 2014, 8:05:58 AM12/18/14
to sparx-enterprise-archite...@googlegroups.com
I have done some more reading and opened the Tools>Scripting window (for the first time) and found loads of useful stuff, including a VB Script to add a tagged value to an element - TVSetElementTaggedValue - just want I wanted !!

I will now brush up my VB scripting skills and give this a try as it seems to be exactly what I was after.  :)

[original message]

qwerty

unread,
Dec 18, 2014, 8:25:27 AM12/18/14
to sparx-enterprise-archite...@googlegroups.com
It's almost never too late  ;)

q.

[original message]

ducatiross

unread,
Dec 19, 2014, 10:55:40 AM12/19/14
to sparx-enterprise-archite...@googlegroups.com
I've been looking into this further, and whilst the VBScript approach would update existing elements, what I really want to do is this and ensure that any future Message element created automatically has the Tags I want.

I've been reading the help file, and found that there is a feature where I can Synchronise Stereotypes. The help for this says :-

"When you create an element, attribute, operation or connector from a profiled object, the Tagged Values and constraints are added from the Profile stereotype. Subsequently, you might update the constraints or Tagged Values of a particular stereotype in the Profile, in which case the items already created in the model would not have those additional constraints or Tagged Value tags and notes."

"You can apply the updated or missing Tagged Values and constraints using the Synchronize Stereotype function. This operates on any profiled element in your model, from any technology that is integrated with or imported into Enterprise Architect."


Now, this sounds like just what I want in that it will add the tags to all existing Message elements, and also, when I create new ones, add the tags to these as well.

However, I cannot find a way to modify the standard Message (in the BPMN 2 toolbox) to add the three tags I want. I don't understand the help as it talks of editing the Profile. Where do I find the Profile for the Message element and how then do I edit it to add the Tags I want ?

I've spent  a good few hours looking, but without success (I have tried the Profile toolbox, but I didn't understand it or do the right thing) , so I am now hoping that my Sparxian experts will point me in the right direction !

[original message]

qwerty

unread,
Dec 19, 2014, 11:05:34 AM12/19/14
to sparx-enterprise-archite...@googlegroups.com
Look into this: http://community.sparxsystems.com/tutorials/552-24intro-to-creating-a-mdg-file

Not that applying a stereotype will only add tags automatically from V10 on. Before you need to explicitly synch TVs.

q.

[original message]

ducatiross

unread,
Dec 19, 2014, 11:25:59 AM12/19/14
to sparx-enterprise-archite...@googlegroups.com
Thanks q. I will.
[original message]

RIL

unread,
Dec 22, 2014, 4:05:50 PM12/22/14
to sparx-enterprise-archite...@googlegroups.com
Hi qwerty,

Regarding Synchronization of TVs : Is there a way to call Syncronize Stereotypes for model Elements via VBScript?

In my case I need it for AssociationEnds (which is missing in the menu in EA10).

// Rolf Lampa

[original message]

qwerty

unread,
Dec 22, 2014, 4:36:02 PM12/22/14
to sparx-enterprise-archite...@googlegroups.com
Hi Rolf,
I'm not sure about the AssociationEnds (we discussed this in a different thread, didn't we?) since I forgot the outcome (my ultra short time memory). However, IIRC in V10 the new behavior was already present so a synch would not be necessary. You might try the Repository method
Code:
bool SynchProfile (string Profile, string Stereotype)
anyway to see whether it has an effect.

q.

[original message]

RIL

unread,
Dec 22, 2014, 5:25:35 PM12/22/14
to sparx-enterprise-archite...@googlegroups.com
Hi again qwerty,

Thank you for your reply. For some reason "Repository.SynchProfile" applies the (role) Stereotype on the Association itself instead of on the AssociationEnds (Roles). (This is the old problem I tried to solve already a year ago).

However, I finally got the following code to work (poking directly on the role), like so:


Code:
link.SupplierEnd.StereotypeEx = "my stereotype"


What I had tried, which did NOT work, was this:

Code:
link.SupplierEnd.Stereotype = "my stereotype"


(that is, "Stereotype" instead of "StereotypeEx".

What does "...Ex" stand for?

// Rolf Lampa

[original message]

qwerty

unread,
Dec 22, 2014, 6:06:31 PM12/22/14
to sparx-enterprise-archite...@googlegroups.com
Ex stands probably for EXtended. I know that for classes it returns the comma separated list of all stereotypes set for the class (what if you have a stereo with comma inside??). Well, that's just one of those strange things a bad architect did allow to be coded in EA :-( It's kind of voodoo. In Attributes for example you need to supply StereotypeEx instead of Stereotype. Strange enough there's also a GetStereotypeList method (yuck).

q.

[original message]

M@localhost Simon M

unread,
Dec 23, 2014, 5:05:26 PM12/23/14
to sparx-enterprise-archite...@googlegroups.com

686E7C6B6D60190 wrote:
... (what if you have a stereo with comma inside??). Well, that's just one of those strange things a bad architect did allow to be coded in EA :-(

What would happen to UML if you had a comma in the stereotype? The diagram notation has the exact same issue. For the standard serialization format it's flat out illegal.

Sure, a comma separated list requires more work for the client to split apart, but that's not my biggest regret of that API function; that's the inability to tell the difference between a BPMN1.1::Pool and a BPMN2.0::Pool. Both just list Pool. Shape scripts handle this particular issue much better. The condition HasProperty("stereotype", "BPMN2.0::Pool") queries the entire list of stereotypes for a matching stereotype. In this case it's looking in a single profile, but even better. If any stereotype (including from another profile) extends the requested stereotype it will match that too. Of course given that shape scripts are only applied using a stereotype this only useful for multiple stereotypes and the child element or related element scripts.

[original message]

qwerty

unread,
Dec 23, 2014, 5:47:00 PM12/23/14
to sparx-enterprise-archite...@googlegroups.com
Simon,
the fact that the UML/OhMyGod guys did a bad job must not mean a tool developer must adopt it. There's a well know construct called collection which would perfectly suit returning a list of stereotypes. However, don't let us get upset about such minor tidbits. I tend to pour salt in open wounds. Eventually, I learned in the past, people tend to cure those wounds once there's enough salt being poured out.

Merry Christmas to you and the other guys down under :)

q.

[original message]

Christoph

unread,
Apr 14, 2020, 6:42:56 AM4/14/20
to Sparx Enterprise Architect General
In PostgreSQL you can use

SELECT upper('{'||(uuid_in(md5(random()::text || clock_timestamp()::text)::cstring))||'}'::varchar);


Regards,

Christoph

Reply all
Reply to author
Forward
0 new messages