openlsd.appli.autoimport.commonimport
Class LSDImportAbstract

java.lang.Object
  extended by openlsd.appli.autoimport.commonimport.LSDImportAbstract
Direct Known Subclasses:
LSDAutoImport, LSDAutoImportBlock, LSDImport, LSDImport, LSDImportBlock, LSDImportBlock, LSDImportNet, LSDImportNet, LSDServerImportAbstract, LSMImportAbstract

public abstract class LSDImportAbstract
extends java.lang.Object

Simple class that shared common things and methods between importers

Author:
Frederic BREGIER LGPL 2007

Field Summary
protected  LSDDbAdmin admin
          DB Admin object
protected  boolean async
          Should the connection done as async (join with a future)
protected  boolean blockmode
          Mode block
protected static long countKO
          Number of KO files
protected static long countOK
          Number of OK files
protected static java.util.Date date_debut
          test only
protected  LSDDbAdmin[] dbconns
          Database connections
protected  java.lang.String dir1
          Mode 1: Directory
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> doneQueue
          Queue of imported files
protected  java.util.LinkedList<java.lang.String> errorList
          List of files in error from init part
protected  java.lang.String ext1
          Mode 1: Extension
protected  java.lang.String extidb
          test only
static java.lang.String extKO
          Extension for KO files
static java.lang.String extOK
          Extension for OK files
protected  java.lang.String extStop
          File that stops the process when it exists for AutoImport
protected  java.lang.String file0
          Mode 0: the file
protected static java.io.FileWriter fileKO
          FileWriter for KO status if use2Out is true
protected  java.lang.String filename2Out
          Basename for 2out files
protected static java.io.FileWriter fileOK
          FileWriter for OK status if use2Out is true
protected  boolean isCompressed
          Using compression
protected  boolean isSameLid
          Does this Import using the same Legacy for all files
protected static boolean istesting
          test only
protected static long KO
          Number of KO files
protected  LSDClientDelete lcd
          Delete Client
protected  LSDExtClientInfo lci
          Info Client
protected  LSDClientPut lcp
          Put Client
protected  LSDClientPut[] lcps
          Client connections
protected  long lid0
          Mode 0: the Legacy Id
protected  java.io.File[] listFiles
          List of files from -dir option
protected  java.util.LinkedList<java.lang.String> listline
          List of line from -source option
protected  LSDLoadConfig llc
          LoadConfig from file
protected  LSDBusiness lsdb
          Mode 0: the ID Business
protected  int nbFile
          Number of Files
protected  int nbthread
          Number of threads
protected  int option
          Which mode: 0 = file lid idb, 1 = dir extension, 2 = sourcefile
protected  java.lang.String passwd
          Password for Delete Client
protected  boolean sameDbConnMyltithread
          Is DB Conn using thread shared connection
protected  LSDDbLegacy sameLegacy
          If Same Legacy, which Legacy Object
protected  long sameLid
          If Same Legacy, which Legacy Id
protected  java.lang.String source2
          Mode 2: Source filename
 long targetIdip
          Target if any by default (implies the use of -samelid option) (ML Support)
protected  boolean todelete
          Does the file after successful import should be deleted
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> todoQueue
          Queue of files to import in non block mode
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers> todoQueueB
          Queue of files to import in block mode
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers> todoQueueBLocal
          todo local Queue for block mode
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> todoQueueLocal
          todo local Queue for non block mode
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember>[] todoQueues
          todo Queues for non block mode
protected  java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers>[] todoQueuesB
          todo Queues for block mode
protected static boolean use2Out
          Should we use two files as exit (OK and KO) or one KO by file
 
Constructor Summary
protected LSDImportAbstract(LSDDbAdmin admin, boolean blockmode)
          Create a LSDImport from args
protected LSDImportAbstract(LSDLoadConfig llc, boolean blockmode)
          Create a LSDImport from args
 
Method Summary
protected  boolean errorFromPrepareImportQueue()
          Set the error status from prepareImportQueue
protected  boolean finalizeAfterAutoImport()
          Finalize and close LSD connections for AutoImport
protected  boolean finalizeAfterImport()
          Finalize status and object after import and close LSD connections
protected  boolean finalizeConnection()
          Finalize connection (database)
protected  void finalizeRegisterFile()
          Finalize registered files for OK and KO
protected  boolean finishAfterAutoImport()
          Finalize status and object after import for AutoImport
protected  boolean getClientPutInfo(LSDDbLegacy legacy, boolean compressedClient, boolean keepalived)
          Get a LSDClientPut and LSDClientInfo and LSDClientDelete for the Legacy and using the extension of PutSessionHandler and InfoSessionHandler.
protected  boolean getClientPutInfoFromIpPort(LSDDbLegacy legacy, LSDDbIpPort ipportUser1, LSDDbIpPort ipportProt1, boolean keepalived)
          Get a LSDClientPut and LSDClientInfo and LSDClientDelete for the Legacy and using the extension of PutSessionHandler and InfoSessionHandler.
