openlsd.database.data
Class LSDDbStorage

java.lang.Object
  extended by openlsd.database.data.LSDDbStorage

public class LSDDbStorage
extends java.lang.Object

Class for Storage manipulation

Author:
Frederic Bregier LGPL

Field Summary
static java.lang.String allfields
          DB field for select
 long fda
          Next available Document (Following Document Available)
static java.lang.String[] fields
          DB field names
 int hasdel
          Has this Storage some Deleted Document
static java.lang.String index
          Index in Table LSDDbStorage alter index "LSD"."
 long lid
          Legacy Id
static int rfda
          DB field rank
static int rhasdel
          DB field rank
static int rlid
          DB field rank
static int rsid
          DB field rank
static int rsize
          DB field rank
 long sid
          Storage Id
 long size
          Current size of the Legacy
static java.lang.String table
          information for DB manipulation: Table name
 
Constructor Summary
LSDDbStorage()
          Create an empty Storage
LSDDbStorage(long lid, long sid, long size, long fda)
          Create a Storage from args
 
Method Summary
static boolean alterIndex(LSDDbAdmin admin)
          Alter rebuild all index associated with this Table
 void assign(long lid, long sid, long size, long fda, int hasdel)
          Assign values to object
static void checkStorageMT(LSDDbAdmin admin, LSDDbLegacy legacy, boolean repair)
          Check Storage from Legacy with Document in DB with mini threading
static boolean del(LSDDbAdmin admin, long lid, long sid)
          Del the Legacy object from DB
static boolean delIfEmpty(LSDDbAdmin admin, long lid, long sid)
          Del the Legacy object from DB if size <= 0
static int delStoragesIfEmpty(LSDDbAdmin admin, long lid)
          Del all Storages associated with the lid from the DB if empty
 boolean get(LSDDbAdmin admin, long lid, long sid)
          Get the Storage object from DB
 boolean get(java.sql.ResultSet resultSet)
          Get Values from ResultSet
 boolean getForUpdateAdd(LSDDbAdmin admin, long lid, long sid, long filesize, int hasdel)
          Get for update the Storage object (lid, sid) from DB (the parameter filesize is added to the existing Storage size)
This version is correct since fda is not changed.
static LSDLinkedLongList<LSDDbStorage> getStorages(LSDDbAdmin admin, long lid)
          Get all Storages associated with the lid from the DB.
static java.lang.String getWhereCond(java.lang.String id, java.lang.String slid)
          Get String for Where Condition
static java.lang.String getWhereCondPl(java.lang.String id)
          Get String for Where Condition
static java.lang.String getWhereCondPls()
          Get String for Where Condition
 boolean insertNoCommit(LSDDbAdmin admin, long filesize)
          Insert data into DB from object.
static void purgeStorageMT(LSDDbAdmin admin, LSDDbLegacy legacy, boolean repair, int nbthread)
          Purge Storage from Legacy of empty Documents in DB with multithreading by storage
 boolean setAdd(LSDDbAdmin admin, long filesize)
          Update or Insert data into DB from object.
 boolean setAddNoCommit(LSDDbAdmin admin, long filesize)
          Update or Insert data into DB from object.
static boolean setAddSizeNoCommit(LSDDbAdmin admin, long lid, long sid, long did, long filesize)
          Update or Insert size into DB.
static LSDDbPreparedStatement setPGet(LSDDbAdmin admin, long lid)
          Create the PreparedStatement for Get
 java.lang.String toString()
          Object to String
 boolean update(LSDDbAdmin admin, long size, long fdanew, int hasdel)
          Update some Values into BD (size is set, not added)
 boolean updateNoCommit(LSDDbAdmin admin, long size, long fdanew, int hasdel)
          Update some Values into BD (size is set, not added) without commit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lid

public long lid
Legacy Id


sid

public long sid
Storage Id


size

public long size
Current size of the Legacy


fda

public long fda
Next available Document (Following Document Available)


hasdel

public int hasdel
Has this Storage some Deleted Document


table

public static final java.lang.String table
information for DB manipulation: Table name

See Also:
Constant Field Values

fields

public static final java.lang.String[] fields
DB field names


rlid

public static final int rlid
DB field rank

See Also:
Constant Field Values

rsid

public static final int rsid
DB field rank

See Also:
Constant Field Values

rsize

public static final int rsize
DB field rank

See Also:
Constant Field Values

rfda

public static final int rfda
DB field rank

See Also:
Constant Field Values

rhasdel

public static final int rhasdel
DB field rank

See Also:
Constant Field Values

allfields

public static final java.lang.String allfields
DB field for select


index

public static final java.lang.String index
Index in Table LSDDbStorage alter index "LSD"."PK_STORAGE" rebuild; alter index "LSD"."IDX_STO_LID" rebuild; alter index "LSD"."IDX_STO_LIDSIDSIZE" rebuild;

See Also:
Constant Field Values
Constructor Detail

LSDDbStorage

public LSDDbStorage()
Create an empty Storage


LSDDbStorage

public LSDDbStorage(long lid,
                    long sid,
                    long size,
                    long fda)
Create a Storage from args

Parameters:
lid -
sid -
size -
fda -
Method Detail

assign

