Login  ·  Register

 
 

SparxSystems EA Script - Correct Protective Marking Tagged Value (‘pm marking’) Across Entire EA Project

Posted: 31 December 2011 01:49 PM   [ Ignore ]
Administrator
Avatar
RankRankRank
Total Posts:  52
Joined  2009-12-04

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 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; 
[ Edited: 31 December 2011 02:05 PM by Maestoso ]
Profile
 
 
Posted: 31 December 2011 02:08 PM   [ Ignore ]   [ # 1 ]
Administrator
Rank
Total Posts:  15
Joined  2009-09-24

Part 2 of code
==

case "RESTRICTED":
     
taggedValue_pm_marking_curr.Value="RESTRICTED" ;
     
taggedValue_pm_marking_curr.Update
     break;
     
     case 
"CONFIDENTIAL":
     
taggedValue_pm_marking_curr.Value="CONFIDENTIAL" ;
     
taggedValue_pm_marking_curr.Update
     break;
     
     case 
"SECRET":
     
taggedValue_pm_marking_curr.Value="SECRET" ;
     
taggedValue_pm_marking_curr.Update;    
     break;
     
     case 
"TOP SECRET":
     
taggedValue_pm_marking_curr.Value="TOP SECRET" ;
     
taggedValue_pm_marking_curr.Update
     break;
     
     default:
      
Session.Output("'"+theElement.Name "' of type <<" +theElement.Stereotype+">> value ='"taggedValue_pm_marking_curr.Value+"'- doesn't match any allowed value");
      if (
forceChange)
      
{
       
// user has elected to force the value to default of 'NONE'
        
Session.Output("Warning!: '"+theElement.Name "' of type <<" +theElement.Stereotype+">> value ='"taggedValue_pm_marking_curr.Value+"' forcibly changed to 'NONE'");
        
taggedValue_pm_marking_curr.Value="NONE" ;
        
taggedValue_pm_marking_curr.Update
        
noUnknownChanged noUnknownChanged +1;

      
}
    }
   
  
     

   
   
   
  } 
else if (taggedValue_pm_Marking_old != null)
  
{
   
//element has the older 'pm_Marking' tagged value 
   
Session.Output("Warning! : '"+theElement.Name "' of type <<" +theElement.Stereotype">> has the old '"+taggedValue_pm_Marking_old.Name"' tagged value. Needs changing - run 'Project - changeConnectorTaggedValueName'");
  
   
  
else if (taggedValue_pm_Marking_old == null && taggedValue_pm_marking_curr == null && theElement.ObjectType != otPackage)
  
{
   
//element has no 'pm marking' tagged value whatsoever and isn't a package (folder)
   
   
    
Session.Output(theElement.ObjectType);
    
Session.Output("Warning! : "+theElement.Name " of type <<" +theElement.Stereotype">> has no 'pm marking' tagged value of any kind - added 'pm marking' with value = 'NONE'");
    
newTaggedValue=theElement.TaggedValues.AddNew("pm marking","NONE");
    
newTaggedValue.Update;
    
newTaggedValues=newTaggedValues+1;
   
  
}
  
 }
  
  
  Session
.Output("Number of elements with unknown values changed to 'NONE' = "+noUnknownChanged);
  
Session.Output("Number of elements to which 'pm marking' added = "+newTaggedValues);
  
Session.Output"Done!" );
  
Session.Output" " );
  
Session.Output" " );
 

 

}



repositoryDetails
()
//
// with false will only report where pm marking contains a non matching value
// if you want to overwrite this and set this to 'NONE' set it to 'true'
//
correctPMmarking(false
Profile
 
 
   
 
 


RSS 2.0     Atom Feed

© 2010 Eclectica Systems Ltd.