protected  boolean getIndexFromString(java.lang.String line)
          Get file, lid and idb from the String line where a blank character is a separator.
protected  LSDDbIpPort getIpPortC(LSDDbLegacy legacy)
          Get the IpPort correspondig to the Legacy for Compress
protected  LSDDbIpPort getIpPortP(LSDDbLegacy legacy)
          Get the IpPort correspondig to the Legacy for Protected
protected  LSDDbLegacy getLegacy(long lid)
          Get the Legacy corresponding to the Legacy lid
protected  boolean initConnection()
          InitConnection.
protected  int initializeArgs(java.lang.String[] args, int curargs)
          Get arguments
protected  boolean initOneFileOption(int curargs, java.lang.String[] args)
          Init one File option form args and current position (must be override)
protected  boolean initOptions(java.lang.String[] args, int curargs)
          Finalize Init options from args
protected  boolean initOptionsAuto(java.lang.String[] args, int curargs)
          Finalize Init options from args for AutoImport
 boolean initRegisterFile()
          Create OK and KO files
protected  boolean joinConnection()
          Finalize connection if they are pending
protected  boolean prepareImportQueue()
          Prepare the Import Queue
protected  int privateInitializeArgs(java.lang.String[] args, int curargs)
          Function to override for specific initialization values
static void registerFalseFile(LSDExtQueueMember member, java.lang.String message)
          Register a File as member as False import
static void registerFalseFile(java.lang.String filename, java.lang.String message)
          Register a File as filename as False import
static void registerTrueFile(LSDExtQueueMember member, boolean createOKFile)
          Register a File as True import
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

admin

protected LSDDbAdmin admin
DB Admin object


llc

protected LSDLoadConfig llc
LoadConfig from file


isSameLid

protected boolean isSameLid
Does this Import using the same Legacy for all files


sameLid

protected long sameLid
If Same Legacy, which Legacy Id


sameLegacy

protected LSDDbLegacy sameLegacy
If Same Legacy, which Legacy Object


todelete

protected boolean todelete
Does the file after successful import should be deleted


option

protected int option
Which mode: 0 = file lid idb, 1 = dir extension, 2 = sourcefile


file0

protected java.lang.String file0
Mode 0: the file


lid0

protected long lid0
Mode 0: the Legacy Id


lsdb

protected LSDBusiness lsdb
Mode 0: the ID Business


lci

protected LSDExtClientInfo lci
Info Client


lcp

protected LSDClientPut lcp
Put Client


lcd

protected LSDClientDelete lcd
Delete Client


passwd

protected java.lang.String passwd
Password for Delete Client


dir1

protected java.lang.String dir1
Mode 1: Directory


ext1

protected java.lang.String ext1
Mode 1: Extension


source2

protected java.lang.String source2
Mode 2: Source filename


blockmode

protected boolean blockmode
Mode block


todoQueue

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> todoQueue
Queue of files to import in non block mode


todoQueueB

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers> todoQueueB
Queue of files to import in block mode


doneQueue

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> doneQueue
Queue of imported files


nbFile

protected int nbFile
Number of Files


KO

protected static long KO
Number of KO files


nbthread

protected int nbthread
Number of threads


istesting

protected static boolean istesting
test only


extidb

protected java.lang.String extidb
test only


date_debut

protected static java.util.Date date_debut
test only


sameDbConnMyltithread

protected boolean sameDbConnMyltithread
Is DB Conn using thread shared connection


async

protected boolean async
Should the connection done as async (join with a future)


isCompressed

protected boolean isCompressed
Using compression


lcps

protected LSDClientPut[] lcps
Client connections


dbconns

protected LSDDbAdmin[] dbconns
Database connections


listFiles

protected java.io.File[] listFiles
List of files from -dir option


listline

protected java.util.LinkedList<java.lang.String> listline
List of line from -source option


todoQueues

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember>[] todoQueues
todo Queues for non block mode


todoQueuesB

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers>[] todoQueuesB
todo Queues for block mode


todoQueueLocal

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMember> todoQueueLocal
todo local Queue for non block mode


todoQueueBLocal

protected java.util.concurrent.ConcurrentLinkedQueue<LSDExtQueueMembers> todoQueueBLocal
todo local Queue for block mode


errorList

protected java.util.LinkedList<java.lang.String> errorList
List of files in error from init part


extStop

protected java.lang.String extStop
File that stops the process when it exists for AutoImport


use2Out

protected static boolean use2Out
Should we use two files as exit (OK and KO) or one KO by file


filename2Out

protected java.lang.String filename2Out
Basename for 2out files


fileOK

protected static java.io.FileWriter fileOK
FileWriter for OK status if use2Out is true


fileKO

protected static java.io.FileWriter fileKO
FileWriter for KO status if use2Out is true


countKO

protected static long countKO
Number of KO files


countOK

protected static long countOK
Number of OK files


targetIdip

public long targetIdip
Target if any by default (implies the use of -samelid option) (ML Support)


extOK

public static final java.lang.String extOK
Extension for OK files

See Also:
Constant Field Values

extKO

public static final java.lang.String extKO
Extension for KO files

