2.8.1: 2008-09-10

net.sf.basedb.clients.migrate
Class ReporterTransfer

java.lang.Object
  extended by net.sf.basedb.clients.migrate.Manager
      extended by net.sf.basedb.clients.migrate.Transfer
          extended by net.sf.basedb.clients.migrate.ReporterTransfer

public class ReporterTransfer
extends Transfer

This class provides methods for transferring reporter data from base 1 to BASE 2.

Version:
2.0
Author:
Gregory, Martin, Nicklas
Last modified
$Date: 2008-09-05 17:15:54 +0200 (Fri, 05 Sep 2008) $

Field Summary
private  ReporterBatcher batcher
          Used for inserting reporter into Base 2.
private  Map<Integer,Integer> duplicates
          Maps BASE 1 reporters that are considered duplicate by BASE 2 after whitespace has been trimmed from the external ID.
private  Map<String,Integer> externalIdMap
          Maps Reporter external ID to Base 1 ID.
private static Logger log
          Logger for this class
private  Map<Integer,ReporterData> reporterMap
          Maps Base 1 ID to ReporterData object.
private  boolean RESUME
          Flag that indicates if we should run in RESUME mode (ie.
private  String[] stringProperties
          Set string and text properties, order must match the select statement except for the id and reporterId in the beginning Extended properties are defined in the extended-properties.xml file for class ReporterData.
 
Fields inherited from class net.sf.basedb.clients.migrate.Transfer
BASE2, FROM, itemList, LIMIT, LOCAL_MYSQL_TRANSFER, mapIds, progress, properties, QUICK_TRANSFER, selectOffset, sessionControl, TO
 
Constructor Summary
ReporterTransfer(boolean resume)
          Reporters are independant from other transfers.
 
Method Summary
private  ReporterData createDataItem(ResultSet rs)
          Creates a ReporterData from the current position in ResultSet.
 Integer getBase2Id(DbControl dc, int base1ReporterId)
           
 ReporterData getReporterById(DbControl dc, int base1ReporterId)
           
private  void mapDuplicateReporters()
           
private  void mapMigratedReporters(DbControl dc, DynamicReporterQuery query)
           
protected  void run(PreparedStatement ps, int from, int size)
          Recursive run over a SQL query defined by a prepared statement and LIMIT values from and size.
 void start()
          Starts the actual transfer.
 
Methods inherited from class net.sf.basedb.clients.migrate.Transfer
cleanUpMemory, commit, createItem, createItem, dependencyFailure, done, getBase2Id, getBatchSize, getCount, getDependencyStatus, getIdMap, getInt, getProperty, initIdMap, isDone, mapId, newDbControl, readRestorePointData, run, runUnBatched, saveItem, setup, startProgress, writeRestorePointData
 
Methods inherited from class net.sf.basedb.clients.migrate.Manager
getPreparedStatements, prepareStatementFromFile, print, printDate, setPreparedStatements, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
Logger for this class


reporterMap

private Map<Integer,ReporterData> reporterMap
Maps Base 1 ID to ReporterData object.


externalIdMap

private Map<String,Integer> externalIdMap
Maps Reporter external ID to Base 1 ID. Only used temporary until the reporterMap is generated.


duplicates

private Map<Integer,Integer> duplicates
Maps BASE 1 reporters that are considered duplicate by BASE 2 after whitespace has been trimmed from the external ID. Only used temporary until the reporterMap is generated. Map contain BASE 1 ID --> Base 1 ID where the value is the "real" reporter that is migrated to BASE 2.


batcher

private ReporterBatcher batcher
Used for inserting reporter into Base 2.


RESUME

private boolean RESUME
Flag that indicates if we should run in RESUME mode (ie. NOT create new reporter items, only map ID:s)


stringProperties

private String[] stringProperties
Set string and text properties, order must match the select statement except for the id and reporterId in the beginning Extended properties are defined in the extended-properties.xml file for class ReporterData. Performance is increased by using the column index instead of name.

Constructor Detail

ReporterTransfer

ReporterTransfer(boolean resume)
Reporters are independant from other transfers.

Method Detail

start

public void start()
Description copied from class: Transfer
Starts the actual transfer.

Specified by:
start in class Transfer

run

protected void run(PreparedStatement ps,
                   int from,
                   int size)
Recursive run over a SQL query defined by a prepared statement and LIMIT values from and size.

Overrides:
run in class Transfer
Parameters:
ps - PreparedStatement which includes a "LIMIT ?,?" at the end.
from - int indicating start position of the ResultSet.
size - int indicating number of rows to include.
See Also:
Manager.prepareStatementFromFile(String)

mapMigratedReporters

private void mapMigratedReporters(DbControl dc,
                                  DynamicReporterQuery query)

mapDuplicateReporters

private void mapDuplicateReporters()

createDataItem

private ReporterData createDataItem(ResultSet rs)
                             throws BaseException,
                                    SQLException
Creates a ReporterData from the current position in ResultSet.

Parameters:
rs - ResultSet containing the data for this item.
Returns:
ReporterData or null if another reporter with same ID has already been created
Throws:
BaseException
SQLException - If current ResultSet position is invalid or number of columns in the select statement is to low.

getReporterById

public ReporterData getReporterById(DbControl dc,
                                    int base1ReporterId)

getBase2Id

public Integer getBase2Id(DbControl dc,
                          int base1ReporterId)

2.8.1: 2008-09-10