com.univocity.api.config.builders
Interface DataStoreMapping


public interface DataStoreMapping

The DataStoreMapping provides builder-style configuration options for defining mappings between entities of two data stores. Instances of this interface are obtained from a DataIntegrationEngine instance, using DataIntegrationEngine.map(String, String).

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
EntityMapping, NameMatcher, PersistenceSetup, DataIntegrationEngine, DataStoreConfiguration

Method Summary
 void addInputRowReader(RowReader rowReader, String... entityNames)
          Adds a RowReader to be executed against the input data of EntityMappings defined in this DataStoreMapping.
 void addInputRowReader(String readerName, String... entityNames)
          Associates a single RowReader, registered in the DataIntegrationEngine, to be executed against the input data of EntityMappings defined in this DataStoreMapping.
 void addOutputRowReader(RowReader rowReader, String... entityNames)
          Adds a RowReader to be executed against the output data of EntityMappings defined in this DataStoreMapping.
 void addOutputRowReader(String readerName, String... entityNames)
          Associates one or more RowReaders registered, in the DataIntegrationEngine, with the output data of EntityMappings defined in this DataStoreMapping.
 void addPersistedRowReader(RowReader rowReader, String... entityNames)
          Adds a RowReader to be executed against the data persisted after the execution of entity mappings in this DataStoreMapping.
 void addPersistedRowReaders(String readerName, String... entityNames)
          Associates RowReader, registered in the DataIntegrationEngine, to be executed against the data persisted after the execution of entity mappings in this DataStoreMapping.
 void autodetectMappings()
          Executes a process for automatic detection of mappings based on entity names and their fields.
 void autodetectMappings(boolean createDestinationEntities)
          Executes a process for automatic detection of mappings based on entity names and their fields.
 void autodetectMappings(boolean createDestinationEntities, NameMatcher entityNameMatcher, NameMatcher fieldNameMatcher)
          Executes a process for automatic detection of mappings based on entity names and their fields.
 void autodetectMappings(NameMatcher entityNameMatcher, NameMatcher fieldNameMatcher)
          Executes a process for automatic detection of mappings based on entity names and their fields.
 PersistenceSetup configurePersistenceDefaults()
          Configures the default persistence settings used by new EntityMapping instances created from this data store mapping.
 String getDestinationDataStore()
          Returns the name of the destination data store whose entities will receive data mapped from the inputs configured in an EntityMapping
 EntityMapping getMapping(String sourceEntityName, String destinationEntityName)
          Obtains the mapping configuration object between two entities.
 String getSourceDataStore()
          Returns the name of the data store that provides entities whose data will be used as input in mappings created with map(String, String)
 boolean isEnabled()
          Tests if this data store mapping is enabled, in which case the entity mappings defined in it can be executed in a DataIntegrationEngine cycle.
 EntityMapping map(String destinationEntityName)
          Creates a mapping configuration object to an entity in the destination data store that does not require input from any entity in the source data store.
 EntityMapping map(String sourceEntityName, String destinationEntityName)
          Creates a mapping configuration object between a data entity in the source data store to another entity in the destination data store.
 void removeMapping(String sourceEntityName, String destinationEntityName)
          Removes a mapping between two data entities.
 void setEnabled(boolean enabled)
          Defines whether this data store mapping is enabled, in which case the entity mappings defined in it can be executed in a DataIntegrationEngine cycle.
 

Method Detail

getSourceDataStore

String getSourceDataStore()
Returns the name of the data store that provides entities whose data will be used as input in mappings created with map(String, String)

Returns:
the name of the source data store

getDestinationDataStore

String getDestinationDataStore()
Returns the name of the destination data store whose entities will receive data mapped from the inputs configured in an EntityMapping

Returns:
the name of the destination data store

map

EntityMapping map(String destinationEntityName)
Creates a mapping configuration object to an entity in the destination data store that does not require input from any entity in the source data store. The EntityMapping instance is unique in a data store mapping and calling this method multiple times with the same entity name will cause an exception.

