Author Topic: Use of Tagged Values for version notes  (Read 2069 times)

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Use of Tagged Values for version notes
« on: March 25, 2020, 12:11:37 am »
Does anyone use Tagged Values as a way for the modeler to annotate changes to the model? I was thinking of a Tagged Value called "Change Description" that the modeler would use to describe what changed. There might be other Tagged Values identifying the reason and/or source of the change. You could then run a script or query to extract all of the changes into a neat report, publish the new version with the change information embedded in the model for reference along with the change report, clear out all of the same Tagged Values in the master and start over for the next version.

Thanks.

Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #1 on: March 25, 2020, 12:23:05 am »
Yeah, we do. I have a script that creates a tagged value CR on selected elemnets.
This tagged value links to a change object in the model.

We use the tagged value notes to store more info

user, date, comments.

see here: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/8ffb8a04ccc9a09d1c701ea7fb966dceaf640045/Projects/Project%20A/A%20Scripts/LinkToCRMain.vbs

For the script we use to link elements to a change object.

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #2 on: March 25, 2020, 01:55:14 am »
This is cool, thanks Geert! I have some dumb questions:
-What does CR stand for?
-When you say "change object" what are you referring to exactly?
-How are these functions triggered to run and when? It looks like maybe linkItemToCR runs while the user is making changes to the model?
-Can you confirm that linktoCR actually adds a row in one of the tagged value tables in the database?
-If so, why does linktoCR not use the input variable selectedItemType? Don't you need to know the item type to know which table to use?

