Skip to main content

Expander Mapping Scope

Expressions in a mapping file has access to a number of variables.

  • expansionSource: The target of the Expander. An instance of the Composite class of the ElementType defined by the Expander.
  • {element}: The same value as expansionSource, but named after the ElementType. (e.g. dataElement)
  • {ancestor}: Any parent or ancestor in the model is also included. (e.g. component and application)
  • expansionContext: A CompositeExpansionContext implementation with additional context information.
  • expander: The ExpansionComposite of the current Expander.
  • expansionResource: The ExpansionResourceComposite of the current expansion-resource bundle. Can be useful to retrieve the version of the expansion-resource.
  • module: If any, the ModuleComposite of the parent module. (Wraps Component or other ModuleType.)
  • program: The ProgramComposite of the program being expanded. (Wraps Application or other ProgramType.)
  • expansionConfiguration: The ExpansionConfigurationComposite for this expansion.

It also contains some support classes:

  • dataRegistry: A DataRegistryComposite It provides several methods to look up elements or data from DataResources.
  • classBuilder: A ClassBuilder instance, which can be used to wrap java class names in a queryable object. (e.g. classBuilder.from('some.java.Class') or classBuilder.from(dataElement)).
  • technologies: A TechnologyHelper instance, which can be used to look for technologies enabled for the program or module.
    • Use technologies.has('TECH') to check if a technology was included.
    • Use technology.get('TECH') to get the TechnologyComposite instance with the given name.
  • filters: A Filters instance that provides helpful filters.
    • filters.forLayer(layer) returns a predicate, which checks whether a Composite is included in that layer (does not have a no~Layer option for that layer).
Deprecated

Some variables are still available in the scope, but use is not recommended:

  • artifactName
  • globalOptionSettings
  • presentationSettings
  • technicalInfrastructure
  • businessLogicSettings

Extending the scope

It is possible to define new variables in the mapping scope, which can be used in other mapping statements.

For this you can use a let statement:

The mapping

<value name="name" eval="field.linkField.targetElement.name"/>
<value name="packageName" eval="field.linkField.targetElement.packageName"/>

can be simplified to:

<let name="targetElement" eval="field.linkField.targetElement"/>
<value name="name" eval="targetElement.name"/>
<value name="packageName" eval="targetElement.packageName"/>

Let statements can also be used to instantiate helper classes:

<let name="nameConverter" eval="new net.democritus.naming.ElementNameConverter()"/>
<value name="nameDashed" eval="nameConverter.getDashed(dataElement.name)"/>
Scopes in list and group statements

In both list and group statements, the variables defined with let statements within the list or group mapping cannot be accessed from outside these mappings.