Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.access
Class DataPort

    java.lang.Object
      org.apache.cayenne.access.DataPort

    public class DataPort

extends Object

An engine to port data between two DataNodes. These nodes can potentially connect to databases from different vendors. The only assumption is that all of the DbEntities (tables) being ported are present in both source and destination databases and are adequately described by Cayenne mapping.

DataPort implements a Cayenne-based algorithm to read data from source DataNode and write to destination DataNode. It uses DataPortDelegate interface to externalize various things, such as determining what entities to port (include/exclude from port based on some criteria), logging the progress of port operation, qualifying the queries, etc.

Since:
  1.2: Prior to 1.2 DataPort classes were a part of cayenne-examples package.

Field Summary
`protected boolean` | `cleaningDestination`
`protected DataPortDelegate` | `delegate`
`protected DataNode` | `destinationNode`
`protected Collection` | `entities`
`static int` | `INSERT_BATCH_SIZE`
`protected int` | `insertBatchSize`
`protected DataNode` | `sourceNode`

Constructor Summary
`DataPort()`
`DataPort(DataPortDelegate delegate)` Creates a new DataPort instance, setting its delegate.

Method Summary
`void` | `execute()` Runs DataPort.
`DataPortDelegate` | `getDelegate()` Returns previously initialized DataPortDelegate object.
`DataNode` | `getDestinationNode()`
`Collection` | `getEntities()`
`int` | `getInsertBatchSize()`
`DataNode` | `getSourceNode()`
`boolean` | `isCleaningDestination()` Returns true if a DataPort was configured to delete all data from the destination tables.
`protected void` | `processDelete(List entities)` Cleans up destination tables data.
`protected void` | `processInsert(List entities)` Reads source data from source, saving it to destination.
`void` | `setCleaningDestination(boolean cleaningDestination)` Defines whether DataPort should delete all data from destination tables before doing the port.
`void` | `setDelegate(DataPortDelegate delegate)`
`void` | `setDestinationNode(DataNode destinationNode)` Sets the DataNode serving as a destination of the ported data.
`void` | `setEntities(Collection entities)` Sets the initial list of entities to process.
`void` | `setInsertBatchSize(int insertBatchSize)` Sets a parameter used for tuning insert batches.
`void` | `setSourceNode(DataNode sourceNode)` Sets the DataNode serving as a source of the ported data.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INSERT_BATCH_SIZE

    public static final int INSERT_BATCH_SIZE

See Also:
  Constant Field Values

### sourceNode

    protected DataNode sourceNode

### destinationNode

    protected DataNode destinationNode

### entities

    protected Collection entities

### cleaningDestination

    protected boolean cleaningDestination

### delegate

    protected DataPortDelegate delegate

### insertBatchSize

    protected int insertBatchSize

Constructor Detail

### DataPort

    public DataPort()

### DataPort

    public DataPort(DataPortDelegate delegate)

  Creates a new DataPort instance, setting its delegate.

Method Detail

### execute

    public void execute()
                 throws CayenneException

  Runs DataPort. The instance must be fully configured by the time this method is invoked, having its delegate, source and destinatio nodes, and a list of entities set up.

  Throws:
    `CayenneException`

### processDelete

    protected void processDelete(List entities)

  Cleans up destination tables data.

### processInsert

    protected void processInsert(List entities)
                          throws CayenneException

  Reads source data from source, saving it to destination.

  Throws:
    `CayenneException`

### getEntities

    public Collection getEntities()

### getSourceNode

    public DataNode getSourceNode()

### getDestinationNode

    public DataNode getDestinationNode()

### setEntities

    public void setEntities(Collection entities)

  Sets the initial list of entities to process. This list can be later modified by the delegate.

### setSourceNode

    public void setSourceNode(DataNode sourceNode)

  Sets the DataNode serving as a source of the ported data.

### setDestinationNode

    public void setDestinationNode(DataNode destinationNode)

  Sets the DataNode serving as a destination of the ported data.

### getDelegate

    public DataPortDelegate getDelegate()

  Returns previously initialized DataPortDelegate object.

### setDelegate

    public void setDelegate(DataPortDelegate delegate)

### isCleaningDestination

    public boolean isCleaningDestination()

  Returns true if a DataPort was configured to delete all data from the destination tables.

### setCleaningDestination

    public void setCleaningDestination(boolean cleaningDestination)

  Defines whether DataPort should delete all data from destination tables before doing the port.

### getInsertBatchSize

    public int getInsertBatchSize()

### setInsertBatchSize

    public void setInsertBatchSize(int insertBatchSize)

  Sets a parameter used for tuning insert batches. If set to a value greater than zero, DataPort will commit every N rows. If set to value less or equal to zero, DataPort will commit only once at the end of the insert.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.