AutoNumber - Helmut-Ortmann/EnterpriseArchitect_hoTools GitHub Wiki

Auto Number

hoTools allows you to generate an Auto Number for new created Elements. Auto Numbering is useful for:

  • Requirements
  • Features
  • Risks
  • Tests
  • etc.

In Settings.json you define the rules for Auto Numbering.

Example Auto Number

You have to enable this feature with Setting General.

Features

  • Generate new name for Name or Alias
  • Define rules for Type, Stereotype (e.g. Business Requirement)
  • Define format (e.g. 'B_Req:0.00.0.2')
  • Drag and drop on canvas
  • New generation of all or of a Type/Stereotype according to createdDate
  • Enable/Disable functionality in Setting General

After getting the error by:

  • Show the last error
  • Show the last SQL hoTools send to your database
  • When the error occurs

Via Menu by:

  • Help,
  • Show last SQL Error

Settings.json

in Settings.json you define Auto Number parameters.

Specify Elements to apply Auto Counter

Define ObjectType and Stereotype for which Element types you want to apply Auto Counter.

"ObjectType": "Requirement",
"Stereotype": "FunctionalRequirement"

Specify SQL to determine current max elements

You can either define for Name or for Alias an SQL to determine the maximal current counter value. You may use SQL wildcards (hoTools converts according to your Database):

  • '%' or '*' or '#WC#' Any characters

  • '_' or '?' a single character

    "SqlTopMost": "select top 1 t1.Object_ID from t_object t1 where t1.object_Type = 'Requirement' AND t1.stereotype = 'FunctionalRequirement' AND t1.name like 'F_' AND NOT t1.name like 'FunctionalRequirement' order by t1.name desc", "SqlTopMostAlias": "",

It's a good idea to exclude Names generated by EA by e.g.:

  • 'AND NOT t1.name like 'FunctionalRequirement*'

hoTools converts the wildcards according to the current DB.

Specify format

  • Specify the first value with e.g. "NumberProxyChar": "99",
  • Specify a 'NumberProxyChar' which you use in the format string as a üplace holder for the generated number
  • Specify the format by using the 'NumberProxyChar'. hoTools pads all number with '0'

The following example shows two possible solution which generates the same name.

"NumberProxyChar": "0",
"NumberStartValue": "1",
"FormatString": "F_0.00.0.0"

"NumberProxyChar": "x",
"NumberStartValue": "1",
"FormatString": "F_x.xx.x.x"

Examples

{ // Functional Requirements, Counter for name
  "ObjectType": "Requirement",
  "Stereotype": "FunctionalRequirement",
  "SqlTopMost": "select top 1 t1.Object_ID from t_object t1 where t1.object_Type = 'Requirement' AND t1.stereotype = 'FunctionalRequirement' AND t1.name like 'F_*' AND NOT t1.name like 'FunctionalRequirement*' order by t1.name desc",
  "SqlTopMostAlias": "",
  "NumberProxyChar": "0",
  "NumberStartValue": "1",
  "FormatString": "F_0.00.0.0"
},
{
  "ObjectType": "Requirement",
  "Stereotype": "BusinessRequirement",
  "SqlTopMost": "",
  "SqlTopMostAlias": "select top 1 t1.Object_ID from t_object t1 where t1.object_Type = 'Requirement' AND t1.stereotype = 'BusinessRequirement' AND t1.alias like 'F_*' AND NOT t1.alias like 'FunctionalRequirement*' order by t1.alias desc",
  "NumberProxyChar": "0",
  "NumberStartValue": "99",
  "FormatString": "F_0.00.0.0"
},
{
  "ObjectType": "Risk",
  "Stereotype": "",
  "SqlTopMost": "select top 1 t1.Object_ID from t_object t1 where t1.object_Type = 'Risk' AND t1.stereotype = NULL AND t1.name like 'R:*' AND NOT t1.name like 'Risk*' order by t1.name desc",
  "SqlTopMostAlias": "",
  "NumberProxyChar": "0",
  "NumberStartValue": "3",
  "FormatString": "R:0.00.0.0"
},
{
  "ObjectType": "Feature",
  "Stereotype": "",
  "SqlTopMost": "",
  "SqlTopMostAlias": "select top 1 t1.Object_ID from t_object t1 where t1.object_Type = 'Feature' AND t1.stereotype = NULL AND t1.alias like 'FE:*' AND NOT t1.alias like 'Feature*' order by t1.alias desc",
  "NumberProxyChar": "4",
  "NumberStartValue": "1",
  "FormatString": "FE:4.44.4.4"
}
]

References