Class TLcdDataModelMapping

java.lang.Object
com.luciad.datamodel.transformation.TLcdDataModelMapping

public class TLcdDataModelMapping extends Object
Class that simplifies the configuration of a TLcdTransformer.
Instances of this class are used to map one or more source data models to one or more target data models.

Typical usage is as follows:


 TLcdDataModelMapping mapping = new TLcdDataModelMapping(sourceDataModel, targetDataModel);
 // optionally, add or change the mapping between two types
 mapping.mapType(...);
 // create and configure the transformer
 TLcdTransformer toTargetModelTransformer = new TLcdTransformer();
 mapping.configure(toTargetModelTransformer);
 // the transformer is ready to be used
 ILcdDataObject dataObjectFromTargetModel = toTargetModelTransformer.transform(dataObjectFromSourceModel);
 
Since:
11.0
See Also:
  • Constructor Details

    • TLcdDataModelMapping

      public TLcdDataModelMapping()
      Constructs a new instance. Properties on the source data with null value will not be transformed by default.
    • TLcdDataModelMapping

      public TLcdDataModelMapping(TLcdDataModel aSourceModel, TLcdDataModel aTargetModel)
      Constructs a new instance that automatically maps the given source model to the given target model (see also mapDataModel(TLcdDataModel, TLcdDataModel...)). Properties on the source data with null value will not be transformed by default.
      Parameters:
      aSourceModel - a source model
      aTargetModel - a target model
    • TLcdDataModelMapping

      public TLcdDataModelMapping(TLcdDataModel aSourceModel, TLcdDataModel aTargetModel, boolean aTransformEmptyProperties)
      Constructs a new instance that automatically maps the given source model to the given target model (see also mapDataModel(TLcdDataModel, TLcdDataModel...)).
      Parameters:
      aSourceModel - a source model
      aTargetModel - a target model
      aTransformEmptyProperties - indicates whether the transformations, created by this data model mapping, should make an attempt to transform properties without a value. This may be useful if a null value in the source data should be mapped onto a non-null default value in the target data.
  • Method Details

    • mapDataModel

      public void mapDataModel(TLcdDataModel aSourceModel, TLcdDataModel... aTargetModels)

      Maps a source data model on one or more target data models. All types declared in the source data model will be automatically mapped (unless they are explicitly mapped, see mapType(TLcdDataType, TLcdDataType, ILcdObjectTransformation)) to a type with the same name from the target data models.

      Calling this method will never cause any explicit type mappings to be overridden.

      Parameters:
      aSourceModel - the source data model
      aTargetModels - the target data models
    • ignore

      public void ignore(TLcdDataType aType)
      Marks the given type that it should not be automatically mapped, even if its declaring data model would be mapped. Also marks all properties of this type that they should not be automatically mapped.
      Parameters:
      aType - the type to ignore
    • ignore

      public void ignore(TLcdDataProperty aProperty)
      Marks the given property that it should not be automatically mapped, even if its declaring data model would be mapped.
      Parameters:
      aProperty - the property to ignore
    • mapType

      public TLcdDataTypeMapping mapType(TLcdDataType aSourceType)

      Maps the given source type on a type with the same name in the target data models. The source type should be a data object type.

      Before this method is called, the source data model should already have been mapped on one or more target data models. Otherwise the implementation will not be able to find a target type and an IllegalArgumentException will be thrown.

      Parameters:
      aSourceType - the source type
      Returns:
      the data type mapping that maps the source type on the target type
      Throws:
      IllegalArgumentException - when no target type could be found
      See Also:
    • mapType

      public TLcdDataTypeMapping mapType(TLcdDataType aSourceType, TLcdDataType aTargetType)
      Maps the source type on the target type (and vice versa) using a TLcdDataTypeMapping. The returned type mapping can be used to further control how properties are mapped from the source type to the target type. Both source and target type are assumed to be data object types. Calling this method overrides the default mapping done by mapDataModel(TLcdDataModel, TLcdDataModel...).
      Parameters:
      aSourceType - the source type
      aTargetType - the target type
      Returns:
      the data type mapping that maps the source type on the target type
      Throws:
      IllegalArgumentException - in case one of the parameters is null
    • mapType

      public void mapType(TLcdDataType aSourceType, TLcdDataType aTargetType, ILcdObjectTransformation aTransformation)
      Maps the source type on the target type using the given transformation.
      Parameters:
      aSourceType - the source type
      aTargetType - the target type
      aTransformation - the transformation that maps the source on the target type
    • configure

      public void configure(TLcdTransformer aTransformerSFCT)
      Registers transformations for the configured mappings and for all types in the mapped source data models (if it is not explicitly ignored and if a target type could be found).
      Parameters:
      aTransformerSFCT - the transformer to configure
    • getInverse

      public TLcdDataModelMapping getInverse()
      Returns the inverse of this mapping. The inverse mapping is typically used only in cases where a source type can be mapped on multiple target types. In such a case, sometimes transformations from a target type to a source type are needed that have no inverse. These transformations can be mapped on this object's inverse.
      Returns:
      the inverse of this mapping