com.univocity.api.entity.custom
Interface CustomDataStore<E extends CustomReadableEntity>

Type Parameters:
E - defines the type of data entities managed by this data store.
All Known Implementing Classes:
DynamicDataStore

public interface CustomDataStore<E extends CustomReadableEntity>

A CustomDataStore is responsible for managing custom data entity instances and making them available to uniVocity.

Implementation of transactional behavior in implementations of this interface (in executeInTransaction(TransactionalOperation)) is optional. However, implementors MUST execute the transactional operation passed in by uniVocity.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
CustomDataStoreFactory, DataIntegrationEngine, DataStoreMapping

Method Summary
 CustomQuery addQuery(String queryName, String query)
          Adds a new query to this data entity.
 void executeInTransaction(TransactionalOperation operation)
          Executes an instance of TransactionalOperation, provided by uniVocity.
 DataStoreConfiguration getConfiguration()
          Returns the configuration object of this data store.
 Set<E> getDataEntities()
          Returns the data entity instances available to uniVocity.
 Set<? extends CustomQuery> getQueries()
          Returns the custom query instances available to uniVocity.
 

Method Detail

getDataEntities

Set<E> getDataEntities()
Returns the data entity instances available to uniVocity. The instances can be implementations of CustomReadableEntity or CustomDataEntity

Returns:
the data entity instances this data store provides.

getQueries

Set<? extends CustomQuery> getQueries()
Returns the custom query instances available to uniVocity.

Returns:
the query instances this data store provides.

addQuery

CustomQuery addQuery(String queryName,
                     String query)
Adds a new query to this data entity.

Parameters:
queryName - name of the new query.
query - the query definition. This can be anything the data store implementation supports: a SQL string, an identifier to some custom query object in a map held by this data store, or anything required to create a new CustomQuery instance.
Returns:
the instance of a new CustomQuery created with the given parameters.

executeInTransaction

void executeInTransaction(TransactionalOperation operation)
Executes an instance of TransactionalOperation, provided by uniVocity.

A possible implementation of transaction handling might look like:


 public void executeInTransaction(TransactionalOperation operation) {
     try {
         operation.execute();
         commitChanges(); //goes through resources allocated by entities of this data store and persists all data changes.
     } catch (Exception ex) {
          rollbackChanges(ex); //goes through resources allocated by entities of this data store and cancels/reverts all data changes.
          throw new IllegalStateException(ex);
     }
 }
 

If the custom data store does not implement transactions, then it can simply be written as:
  public void executeInTransaction(TransactionalOperation operation) {
      operation.execute();
  }
 

Notes

Parameters:
operation - the transactional operation that must be executed

getConfiguration

DataStoreConfiguration getConfiguration()
Returns the configuration object of this data store.

Returns:
the configuration of this data store


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