com.univocity.api.config.builders
Interface IdentifierType

All Superinterfaces:
IdentifierCopy

public interface IdentifierType
extends IdentifierCopy

The IdentifierType configuration is obtained from a IdentifierMappingSetup using IdentifierMappingSetup.associate(String...).

It is used to define how the values read from the source entity are to be associated with the destination identifiers:

The following example demonstrates how an identifier mapping can be written:
  // The identifier of this mapping contains two fields: "id" and "locale".
  // The mapping associates source fields "number" and "seq" to derive the value of "id"
  // and executes a function to get the locale ID of "en_US" to derive the value of "locale"
  mapping.identity().associate("number", "seq").to("id").and("{getLocaleId(en_US)}").to("locale");

  // "number" and "seq" are a reference to "referred_entity".
  // This reference will be read from the metadata and stored in the "id" field.
  mapping.reference().using("number", "seq").referTo("source_entity", "referred_entity").on("id");
 

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
FieldMappingSetup, FunctionCall

Method Summary
 GeneratedIdentifierTransform toGeneratedId(String destinationField)
          Defines what generated identifier field of a destination entity should be associated with values extracted from a selection of fields in the source entity.
 GeneratedIdentifierTransform toGeneratedId(String destinationField, String valueIfEmpty)
          Defines what generated identifier field of a destination entity should be associated with values extracted from a selection of fields in the source entity.
 
Methods inherited from interface com.univocity.api.config.builders.IdentifierCopy
to
 

Method Detail

toGeneratedId

GeneratedIdentifierTransform toGeneratedId(String destinationField,
                                           String valueIfEmpty)
Defines what generated identifier field of a destination entity should be associated with values extracted from a selection of fields in the source entity.

Parameters:
destinationField - the name of the generated field in the destination entity
valueIfEmpty - an expression used to produce a value to insert when adding new records, in case no fields (other than the identifier) are mapped. This is required to create a new record in the destination and obtain the generated identifier.
Returns:
the next (optional) step of an identifier mapping configuration: define what functions should be executed to transform input values before associating them to the generated identifier.

toGeneratedId

GeneratedIdentifierTransform toGeneratedId(String destinationField)
Defines what generated identifier field of a destination entity should be associated with values extracted from a selection of fields in the source entity.

Parameters:
destinationField - the name of the generated field in the destination entity

When adding new records, in case no fields (other than the identifier) are mapped, uniVocity will insert a record with null to obtain the identifier generated in the destination.

Returns:
the next (optional) step of an identifier mapping configuration: define what functions should be executed to transform input values before associating them to the generated identifier.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.