2.9.2: 2009-01-08

net.sf.basedb.clients.migrate
Class UploadFileTransfer

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.SharedItemTransfer
              extended by net.sf.basedb.clients.migrate.CommonItemTransfer
                  extended by net.sf.basedb.clients.migrate.FileTransfer
                      extended by net.sf.basedb.clients.migrate.UploadFileTransfer

public class UploadFileTransfer
extends FileTransfer

All files are migrated in one go. This is done to ease the transfer of file related items down the road. In BASE 2 files are unique in regards to their md5sum. No files having equal md5sum will be migrated.

Version:
2.0
Author:
Gregory Vincic
Last modified
$Date: 2008-09-11 22:05:50 +0200 (Thu, 11 Sep 2008) $

Field Summary
private  boolean createImage
          If createItem(ResultSet) should create an image related file.
private  boolean createPrintmap
          If createItem(ResultSet) should create a printmap related file.
private  boolean createProtocol
          If createItem(ResultSet) should create a protocol related file.
private  boolean createRawBioAssay
          If createItem(ResultSet) should create a rawBioAssay related file.
private  HashMap<Integer,Integer> imageFileMap
          Map of image related base 1 -> BASE 2 files
private static Logger log
          This class's logger
private  HashMap<String,Integer> md5ToIdMap
          Stores unique md5 -> fileId
private  String path
          Current path to files e.g userfiles + "/raw data"
private  HashMap<Integer,Integer> printmapFileMap
          Map of printmap related base 1 -> BASE 2 files
private  HashMap<Integer,Integer> protocolFileMap
          Map of protocol related base 1 -> BASE 2 files
private  HashMap<Integer,Integer> rawBioAssayFileMap
          Map of rawBioAssay related base 1 -> BASE 2 files
private  String userfiles
          Path to base 1 userfiles e.g.
private  boolean useSubpath
          Whether or not item id's are used to calculate a subpath directory.
 
Fields inherited from class net.sf.basedb.clients.migrate.FileTransfer
VERIFY_MD5
 
Fields inherited from class net.sf.basedb.clients.migrate.CommonItemTransfer
DESCRIPTION, NAME, REMOVED
 
Fields inherited from class net.sf.basedb.clients.migrate.SharedItemTransfer
GID, GROUP_ACCESS, groupT, ID, OWNER, userT, WORLD_ACCESS
 
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
UploadFileTransfer(UserTransfer userT, GroupTransfer groupT, String path)
           
 
Method Summary
protected  void createItem(ResultSet rs)
          Creates a file from the current row in the resultSet.
 File getFileByMd5(DbControl dc, User owner, String md5)
          Returns the file matching owner and md5.
 File getImageFileById(DbControl dc, int base1Id)
          Returns the image related file matching a base1Id.
 File getPrintmapFileById(DbControl dc, int base1Id)
          Returns the printmap related file matching a base1Id.
 File getProtocolFileById(DbControl dc, int base1Id)
          Returns the protocol related file matching a base1Id.
 File getRawBioAssayFileById(DbControl dc, int base1Id)
          Returns the rawBioAssay related file matching a base1Id.
 void start()
          Starts this transfer.
private  void transferImages(PreparedStatement ps)
          Starts transfer of image related files Path to images is hardcoded here.
private  void transferPrintmaps(PreparedStatement ps)
          Starts transfer of printmap related files Path to printmap is hardcoded here.
private  void transferProtocolFiles(PreparedStatement ps)
          Starts transfer of protocol related files Path to protocols is hardcoded here.
private  void transferRawBioAssayFiles(PreparedStatement ps)
          Starts transfer of rawBioAssay related files.
private  void transferUploads(PreparedStatement ps)
          Starts transfer of upload related files Path to uploads is hardcoded here.
 
Methods inherited from class net.sf.basedb.clients.migrate.FileTransfer
getExistingFile, md5sum, md5sum, replaceForbiddenCharacters, setCommonItemData, transferFile
 
Methods inherited from class net.sf.basedb.clients.migrate.CommonItemTransfer
setCommonItemData
 
Methods inherited from class net.sf.basedb.clients.migrate.SharedItemTransfer
chmod, chown, getOwner, setSharedItemData
 
Methods inherited from class net.sf.basedb.clients.migrate.Transfer
cleanUpMemory, commit, createItem, dependencyFailure, done, getBase2Id, getBatchSize, getCount, getDependencyStatus, getIdMap, getInt, getProperty, initIdMap, isDone, mapId, newDbControl, readRestorePointData, run, 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

