Common Transformer Functionality

Introduction

The execution of a transformer (e.g. identity and profiler transformation) can include invocation of common pre- and/or postprocessing functionality. The following sections describe which functionality is available and define how to configure it.

Preprocessing

Preprocessing functionality is executed on a model right before the transformer specific processing (e.g. profiling) is invoked.

Currently no specific common preprocessing functionality is available.

Postprocessing

Postprocessing functionality is executed on a model right after the transformer specific processing (e.g. profiling) has been completed.

Setting Tagged Values

Overview

This function supports setting and re-setting of tagged values for model elements (currently: packages, classes, properties) after a transformation.

Filter instructions support the identification of model elements for which a tagged value is to be (re-)set.

It is possible to add a tagged value to a model element without providing an actual value in the configuration. In that case ShapeChange determines if the tagged value already exists. If so, the existing value is kept. Otherwise the tagged value is initialized with the empty string. If the configuration contains a value for the tagged value, it is set.

Configuration

In order to configure which tagged values to set after a specific transformer has been completed, add a <taggedValues> element as child to the <Transformer> element in the ShapeChangeConfiguration. Within the <taggedValues> element, add one or more <TaggedValue> elements, with the following attributes (modelElementStereotype, modelElementName, applicationSchemaName represent filter criteria to select the model elements on which to set the tagged value; they are connected by an implicit AND; note: if none of these criteria is set, the tagged value is set on all model elements!):

Attribute Name Required / Optional Explanation
name Required Name of the tagged value to (re-)set.
value Optional Value of the tagged value.
modelElementStereotype Optional Regular expression: if one of the stereotypes of a given model element matches the regular expression, this filter criterium evaluates to true.Note: stereotypes are recognized via their well-known form only, not via their aliases (see ShapeChange Stereotypes for further information). The regular expression must be defined accordingly.Also note that this filter criterium does not support a combined check of multiple stereotypes (e.g. ensure that a model element has both stereotype A and B).
modelElementName Optional Regular expression: if the name of a given model element matches the regular expression, this filter criterium evaluates to true.
applicationSchemaName Optional Regular expression: if the name of the application schema that a given model element belongs to matches the regular expression, this filter criterium evaluates to true.This criterium is useful in case that tagged values for model elements shall only be set within specific application schema.

 Example

Setting of the following tagged values adds information about the DGIWG Spatial Profile implemented by the MyAppSchema application schema to the model. More specifically, the tagged values are set on the package with (normalized) stereotype “application schema” and name “MyAppSchema”.

<taggedValues>
 <TaggedValue name="dgiwgComplianceLevel" value="L1_3D" modelElementStereotype="(?i:application schema)" modelElementName="MyAppSchema"/>
 <TaggedValue name="dgiwgGMLProfileSchema" value="http://schemas.dgiwg.org/gml/3.2/spatial/1.0/3dGeometry.xsd" modelElementStereotype="(?i:application schema)" modelElementName="MyAppSchema"/>
</taggedValues>

 

Setting Model Generation Date and Time

Overview

The time that a model has been transformed by ShapeChange can be added to the model.

More specifically, ShapeChange adds the “generationDateTime” tagged value for each selected application schema (selection can be controlled via parameters on the <input> configuration element, e.g. the paramter appSchemaName – see the “input” element documentation for further information). The value is a time instant in UTC with the format: yyyy-MM-dd’T’HH:mm:ss’Z’.

Configuration

In order to configure this functionality, simply add a <ProcessParameter> element to the configuration of a transformer, with the attribute “name” set to “setGenerationDateTimeTaggedValue” and the attribute “value” set to “true”.

Example

<parameters>
    <ProcessParameter name="setGenerationDateTimeTaggedValue" value="true"/>
</parameters>

Parsing and Validating Constraints

(since v2.2.0)

A model transformation (for example profiling) can modify the model in such a way that constraints – especially OCL and FOL constraints – are no longer valid. By default, ShapeChange parses and validates constraints when postprocessing a transformed model.

Invalid constraints are converted into simple text constraints, so that processing can proceed. However, warnings in the log will identify invalid constraints (together with the reason why they are invalid). The user can then either modify the input model (e.g. constraint definitions), the transformations (e.g. profiling), or the output (if there were only minor issues).

Parsing and validating constraints of a transformed model can help prevent errors.

However, the functionality can also be skipped by including rule-trf-all-postprocess-skip-constraint-validation in the rules of a particular transformation. This can be useful if constraints of transformed models are irrelevant for target processing (i.e., the derivation of the final output).