Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.objectstyle.cayenne.dataport
Class DataPort  view DataPort download DataPort.java

java.lang.Object
  extended byorg.objectstyle.cayenne.dataport.DataPort

public class DataPort
extends java.lang.Object

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 one data node and write to another. It uses DataPortDelegate interface to decouple porting logic from such things like filtering entities (include/exclude from port based on some criteria), logging the progress of port operation, qualifying the queries, etc. It is possible to build various configurable interfaces for this tool. E.g. Cayenne implements CayenneDataPort Ant task.


Field Summary
protected  boolean cleaningDestination
           
protected  DataPortDelegate delegate
           
protected  org.objectstyle.cayenne.access.DataNode destinationNode
           
protected  java.util.List entities
           
static int INSERT_BATCH_SIZE
           
protected  org.objectstyle.cayenne.access.DataNode sourceNode
           
 
Constructor Summary
DataPort(DataPortDelegate delegate)
          Creates new DataPort instance, initializing it with a DataPortDelegate.
 
Method Summary
 void execute()
          Runs DataPort.
 DataPortDelegate getDelegate()
           
 org.objectstyle.cayenne.access.DataNode getDestinationNode()
           
 java.util.List getEntities()
           
 org.objectstyle.cayenne.access.DataNode getSourceNode()
           
 boolean isCleaningDestination()
           
protected  void processDelete(java.util.List entities)
          Cleans up destination tables data.
protected  void processInsert(java.util.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(org.objectstyle.cayenne.access.DataNode destinationNode)
          Sets the DataNode serving as a destination of the ported data.
 void setEntities(java.util.List entities)
          Sets the initial list of entities to process.
 void setSourceNode(org.objectstyle.cayenne.access.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 org.objectstyle.cayenne.access.DataNode sourceNode

destinationNode

protected org.objectstyle.cayenne.access.DataNode destinationNode

entities

protected java.util.List entities

cleaningDestination

protected boolean cleaningDestination

delegate

protected DataPortDelegate delegate
Constructor Detail

DataPort

public DataPort(DataPortDelegate delegate)
Creates new DataPort instance, initializing it with a DataPortDelegate.

Method Detail

execute

public void execute()
             throws java.lang.Exception
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.


processDelete

protected void processDelete(java.util.List entities)
Cleans up destination tables data.


processInsert

protected void processInsert(java.util.List entities)
                      throws java.lang.Exception
Reads source data from source, saving it to destination.


getEntities

public java.util.List getEntities()

getSourceNode

public org.objectstyle.cayenne.access.DataNode getSourceNode()

getDestinationNode

public org.objectstyle.cayenne.access.DataNode getDestinationNode()

setEntities

public void setEntities(java.util.List entities)
Sets the initial list of entities to process. This list can be later modified by the delegate.


setSourceNode

public void setSourceNode(org.objectstyle.cayenne.access.DataNode sourceNode)
Sets the DataNode serving as a source of the ported data.


setDestinationNode

public void setDestinationNode(org.objectstyle.cayenne.access.DataNode destinationNode)
Sets the DataNode serving as a destination of the ported data.


getDelegate

public DataPortDelegate getDelegate()

setDelegate

public void setDelegate(DataPortDelegate delegate)

isCleaningDestination

public boolean isCleaningDestination()

setCleaningDestination

public void setCleaningDestination(boolean cleaningDestination)
Defines whether DataPort should delete all data from destination tables before doing the port.