Thanks very much and I hope the epidemic is not affecting your area of the country.

Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #3 on: March 25, 2020, 02:11:17 am »
This is cool, thanks Geert! I have some dumb questions:
-What does CR stand for?
Change Request
Quote
-When you say "change object" what are you referring to exactly?
We use EA's Change object from EA's maintenance toolbox (looks a bit similar to a requirement)
Quote
-How are these functions triggered to run and when? It looks like maybe linkItemToCR runs while the user is making changes to the model?
We have scripts in project browser and diagram groups. User right click on a number of items and then run the script from the context menu.
Quote
-Can you confirm that linktoCR actually adds a row in one of the tagged value tables in the database?
It creates a tagged value. Depending on the item that is in t_objectproperties, t_attribute_tag or t_connectorTag (we don't use t_operationTag or t_taggedValue for this purpose)
Quote
-If so, why does linktoCR not use the input variable selectedItemType? Don't you need to know the item type to know which table to use?
Each object we use has a property named TaggedValue, so the function doesn't need to know which type it is dealing with. Each TaggedValue has the same properties and can be dealt with the same way.
This is an advantage of using a non-strong typed language such as VBScript.
Quote
Thanks very much and I hope the epidemic is not affecting your area of the country.

Bill
Hope you and you family are spared as well.
Belgium is so small you could consider it as having only one area, but we have been in lockdown for a week and a half now.
Up till now we haven not gotten sick, so we have good hope to escape it.

Geert


[/quote]

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #4 on: March 25, 2020, 06:23:11 am »

>>Each object we use has a property named TaggedValue, so the function doesn't need to know which type it is dealing with.<<


Are you saying that every row in t_attribute has a corresponding row in t_attributetag in which the property is TaggedValue and the value is "attribute"?


Also, what is the relationship between your method and an MDG? Is your code part of an MDG?


Thanks again.


Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #5 on: March 25, 2020, 03:36:51 pm »

>>Each object we use has a property named TaggedValue, so the function doesn't need to know which type it is dealing with.<<


Are you saying that every row in t_attribute has a corresponding row in t_attributetag in which the property is TaggedValue and the value is "attribute"?
No, each attribute corresponds to a single record in t_attribute. Each tagged value on an attribute is a record in t_attributeTag.
What I'm trying to say is that, if you use the API, you can write the exact same code for to handle tagged values for elements, attributes and connectors. No need to know anything about the actual tables here.
Quote

Also, what is the relationship between your method and an MDG? Is your code part of an MDG?
No, just a script and a tagged value definition. Scripts and tagged values (that are not part of a UML profile) I usually transfer with reference data export.
I don't like the way MDG's modify them. Scripts all get put into the same group, and tagged values get the MDG name added like (myMDG::TagName)

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #6 on: March 25, 2020, 11:53:05 pm »
OK so you're saying that I can just follow the instructions here and then use your code as-is?
https://bellekens.com/2015/12/27/how-to-use-the-enterprise-architect-vbscript-library/

You're saying I should download the entire Library or just the LinkToCRMain.vbs?

Is there code in there to generate reports of the changes as well? This would really be great if it's as easy as it sounds.

Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #7 on: March 26, 2020, 12:13:45 am »
In this particular case I don't think you need the whole library

The main script is used by
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/Project%20A/Diagram%20Group/Link%20To%20CR.vbs
and
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/Project%20A/Project%20Browser%20Group/Link%20To%20CR.vbs

It uses also
https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Projects/Project%20A/A%20Scripts/Util.vbs

I do have some searches as well that we use to get the details out
Object by CR:
Code: [Select]
SELECT o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE,
re.Name AS Release, cr.StereoType AS ChangeType, cr.Name AS ChangeRequest, o.name AS ChangedItem,
substring(op.Notes, charindex('date=',op.[Notes]) + len('date='),10) as ChangeDate,
substring(op.Notes,charindex('user=',op.[Notes]) + len('user='),charindex(';date=', op.[Notes]) - (charindex('user=',op.[Notes]) + len('user='))) as UserName,
substring(op.Notes,charindex('comments=',op.[Notes]) + len('comments='),500) as ChangeComments,
package.name AS PackageName, package_p1.name AS Package_level1, package_p2.name AS Package_level2, package_p3.name AS Package_level3
FROM ((((((((t_object o
INNER JOIN t_objectproperties op ON o.Object_ID = op.Object_ID)
INNER JOIN t_object cr ON cr.ea_guid = op.value)
LEFT JOIN t_connector crre ON crre.Start_Object_ID = cr.Object_Id)
LEFT JOIN t_object re ON (re.Object_Id = crre.End_Object_Id AND re.StereoType = 'Release'))
INNER JOIN t_package package ON o.package_id = package.package_id)
LEFT JOIN t_package package_p1 ON package_p1.package_id = package.parent_id)
LEFT JOIN t_package package_p2 ON package_p2.package_id = package_p1.parent_id)
LEFT JOIN t_package package_p3 ON package_p3.package_id = package_p2.parent_id)
WHERE op.Property = 'CR'
and cr.Name like '#WC#<Search Term>#WC#'
AND o.Package_ID IN (#Branch#)

UNION

SELECT a.ea_guid AS CLASSGUID, 'Attribute' AS CLASSTYPE,
re.Name AS Release, cr.StereoType AS ChangeType, cr.Name AS ChangeRequest, o.name +'.'+ a.Name AS ChangedItem,
substring(atv.Notes, charindex('date=',atv.[Notes]) + len('date='),10) as ChangeDate,
substring(atv.Notes,charindex('user=',atv.[Notes]) + len('user='),charindex(';date=', atv.[Notes]) - (charindex('user=',atv.[Notes]) + len('user='))) as UserName,
substring(atv.Notes,charindex('comments=',atv.[Notes]) + len('comments='),500) as ChangeComments,
package.name AS PackageName, package_p1.name AS Package_level1, package_p2.name AS Package_level2, package_p3.name AS Package_level3
FROM (((((((((t_attribute a
INNER JOIN t_attributetag atv ON a.ID = atv.ElementID)
INNER JOIN t_object cr ON cr.ea_guid = atv.value)
LEFT JOIN t_connector crre ON crre.Start_Object_ID = cr.Object_Id)
LEFT JOIN t_object re ON (re.Object_Id = crre.End_Object_Id AND re.StereoType = 'Release'))
INNER JOIN t_object o ON a.Object_ID = o.Object_ID)
INNER JOIN t_package package ON o.package_id = package.package_id)
LEFT JOIN t_package package_p1 ON package_p1.package_id = package.parent_id)
LEFT JOIN t_package package_p2 ON package_p2.package_id = package_p1.parent_id)
LEFT JOIN t_package package_p3 ON package_p3.package_id = package_p2.parent_id)
WHERE atv.Property = 'CR'
and cr.Name like '#WC#<Search Term>#WC#'
AND o.Package_ID IN (#Branch#)
ORDER BY Release, ChangeType, ChangeRequest, ChangedItem

Objects by release:
Code: [Select]
SELECT o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE,
re.Name AS Release, cr.StereoType AS ChangeType, cr.Name AS ChangeRequest, o.name AS ChangedItem,
substring(op.Notes, charindex('date=',op.[Notes]) + len('date='),10) as ChangeDate,
substring(op.Notes,charindex('user=',op.[Notes]) + len('user='),charindex(';date=', op.[Notes]) - (charindex('user=',op.[Notes]) + len('user='))) as UserName,
substring(op.Notes,charindex('comments=',op.[Notes]) + len('comments='),500) as ChangeComments,
package.name AS PackageName, package_p1.name AS Package_level1, package_p2.name AS Package_level2, package_p3.name AS Package_level3
FROM ((((((((t_object o
INNER JOIN t_objectproperties op ON o.Object_ID = op.Object_ID)
INNER JOIN t_object cr ON cr.ea_guid = op.value)
INNER JOIN t_connector crre ON crre.Start_Object_ID = cr.Object_Id)
INNER JOIN t_object re ON (re.Object_Id = crre.End_Object_Id AND re.StereoType = 'Release'))
INNER JOIN t_package package ON o.package_id = package.package_id)
LEFT JOIN t_package package_p1 ON package_p1.package_id = package.parent_id)
LEFT JOIN t_package package_p2 ON package_p2.package_id = package_p1.parent_id)
LEFT JOIN t_package package_p3 ON package_p3.package_id = package_p2.parent_id)
WHERE op.Property = 'CR'
AND re.Name LIKE '<Search Term>'
AND o.Package_ID IN (#Branch#)

UNION ALL

SELECT a.ea_guid AS CLASSGUID, 'Attribute' AS CLASSTYPE,
re.Name AS Release, cr.StereoType AS ChangeType, cr.Name AS ChangeRequest, o.name +'.'+ a.Name AS ChangedItem,
substring(atv.Notes, charindex('date=',atv.[Notes]) + len('date='),10) as ChangeDate,
substring(atv.Notes,charindex('user=',atv.[Notes]) + len('user='),charindex(';date=', atv.[Notes]) - (charindex('user=',atv.[Notes]) + len('user='))) as UserName,
substring(atv.Notes,charindex('comments=',atv.[Notes]) + len('comments='),500) as ChangeComments,
package.name AS PackageName, package_p1.name AS Package_level1, package_p2.name AS Package_level2, package_p3.name AS Package_level3
FROM (((((((((t_attribute a
INNER JOIN t_attributetag atv ON a.ID = atv.ElementID)
INNER JOIN t_object cr ON cr.ea_guid = atv.value)
INNER JOIN t_connector crre ON crre.Start_Object_ID = cr.Object_Id)
INNER JOIN t_object re ON (re.Object_Id = crre.End_Object_Id AND re.StereoType = 'Release'))
INNER JOIN t_object o ON a.Object_ID = o.Object_ID)
INNER JOIN t_package package ON o.package_id = package.package_id)
LEFT JOIN t_package package_p1 ON package_p1.package_id = package.parent_id)
LEFT JOIN t_package package_p2 ON package_p2.package_id = package_p1.parent_id)
LEFT JOIN t_package package_p3 ON package_p3.package_id = package_p2.parent_id)
WHERE atv.Property = 'CR'
AND re.Name LIKE '<Search Term>'
AND o.Package_ID IN (#Branch#)
ORDER BY Release, ChangeType, ChangeRequest, ChangedItem

These searches have been developed for SQL Server and might not work for .eap files.

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #8 on: March 26, 2020, 12:46:09 am »
Thanks Geert!  :D

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #9 on: June 18, 2020, 02:48:25 am »
Hi Geert,
I am finally getting around to trying this out (Link to CR.vbs). I imported this script (and Util.vbs and LinkToCRMain.vbs) into my EAP file. I can run the script by right-clicking on an object in a diagram (Specialize -> Scripts). But nothing seems to happen. What am I missing?

Hope you're well. Thanks.

Bill

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #10 on: June 18, 2020, 03:14:34 am »
Hi Bill,


Not sure what is happening there. Have you tried to debug it and step through?

Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #11 on: June 18, 2020, 03:42:37 am »
I think I might need to take a few steps back:
- I noticed the code includes getUserLogin. Right now my file is unsecured. Do I need to add security and require a login?
- The purpose of this is to link elements to CRs, right? How do I enter a CR? What does EA recognize as a CR? I see the below in your code. Can you explain?

Bill

   sqlGetString = "select top 1 o.Object_id " & _
               " from (t_objectproperties tv " & _
               " inner join t_object o on o.ea_guid = tv.VALUE) " & _
               " where tv.[Notes] like 'user=" & userLogin & ";" & wildcard & "' " & _
               " order by  " & sqlDateString & " desc, tv.PropertyID desc "

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10172
  • Karma: +329/-30
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use of Tagged Values for version notes
« Reply #12 on: June 18, 2020, 04:00:43 am »
I don't think you need to enable security to get something from getUserLogin. IIRC it returns the windows username if you haven't enabled security.
The element we link in the CR tag is an EA Change element from the maintenance toolbox.

I store the userID, the date, and the comment in the notes of the tagged value.

With this query I get the element with the most recent CR tag done by the current user.
This allows the script to propose to link to the same CR (as often we link multiple things to the same CR)

Geert



Geert

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #13 on: June 18, 2020, 04:57:36 am »
Here's what shows up in the debug window.

Bill

[512023404]      Stack recording threshold set to 3 frames
[512023470]      Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[512023471]      Agent dll found: C:\Program Files (x86)\Sparx Systems\EA\SScript.DLL
[512023471]      Default Directory is C:\Program Files (x86)\Sparx Systems\EA
[512023471]      Agent: Started
[512023491]      Microsoft Process Debug Manager creation Failed: 0x80040154
[512023491]      This is included as part of various Microsoft products.
[512023492]      Download the Microsoft Script Debugger to install it.
[512023492]      Failed to initialize VBScript engine
[512023492]      Warning, all breakpoints failed to bind, check binaries built with debug information and source files synchronized with Model
[512023492]      Debug Session Ended

bholtzman

  • EA User
  • **
  • Posts: 86
  • Karma: +2/-0
    • View Profile
Re: Use of Tagged Values for version notes
« Reply #14 on: June 18, 2020, 05:39:25 am »
Stepping through the code it looks like it bombs at the CreateObject call.

function getSelectedElements(diagram)
   dim selectedElements
   set selectedElements = CreateObject("System.Collections.ArrayList")