Book a Demo

Author Topic: Auto Numbering Based On Level Numbering  (Read 5476 times)

Ano

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Auto Numbering Based On Level Numbering
« on: October 02, 2012, 01:40:22 pm »
Is it possible to set up auto numbering so that it is based on the level numbering? For example, I would like to have top level requirement element automatically labelled "REQ0001 - <Short Description>", "REQ0002 - <Short Description>" and sub requirements labelled "REQ0001.1 - <Short Description>", "REQ0001.2 - <Short Description>", "REQ0001.2.1 - <Short Description>", etc.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #1 on: October 02, 2012, 09:49:34 pm »
No. You will need some automation to do that for you.

q.

Doug Blake

  • EA User
  • **
  • Posts: 102
  • Karma: +0/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #2 on: October 02, 2012, 11:05:54 pm »
I like this idea, but I cant be bothered adding to the tool for every little extra feature. Isnt it time Sparx took on some of these extras and built them into the tool as installed so we all get the benefit of them?
DGB Using 12.0.1214 / eaDocX 3.6.2.1 / MSSQL / TFS / Windows 7 / IE11

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #3 on: October 02, 2012, 11:12:34 pm »
Veto. EA already has so many whistles and bells that no user is able to handle them (wisely). The situation will not get better with more features. Instead a sort of Lego toolbox (like the MDG in large) would be nice.

Well, I know this is a different kind of discussion not taken the first time. But this needed to be said too.

q.

Robert Sheridan

  • EA User
  • **
  • Posts: 105
  • Karma: +0/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #4 on: October 02, 2012, 11:36:26 pm »
I use autonumber to uniquely identify and level numbering to help show the hierarchy of elements (usually requirements).  They are not interchangeable in my view.

I agree with Qwerty, I find myself lost in the features on occaisons; more is not necessarily better.
« Last Edit: October 02, 2012, 11:37:27 pm by RobertS »

Ano

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #5 on: October 03, 2012, 08:22:34 am »
Can some one please point me in the direction of how to do this via automation.

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #6 on: October 03, 2012, 04:27:18 pm »
Here is some simple script for numbering elements across a pacakge tree. You would need to alter the numbering pattern in CountElement():
Quote
!INC Local Scripts.EAConstants-JScript

//
// Recursively counts the number of elements in the selected package and its children
//
// Related APIs
// =================================================================================
// Package API - http://www.sparxsystems.com/uml_tool_guide/index.html?package_2.htm
// Repository API - http://www.sparxsystems.com/uml_tool_guide/index.html?repository3.htm
//

// some pre-sets for defining the numbering Prefix and string lenght
var elementCounter = 0;
var NumLength = 3;
var Prefix = "REQ";
var ElementType = "Requirement"

function RecursiveElementCountExample()
{
      
      
      // Show the script output window
      Repository.EnsureOutputVisible( "Script" );

      Session.Output( "JScript RECURSIVE ELEMENT COUNT EXAMPLE" );
      Session.Output( "=======================================" );
      
      // Get the package to work on
      var contextObjectType = Repository.GetContextItemType();
      
      if ( contextObjectType == otPackage )
      {
            // Get the context object as a package
            var contextPackage as EA.Package;
            contextPackage = Repository.GetContextObject();
            
            // Recursively count the number of elements in the package and its children
            DumpPackages( contextPackage);
            
            // Output the results!
            var message = "Package '" + contextPackage.Name + "' has " + elementCounter +
                  " element(s) under it";
            
            Session.Prompt( message, promptOK );
            Session.Output( message );
            
            Session.Output( "Done!" );
      }
      else
      {
            Session.Prompt( "This script requires a package to be selected.\n" +
                  "Please select a package and try again.", promptOK );
      }
}

function DumpPackages( thePackage)
{
      
      // Cast thePackage to EA.Package so we get intellisense
      var currentPackage as EA.Package;
      var childPackages as EA.Collection;
      
      currentPackage = thePackage;
      childPackages = thePackage.Packages;
      
      CountElements(thePackage);
      Session.Output( "Package Children: " + childPackages.Count());
      
      // Iterate through all child packages
      for ( var i = 0 ; i < childPackages.Count ; i++ )
      {
            var currentPackage as EA.Package;
            currentPackage = childPackages.GetAt(i);
      
            // Recursively process child packages
            DumpPackages( currentPackage );
            
      }

      return;
}


function CountElements(thePackage)
{
      // for each element in the package
      // replace Name the string with counter added
      
      var elements as EA.Collection;
      var currentElement as EA.Element;
      var txtUpdate;
      //var elementCount = 0;
      
      elements = thePackage.Elements;
      
      for ( var i = 0 ; i < elements.Count ; i++ )
            {
                  currentElement = elements.GetAt( i );
                  
                  if (currentElement.Type == ElementType)
                  {
                        Session.Output( "CurrentElement: " + currentElement.Name);
                        elementCounter = elementCounter+1;
                        currentElement.Name = Prefix + pad(elementCounter, NumLength) + " " + currentElement.Name;
                        currentElement.update();
                  }
            }
            
      return;
}

function pad(number, length) {
  
    var str = String(number);
    while (str.length < length)
      {
        str = '0' + str;
    }
  
    return str;

}


RecursiveElementCountExample();

Paul Lotz

  • EA User
  • **
  • Posts: 248
  • Karma: +1/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #7 on: October 09, 2012, 04:47:04 am »
Quote
Is it possible to set up auto numbering so that it is based on the level numbering? For example, I would like to have top level requirement element automatically labelled "REQ0001 - <Short Description>", "REQ0002 - <Short Description>" and sub requirements labelled "REQ0001.1 - <Short Description>", "REQ0001.2 - <Short Description>", "REQ0001.2.1 - <Short Description>", etc.

Be sure this is really what you want.  What happens if someone moves a requirement to a different level in the hierarchy?  Should the requirement number to change?  (I think the intent of the autonumbering scheme is to provide a unique number for each requirement so that it is easy to trace it through various edits.  That doesn't mean one can't use it differently, but be aware of the purpose first.)

Ano

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Auto Numbering Based On Level Numbering
« Reply #8 on: October 10, 2012, 12:07:34 pm »
Thank you very much Dermot. Your example script was very useful.