Login  ·  Register


Sparx Systems EA - Script - Delete Specified Tagged Value Across Repository

Posted: 23 December 2011 12:09 PM   [ Ignore ]
Total Posts:  52
Joined  2009-12-04

The following is a script (JScript) for Sparx Systems’ Enterprise Architect that will delete a specified tagged value across a repository (project). As usual no guarantees are offered and you should backup your project before running it.

This is a by product of the development of the forthcoming MDG Technology for TRAK version 0.124 which implements the change (#3418285) to the TRAK metamodel where normal english is used rather than ‘softese’ i.e. ‘Concept Activity’ instead of ‘Concept Activity’ and ‘tools used’ for ‘toolsUsed’. The idea is to make it easier for anyone to read any view since it’s all about communication of ideas.

Most of the development activity at the moment is to provide supporting scripts to change the names of the tagged values and stereotypes affected and to preserve values.

The script to delete a tagged value is

!INC Local Scripts.EAConstants-JScript

 * Deletes object attribute (not connector attribute) name across entire repository.
 * NOTE: Backup uo before running
* Nic Plum Eclectica Systems Ltd
function deleteAttribute(oldAttName)
// Show the script output window
Repository.EnsureOutputVisible"Script" );

allExistingElements as EA.Collection;
currentAttribute as EA.Attribute;
theElement as EA.Element;
taggedValue as EA.TaggedValue;
//limit operation to those elements having a tagged value with the correct name
var SQLstatement="SELECT t_object.Object_ID FROM t_objectproperties INNER JOIN t_object ON t_objectproperties.Object_ID = t_object.Object_ID WHERE t_objectproperties.Property='"+oldAttName+"'";
//select those elements using the query
Session.Output"Delete Tagged Value Name: '"+oldAttName+"'" );
Session.Output"=======================================" );
Session.Output"Number of repository elements having tagged value '"oldAttName"' = "allExistingElements.Count );

// operate on an element within the returned collection
for ( var allExistingElements.Count i++ )
taggedValue theElement.TaggedValues.GetByNameoldAttName );
  if ( 
taggedValue != null )
//have to iterate through collection of tagged values because there is only a means to delete using the index value within the collection
  //not a DeleteByName 
for (var ttv=0ttv theElement.TaggedValues.Count ttv++)
   if ( 
thisTaggedValue.Name == oldAttName)
theElement.TaggedValues.DeleteAt (ttv,true);

.Output"Done!" );
Session.Output"" );



("add tagged value name here"); 



RSS 2.0     Atom Feed

© 2010 Eclectica Systems Ltd.