Parameters:
destinationEntityName - the name of the entity in the destination data store.
Returns:
a new EntityMapping instance.

map

EntityMapping map(String sourceEntityName,
                  String destinationEntityName)
Creates a mapping configuration object between a data entity in the source data store to another entity in the destination data store. The EntityMapping instance is unique in a data store mapping and calling this method multiple times with the same entity names will cause an exception.

Parameters:
sourceEntityName - the name of the entity in the source data store
destinationEntityName - the name of the entity in the destination data store.
Returns:
a new EntityMapping instance.

getMapping

EntityMapping getMapping(String sourceEntityName,
                         String destinationEntityName)
Obtains the mapping configuration object between two entities.

Parameters:
sourceEntityName - the name of the source data entity.
destinationEntityName - the name of the destination data entity.
Returns:
the existing DataStoreMapping instance associated with the given data entity names, or null if there's no mapping between them.

removeMapping

void removeMapping(String sourceEntityName,
                   String destinationEntityName)
Removes a mapping between two data entities. All configuration settings defined in the underlying EntityMapping will be lost.

Parameters:
sourceEntityName - the name of the source data entity.
destinationEntityName - the name of the destination data entity.

autodetectMappings

void autodetectMappings()
Executes a process for automatic detection of mappings based on entity names and their fields. Entities that are already mapped will not be used in the process.

Entities and fields with similar names will be automatically associated. Underscores and spaces are ignored, for example: entity1 will be associated with ENTITY 1 or ENTITY_1. When mapping fields, if the field in either source or destination is an identifier, the mapping will be created using IdentifierMappingSetup, otherwise a regular field copy will be created using FieldMappingSetup.

Important: You may want to define the correct sequence of mappings to be executed by default using DataIntegrationEngine.setMappingSequence(String...)


autodetectMappings

void autodetectMappings(boolean createDestinationEntities)
Executes a process for automatic detection of mappings based on entity names and their fields. Entities that are already mapped will not be used in the process.

Entities and fields with similar names will be automatically associated. Underscores and spaces are ignored, for example: entity1 will be associated with ENTITY 1 or ENTITY_1. When mapping fields, if the field in either source or destination is an identifier, the mapping will be created using IdentifierMappingSetup, otherwise a regular field copy will be created using FieldMappingSetup.

Important: You may want to define the correct sequence of mappings to be executed by default using DataIntegrationEngine.setMappingSequence(String...)

Parameters:
createDestinationEntities - flag indicating whether "clones" of the source entities should be created in the destination data store. Some data stores support dynamic creation of entities, such as uniVocity-provided CSV, TSV and Fixed-Width data stores (but only when an output directory is defined: see TextDataStoreConfiguration.setOutputDirectory(java.io.File)). New entities will be created with the exact same name of the source entity, and with the same fields.

autodetectMappings

void autodetectMappings(boolean createDestinationEntities,
                        NameMatcher entityNameMatcher,
                        NameMatcher fieldNameMatcher)
Executes a process for automatic detection of mappings based on entity names and their fields. Entities that are already mapped will not be used in the process.

A NameMatcher will be used to match names of entities and create a mapping between them. If an EntityMapping is created for matching entities, then another NameMatcher will be executed to match the names of each field in both entities. If the field in either source or destination is an identifier, the mapping will be created using IdentifierMappingSetup, otherwise a regular field copy will be created using FieldMappingSetup.

Parameters:
createDestinationEntities - flag indicating whether "clones" of the source entities should be created in the destination data store. Some data stores support dynamic creation of entities, such as uniVocity-provided CSV, TSV and Fixed-Width data stores (but only when an output directory is defined: see TextDataStoreConfiguration.setOutputDirectory(java.io.File)). New entities will be created with the exact same name of the source entity, and with the same fields.
entityNameMatcher - a matcher for entity names. If null, the default matching algorithm will be used.
fieldNameMatcher - a matcher for field names. If null, the default matching algorithm will be used.

autodetectMappings