See Also:
Constant Field Values
Constructor Detail

LSDImportAbstract

protected LSDImportAbstract(LSDLoadConfig llc,
                            boolean blockmode)
Create a LSDImport from args

Parameters:
llc -
blockmode -

LSDImportAbstract

protected LSDImportAbstract(LSDDbAdmin admin,
                            boolean blockmode)
Create a LSDImport from args

Parameters:
admin -
blockmode -
Method Detail

privateInitializeArgs

protected int privateInitializeArgs(java.lang.String[] args,
                                    int curargs)
Function to override for specific initialization values

Parameters:
args -
curargs -
Returns:
the next current rank

initializeArgs

protected int initializeArgs(java.lang.String[] args,
                             int curargs)
Get arguments

Parameters:
args -
curargs -
Returns:
the next current rank

getIndexFromString

protected boolean getIndexFromString(java.lang.String line)
Get file, lid and idb from the String line where a blank character is a separator. Should be override to explicitly specify how to use the correct business implementation.

Parameters:
line -
Returns:
True if OK, else False

initOptions

protected boolean initOptions(java.lang.String[] args,
                              int curargs)
Finalize Init options from args

Parameters:
args -
curargs -
Returns:
True if OK, else False

initOneFileOption

protected boolean initOneFileOption(int curargs,
                                    java.lang.String[] args)
Init one File option form args and current position (must be override)

Parameters:
curargs -
args -
Returns:
True if OK, else False

initRegisterFile

public boolean initRegisterFile()
Create OK and KO files

Returns:
True if OK else False

registerFalseFile

public static void registerFalseFile(LSDExtQueueMember member,
                                     java.lang.String message)
Register a File as member as False import

Parameters:
member -
message -

registerFalseFile

public static void registerFalseFile(java.lang.String filename,
                                     java.lang.String message)
Register a File as filename as False import

Parameters:
filename -
message -

registerTrueFile

public static void registerTrueFile(LSDExtQueueMember member,
                                    boolean createOKFile)
Register a File as True import

Parameters:
member -
createOKFile -

initOptionsAuto

protected boolean initOptionsAuto(java.lang.String[] args,
                                  int curargs)
Finalize Init options from args for AutoImport

Parameters:
args -
curargs -
Returns:
True if OK, else False

initConnection

protected boolean initConnection()
InitConnection. Must be followed later on by joinConnection()

Returns:
True if OK, else False

prepareImportQueue

protected boolean prepareImportQueue()
Prepare the Import Queue

Returns:
True if OK, else False

joinConnection

protected boolean joinConnection()
Finalize connection if they are pending

Returns:
True if OK, else False

errorFromPrepareImportQueue

protected boolean errorFromPrepareImportQueue()
Set the error status from prepareImportQueue

Returns:
True if OK, else False

finalizeAfterImport

protected boolean finalizeAfterImport()
Finalize status and object after import and close LSD connections

Returns:
True if OK, else False

finishAfterAutoImport

protected boolean finishAfterAutoImport()
Finalize status and object after import for AutoImport

Returns:
True if OK, else False

finalizeAfterAutoImport

protected boolean finalizeAfterAutoImport()
Finalize and close LSD connections for AutoImport

Returns:
True if OK, else False

finalizeConnection

protected boolean finalizeConnection()
Finalize connection (database)

Returns:
True if OK, else False

finalizeRegisterFile

protected void finalizeRegisterFile()
Finalize registered files for OK and KO


getClientPutInfo

protected boolean getClientPutInfo(LSDDbLegacy legacy,
                                   boolean compressedClient,
                                   boolean keepalived)
Get a LSDClientPut and LSDClientInfo and LSDClientDelete for the Legacy and using the extension of PutSessionHandler and InfoSessionHandler.

Parameters:
legacy -
compressedClient -
keepalived -
Returns:
True if OK, else False

getClientPutInfoFromIpPort

protected boolean getClientPutInfoFromIpPort(LSDDbLegacy legacy,
                                             LSDDbIpPort ipportUser1,
                                             LSDDbIpPort ipportProt1,
                                             boolean keepalived)
Get a LSDClientPut and LSDClientInfo and LSDClientDelete for the Legacy and using the extension of PutSessionHandler and InfoSessionHandler.

Parameters:
legacy -
ipportUser1 -
ipportProt1 -
keepalived -
Returns:
True if OK, else False

getLegacy

protected LSDDbLegacy getLegacy(long lid)
Get the Legacy corresponding to the Legacy lid

Parameters:
lid -
Returns:
the LSDDBLegacy or null if an error occurs.

getIpPortC

protected LSDDbIpPort getIpPortC(LSDDbLegacy legacy)
Get the IpPort correspondig to the Legacy for Compress

Parameters:
legacy -
Returns:
The LSDDbIpPort or null if an error occurs.

getIpPortP

protected LSDDbIpPort getIpPortP(LSDDbLegacy legacy)
Get the IpPort correspondig to the Legacy for Protected

Parameters:
legacy -
Returns:
The LSDDbIpPort or null if an error occurs.