Naming Modifier

Introduction

This transformation can be used to modify the names of specific model elements in the application schema. The rules section documents available behavior.

Configuration

The following sections specifiy the configuration options for a NamingModifier transformation.

Class

The class for the Naming Modifier implementation is de.interactive_instruments.ShapeChange.Transformation.Naming.NamingModifier.

Rules

The rules supported by the Naming Modifier transformation are described in the following sections.

NOTE: The transformation can be configured without any rule. In that case, names within the model will not be modified.

rule-trf-add-suffix

Dependency on other rule(s): none

Behavior: This rule is used to append a suffix (specified via the parameter suffix) to specific application schema classes. If the name of a class matches the regular expression specified via the configuration parameter modelElementNamesToAddSuffixRegex the suffix is added to the class name.

Parameter(s):

rule-trf-camelcase-to-uppercase

Available for ShapeChange version: 2.3.0+

Dependency on other rule(s): none

Behavior: Updates the names of application schema classes and their properties as follows:

  • All lower case letters are replaced with upper case letters.
  • If a letter or decimal digit is followed by an upper-case letter, the two are separated by an underscore.
  • An underscore in the original name is replaced by two underscores.
  • A decimal digit is kept as-is.
  • If the original name contains a suffix identified by parameter suffixesToIgnore then that suffix is kept as-is. If multiple suffixes (given by the parameter) match the end of the string, a warning is logged and the suffix with greatest length is chosen.

This rule can be useful when Oracle DB naming conventions play a role, and when the name transformation shall be reversible.

NOTE1: This rule does not modify the names of enums and codes (i.e. the properties of enumeration and codelist classes). If these names shall be modified as well, add rule-trf-camelcase-to-uppercase-include-enums and rule-trf-camelcase-to-uppercase-include-codes.

NOTE2: The rule only processes tagged values of included classes and properties if rule-trf-camelcase-to-uppercase-include-taggedTalues is enabled. The tags to modify are identified via the configuration parameter camelCaseToUpperCase_taggedValues.

Examples:

  • abcDefGhi (parameter suffixesToIgnore not set) -> ABC_DEF_GHI
  • abc_DefGhi (parameter suffixesToIgnore not set) -> ABC__DEF_GHI
  • ABCDefGhi (parameter suffixesToIgnore not set) -> A_B_C_DEF_GHI
  • AbcDEfGHI (parameter suffixesToIgnore not set) -> ABC_D_EF_G_H_I
  • AbcDefGhiID (parameter suffixesToIgnore set to ‘ID’) -> ABC_DEF_GHI_ID
  • AbcDefGHIID (parameter suffixesToIgnore set to ‘ID’) -> ABC_DEF_G_H_I_ID
  • AbcDefGHIID (parameter suffixesToIgnore set to ‘ID, GHIID’) -> ABC_DEF_GHIID
  • AbcDefGhiCL (parameter suffixesToIgnore set to ‘CL’) -> ABC_DEF_GHI_CL
  • abcDefGhi_CL (parameter suffixesToIgnore set to ‘CL’) -> ABC_DEF_GHI__CL
  • Abc1D1efG2HI (parameter suffixesToIgnore not set) -> ABC1_D1EF_G2_H_I

Parameter(s):

rule-trf-camelcase-to-uppercase-include-codes

Available for ShapeChange version: 2.3.0+

Dependency on other rule(s): rule-trf-camelcase-to-uppercase

Behavior: Extends the behavior of rule-trf-camelcase-to-uppercase so that the names of codes (i.e. properties of codelists) are modified as well.

Parameter(s):

rule-trf-camelcase-to-uppercase-include-enums

Available for ShapeChange version: 2.3.0+

Dependency on other rule(s): rule-trf-camelcase-to-uppercase

Behavior: Extends the behavior of rule-trf-camelcase-to-uppercase so that the names of enums (i.e. properties of enumerations) are modified as well.

Parameter(s):

rule-trf-camelcase-to-uppercase-include-taggedTalues

(since v2.4.0)

Extends the behavior of rule-trf-camelcase-to-uppercase so that tagged values (identified via parameter camelCaseToUpperCase_taggedValues) of included classes and properties are modified as well.

Parameters

The parameters supported by the Naming Modifier transformation are documented in the following sections.

camelCaseToUpperCase_taggedValues

Comma-separated list of names of tagged values to modify by rule-trf-camelcase-to-uppercase-include-taggedTalues.

modelElementNamesToAddSuffixRegex

Alias: none

Required / Optional: Required

Type: String (representing a Java compliant regular expression)

Default Value: none

Explanation: The regular expression to identify the application schema classes where a suffix shall be appended to the class name.

Applies to Rule(s)rule-trf-add-suffix

suffix

Alias: none

Required / Optional: Optional

Type: String

Default Value: “_” (a single underscore)

Explanation: The suffix to add.

Applies to Rule(s)rule-trf-add-suffix

suffixesToIgnore

Alias: none

Required / Optional: Optional

Type: String

Default Value: none

Explanation: Contains a (comma-separated) list of strings that shall be ignored by “rule-trf-camelcase-to-uppercase” when they occur as suffix in the name of a model element. Note that case matters when the process checks if a model element name ends with one of the given strings.

Applies to Rule(s): rule-trf-camelcase-to-uppercase

Map Entries

At the moment none of the Naming Modifier rules use process map entries.

Sample Configuration

<Transformer class="de.interactive_instruments.ShapeChange.Transformation.Naming.NamingModifier"
  id="step2" input="step1" mode="enabled">
  <parameters>
    <ProcessParameter name="suffix" value="_SUFFIX"/>
    <ProcessParameter name="modelElementNamesToAddSuffixRegex" value="Feature(2|3)|F(2|3)"/>
  </parameters>
  <rules>
    <ProcessRuleSet name="rules">
      <rule name="rule-trf-add-suffix"/>
    </ProcessRuleSet>
  </rules>
</Transformer>
Top