userfiles

private String userfiles
Path to base 1 userfiles e.g. /usr/local/base/data


path

private String path
Current path to files e.g userfiles + "/raw data"


md5ToIdMap

private HashMap<String,Integer> md5ToIdMap
Stores unique md5 -> fileId


protocolFileMap

private HashMap<Integer,Integer> protocolFileMap
Map of protocol related base 1 -> BASE 2 files


imageFileMap

private HashMap<Integer,Integer> imageFileMap
Map of image related base 1 -> BASE 2 files


printmapFileMap

private HashMap<Integer,Integer> printmapFileMap
Map of printmap related base 1 -> BASE 2 files


rawBioAssayFileMap

private HashMap<Integer,Integer> rawBioAssayFileMap
Map of rawBioAssay related base 1 -> BASE 2 files


useSubpath

private boolean useSubpath
Whether or not item id's are used to calculate a subpath directory.


createProtocol

private boolean createProtocol
If createItem(ResultSet) should create a protocol related file.


createImage

private boolean createImage
If createItem(ResultSet) should create an image related file.


createPrintmap

private boolean createPrintmap
If createItem(ResultSet) should create a printmap related file.


createRawBioAssay

private boolean createRawBioAssay
If createItem(ResultSet) should create a rawBioAssay related file.


log

private static final Logger log
This class's logger

Constructor Detail

UploadFileTransfer

UploadFileTransfer(UserTransfer userT,
                   GroupTransfer groupT,
                   String path)
Parameters:
userT - UserTransfer used to find owners of files
groupT - GroupTransfer used to find group owners of files
path - Subdirectory within the userfiles directory containing the files to transfer
Method Detail

start

public void start()
Starts this transfer.

Specified by:
start in class Transfer

transferRawBioAssayFiles

private void transferRawBioAssayFiles(PreparedStatement ps)
Starts transfer of rawBioAssay related files. Path to rawBioAssays is hardcoded here.

Parameters:
ps - Select statement listing rawBioAssay's from base 1

transferPrintmaps

private void transferPrintmaps(PreparedStatement ps)
Starts transfer of printmap related files Path to printmap is hardcoded here.

Parameters:
ps - Select statement listing image's from base 1

transferImages

private void transferImages(PreparedStatement ps)
Starts transfer of image related files Path to images is hardcoded here.

Parameters:
ps - Select statement listing image's from base 1

transferProtocolFiles

private void transferProtocolFiles(PreparedStatement ps)
Starts transfer of protocol related files Path to protocols is hardcoded here.

Parameters:
ps - Select statement listing protocol's from base 1

transferUploads

private void transferUploads(PreparedStatement ps)
Starts transfer of upload related files Path to uploads is hardcoded here.

Parameters:
ps - Select statement listing upload's from base 1

createItem

protected void createItem(ResultSet rs)
                   throws BaseException,
                          SQLException
Creates a file from the current row in the resultSet. This method is called from Transfer.runUnBatched(PreparedStatement, int, int)

Overrides:
createItem in class Transfer
Parameters:
rs - ResultSet containing information about the file.
Throws:
BaseException
SQLException

getFileByMd5

public File getFileByMd5(DbControl dc,
                         User owner,
                         String md5)
Returns the file matching owner and md5.

Parameters:
dc - DbControl used to get the file
owner -
md5 -
Returns:
File or null if no matching file is found

getProtocolFileById

public File getProtocolFileById(DbControl dc,
                                int base1Id)
Returns the protocol related file matching a base1Id.

Parameters:
dc - DbControl used to get the file.
base1Id -

getImageFileById

public File getImageFileById(DbControl dc,
                             int base1Id)
Returns the image related file matching a base1Id.

Parameters:
dc - DbControl used to get the file.
base1Id -

getPrintmapFileById

public File getPrintmapFileById(DbControl dc,
                                int base1Id)
Returns the printmap related file matching a base1Id.

Parameters:
dc - DbControl used to get the file.
base1Id - Of the array design

getRawBioAssayFileById

public File getRawBioAssayFileById(DbControl dc,
                                   int base1Id)
Returns the rawBioAssay related file matching a base1Id.

Parameters:
dc - DbControl used to get the file.
base1Id -

2.9.2: 2009-01-08