The attached JScript (Project - Correct pm marking.js) works with Sparx Systems Enterprise Architect and on an EA project created using the MDG Technology for TRAK. It is part of a set of scripts that make life easier.
It examines the contents of the tagged value used to hold the protective marking (‘pm marking’) for every object (not connector):
if it finds values that correspond to ‘NONE’, ‘NOT PROTECTIVELY MARKED’, ‘RESTRICTED’, ‘CONFIDENTIAL’, ‘SECRET’ or ‘TOP SECRET’ (or any combination of upper / lower case to this effect) it corrects them
if it finds the older tagged value named ‘pm_Marking’ it issues a warning to run the script that comes with v 0.124 of the MDG Technology for TRAK that changes the tagged value names.
if it finds that the object (excluding packages/folders) is missing the tagged value it adds it with default value ‘NONE’ and reports this.
if it finds a value that it doesn’t recognise it reports this. You can then run the script again with a setting to forcibly set these values to ‘NONE’ .
As ever - no warranty and you should always backup your project file before running a script that modifies your project.
Any suggestions for useful things to be able to do / automate when using the MDG Technology for TRAK / creating a TRAK architecture description?
==
!INC Local Scripts.EAConstants-JScript
/*
* Script Name: Project - correctPMmarking.js
* Author: Nic Plum Eclectica Systems Ltd. http://eclectica-systems.co.uk
*
* Purpose: Checks the 'pm marking' protective marking tagged value contents across an entire TRAK EA project
* and corrects values to current definition (NONE/NOT PROTECTIVELY MARKED/RESTRICTED/CONFIDENTIAL/SECRET/TOP SECRET)
* If 'pm marking' is missing it will be added with the default value of 'NONE'
* Reports where a non matching value is found and can then be run again to set this to 'NONE'
* Does not apply marking to packages (folders)
*
*
*
* Support: http://trak-community.org/index.php/forums/viewforum/11/ - look out for new scripts in the future
* and http://sourceforge.net/projects/mdgfortrak/support
*
*
* Date: 31th December 2011
*
* __________________________________________________________________
* NOTE: Backup up EA project file (.eap) or database before running !!
* __________________________________________________________________
*
*/
/*
* Legal Weasel Words
* GNU Free Documentation License Version 1.3, 3 November 2008
* The text of the license is at http://www.gnu.org/licenses/fdl-1.3.html
*
* This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
i.e intended to be helpgul but no guarantee of anything.
*/
function repositoryDetails()
{
// Outputs some basic information that might be useful for debugging
// Show the script output window
Repository.EnsureOutputVisible( "Script" );
Session.Output("=====================================");
Session.Output("Project / Environment Information");
Session.Output("EA build = "+Repository.LibraryVersion);
Session.Output("EA edition = "+EAEdition(Repository.EAEdition));
Session.Output("EA edition ex = "+EAEdition(Repository.EAEditionEx));
Session.Output("Project ID = "+Repository.ProjectGUID);
Session.Output("=====================================");
}
function EAEdition (enValue)
{
switch (enValue)
{
case piLite:
return "EA Lite" ;
case piDesktop:
return "Desktop Edition";
case piProfessional:
return "Professional Edition";
case piCorporate:
return "Corporate Edition";
case piBusiness:
return "Business Edition";
case piSystemEng:
return "Systems Engineering Edition";
case piUltimate:
return "Ultimate Edition";
default:
return "Unknown edition";
}
}
function correctPMmarking(changeUknownValues)
{
// Show the script output window
Repository.EnsureOutputVisible( "Script" );
var forceChange = changeUknownValues;
//deprecatedAttName =oldAttName;
var allExistingElements as EA.Collection;
var currentAttribute as EA.Attribute;
var theTaggedValue as EA.AttributeTag;
var theExistingTaggedValues as EA.Collection;
var theElement as EA.Element;
var SQLstatement = "SELECT t_object.Object_ID FROM t_object WHERE t_object.Stereotype IS NOT Null AND t_object.Stereotype <> 'stereotype' AND t_object.Stereotype <> 'metaclass' AND t_object.Stereotype <> 'enumeration' AND t_object.Stereotype <> 'Pre-condition' AND t_object.Stereotype <> 'profile'";
allExistingElements=Repository.GetElementSet(SQLstatement,2);
var taggedValue_pm_marking_curr as EA.TaggedValue;
var taggedValue_pm_Marking_old as EA.TaggedValue;
var newTaggedValue as EA.TaggedValue;
var thisTaggedValue as EA.TaggedValue;
var noUnknownChanged = 0;
var newTaggedValues = 0;
var taggedValName = "pm marking"
Session.Output( "Searching project looking at contents of '"+taggedValName+"'" );
Session.Output( "=======================================" );
Session.Output( "Number of repository elements= "+ allExistingElements.Count );
// Get the currently selected element in the tree to work on
for ( var i = 0 ; i < allExistingElements.Count ; i++ )
{
theElement = allExistingElements.GetAt(i);
taggedValue_pm_marking_curr = theElement.TaggedValues.GetByName(taggedValName );
taggedValue_pm_Marking_old = theElement.TaggedValues.GetByName("pm_Marking");
if ( taggedValue_pm_marking_curr != null )
{
//first check / correct for mixed case typos e.g. 'nONE', 'NOnE' etc.
switch (taggedValue_pm_marking_curr.Value.toUpperCase())
{
case "NONE":
taggedValue_pm_marking_curr.Value="NONE" ;
taggedValue_pm_marking_curr.Update;
break;
case "NOT PROTECTIVELY MARKED":
taggedValue_pm_marking_curr.Value="NOT PROTECTIVELY MARKED" ;
taggedValue_pm_marking_curr.Update;
break;