public void assign(long lid,
                   long sid,
                   long size,
                   long fda,
                   int hasdel)
Assign values to object

Parameters:
lid -
sid -
size -
fda -
hasdel -

get

public boolean get(java.sql.ResultSet resultSet)
Get Values from ResultSet

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

getWhereCondPls

public static java.lang.String getWhereCondPls()
Get String for Where Condition

Returns:
the string as result

getWhereCondPl

public static java.lang.String getWhereCondPl(java.lang.String id)
Get String for Where Condition

Parameters:
id -
Returns:
the string as result

getWhereCond

public static java.lang.String getWhereCond(java.lang.String id,
                                            java.lang.String slid)
Get String for Where Condition

Parameters:
id -
slid -
Returns:
the string as result

setPGet

public static LSDDbPreparedStatement setPGet(LSDDbAdmin admin,
                                             long lid)
Create the PreparedStatement for Get

Parameters:
admin -
lid -
Returns:
LSDDbPreparedStatement

get

public boolean get(LSDDbAdmin admin,
                   long lid,
                   long sid)
Get the Storage object from DB

Parameters:
admin -
lid -
sid -
Returns:
True if OK, else False

getForUpdateAdd

public boolean getForUpdateAdd(LSDDbAdmin admin,
                               long lid,
                               long sid,
                               long filesize,
                               int hasdel)
Get for update the Storage object (lid, sid) from DB (the parameter filesize is added to the existing Storage size)
This version is correct since fda is not changed. CheckStorage has an internal function to correct this fda.

Parameters:
admin -
lid -
sid -
filesize -
hasdel -
Returns:
True if OK, else False

setAdd

public boolean setAdd(LSDDbAdmin admin,
                      long filesize)
Update or Insert data into DB from object. lid and sid must be ok. The filesize is added to the size of the Storage.

Parameters:
admin -
filesize -
Returns:
True if OK, else False

setAddNoCommit

public boolean setAddNoCommit(LSDDbAdmin admin,
                              long filesize)
Update or Insert data into DB from object. lid and sid must be ok. The filesize is added to the size of the Storage. No Commit is done.

Parameters:
admin -
filesize -
Returns:
True if OK, else False

setAddSizeNoCommit

public static boolean setAddSizeNoCommit(LSDDbAdmin admin,
                                         long lid,
                                         long sid,
                                         long did,
                                         long filesize)
Update or Insert size into DB. lid and sid must be ok. The filesize is added to the size of the Storage. No Commit is done.

Parameters:
admin -
lid -
sid -
did -
filesize -
Returns:
True if OK, else False

insertNoCommit

public boolean insertNoCommit(LSDDbAdmin admin,
                              long filesize)
Insert data into DB from object. lid and sid must be ok. The filesize is added to the size of the Storage. No Commit is done.

Parameters:
admin -
filesize -
Returns:
True if OK, else False

update

public boolean update(LSDDbAdmin admin,
                      long size,
                      long fdanew,
                      int hasdel)
Update some Values into BD (size is set, not added)

Parameters:
admin -
size -
fdanew -
hasdel -
Returns:
True if OK, else False

updateNoCommit

public boolean updateNoCommit(LSDDbAdmin admin,
                              long size,
                              long fdanew,
                              int hasdel)
Update some Values into BD (size is set, not added) without commit

Parameters:
admin -
size -
fdanew -
hasdel -
Returns:
True if OK, else False

getStorages

public static LSDLinkedLongList<LSDDbStorage> getStorages(LSDDbAdmin admin,
                                                          long lid)
Get all Storages associated with the lid from the DB.

Parameters:
admin -
lid -
Returns:
the list of storage or null if an error occurs

del

public static boolean del(LSDDbAdmin admin,
                          long lid,
                          long sid)
Del the Legacy object from DB

Parameters:
admin -
lid -
sid -
Returns:
True if OK, else False

delIfEmpty

public static boolean delIfEmpty(LSDDbAdmin admin,
                                 long lid,
                                 long sid)
Del the Legacy object from DB if size <= 0

Parameters:
admin -
lid -
sid -
Returns:
True if OK, else False

delStoragesIfEmpty

public static int delStoragesIfEmpty(LSDDbAdmin admin,
                                     long lid)
Del all Storages associated with the lid from the DB if empty

Parameters:
admin -
lid -
Returns:
the number of services deleted

checkStorageMT

public static void checkStorageMT(LSDDbAdmin admin,
                                  LSDDbLegacy legacy,
                                  boolean repair)
Check Storage from Legacy with Document in DB with mini threading

Parameters:
admin -
legacy -
repair -

purgeStorageMT

public static void purgeStorageMT(LSDDbAdmin admin,
                                  LSDDbLegacy legacy,
                                  boolean repair,
                                  int nbthread)
Purge Storage from Legacy of empty Documents in DB with multithreading by storage

Parameters:
admin -
legacy -
repair -
nbthread -

alterIndex

public static boolean alterIndex(LSDDbAdmin admin)
Alter rebuild all index associated with this Table

Parameters:
admin -
Returns:
True if ok

toString

public java.lang.String toString()
Object to String

Overrides:
toString in class java.lang.Object
Returns:
the string that displays this object
See Also:
Object.toString()