void autodetectMappings(NameMatcher entityNameMatcher,
                        NameMatcher fieldNameMatcher)
Executes a process for automatic detection of mappings based on entity names and their fields. Entities that are already mapped will not be used in the process.

A NameMatcher will be used to match names of entities and create a mapping between them. If an EntityMapping is created for matching entities, then another NameMatcher will be executed to match the names of each field in both entities. If the field in either source or destination is an identifier, the mapping will be created using IdentifierMappingSetup, otherwise a regular field copy will be created using FieldMappingSetup.

Parameters:
entityNameMatcher - a matcher for entity names. If null, the default matching algorithm will be used.
fieldNameMatcher - a matcher for field names. If null, the default matching algorithm will be used.

configurePersistenceDefaults

PersistenceSetup configurePersistenceDefaults()
Configures the default persistence settings used by new EntityMapping instances created from this data store mapping. This won't affect the persistence settings of existing entity mappings.

The default persistence configuration in the PersistenceSetup instance is:

Returns:
the persistence settings builder that provides configuration defaults for new entity mappings.

isEnabled

boolean isEnabled()
Tests if this data store mapping is enabled, in which case the entity mappings defined in it can be executed in a DataIntegrationEngine cycle.

Returns:
true if the mappings configured in this object are enabled and can be executed by a DataIntegrationEngine, otherwise false

setEnabled

void setEnabled(boolean enabled)
Defines whether this data store mapping is enabled, in which case the entity mappings defined in it can be executed in a DataIntegrationEngine cycle.

Parameters:
enabled - a flag enabling mappings configured in this object to be executed by a DataIntegrationEngine.

addInputRowReader

void addInputRowReader(RowReader rowReader,
                       String... entityNames)
Adds a RowReader to be executed against the input data of EntityMappings defined in this DataStoreMapping.

Parameters:
rowReader - the callback object that will intercept and possibly manipulate the rows extracted from the source entity before its data is mapped to the destination.
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.

addInputRowReader

void addInputRowReader(String readerName,
                       String... entityNames)
Associates a single RowReader, registered in the DataIntegrationEngine, to be executed against the input data of EntityMappings defined in this DataStoreMapping.

Parameters:
readerName - the name of a callback object extending RowReader that will intercept and possibly manipulate the rows extracted from the source entity before its data is mapped to the destination.
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.

addOutputRowReader

void addOutputRowReader(RowReader rowReader,
                        String... entityNames)
Adds a RowReader to be executed against the output data of EntityMappings defined in this DataStoreMapping.

Parameters:
rowReader - the callback object that will intercept and possibly manipulate the rows extracted from the source entity and mapped to the destination, before they are persisted
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.

addOutputRowReader

void addOutputRowReader(String readerName,
                        String... entityNames)
Associates one or more RowReaders registered, in the DataIntegrationEngine, with the output data of EntityMappings defined in this DataStoreMapping.

Parameters:
readerName - the names of the callback object extending RowReader that will intercept and possibly manipulate the rows extracted from the source entity and mapped to the destination, before they are persisted
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.

addPersistedRowReader

void addPersistedRowReader(RowReader rowReader,
                           String... entityNames)
Adds a RowReader to be executed against the data persisted after the execution of entity mappings in this DataStoreMapping. Values generated after insertion, if any, will be available to the RowReader.

Parameters:
rowReader - the callback object that will manipulate rows extracted from the source entity, mapped and persisted into the destination
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.

addPersistedRowReaders

void addPersistedRowReaders(String readerName,
                            String... entityNames)
Associates RowReader, registered in the DataIntegrationEngine, to be executed against the data persisted after the execution of entity mappings in this DataStoreMapping. Values generated after insertion, if any, will be available to the RowReader.

Parameters:
readerName - the names of the callback object,extending RowReader, that will manipulate rows extracted from the source entity, mapped and persisted into the destination
entityNames - The names of the data entities used by one or more EntityMappings of this DataStoreMapping. If no names are given, then all EntityMappings of this DataStoreMapping will have the given RowReader added.


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