openlsd.database.data
Class LSDDbDocument

java.lang.Object
  extended by openlsd.database.data.LSDDbDocument
Direct Known Subclasses:
LSDExtDbDocument

public class LSDDbDocument
extends java.lang.Object

Class for Document manipulation : this class will be extended to follow the business logic (minimal extension is as in LSDExtDbDocument which adds a field for the business data management as LSDBusiness defined and implemented as example in LSDBusinessImpl). This class is intend for simple manipulation outside any Business constraints.

Author:
Frederic Bregier LGPL
See Also:
LSDExtDbDocument

Field Summary
static java.lang.String allfields
          DB field for all fields in select command.
protected static java.lang.String allfields1
          DB field for all fields in select command.
 long did
          Document index
 java.sql.Timestamp docdate
          Date for insertion
static java.lang.String EMPTYMD5
          Empty MD5 value
static java.lang.String[] fields
          DB field names
static java.lang.String getFieldsSet
          Set for all fields except fields used in getWhereClause
static java.lang.String getFieldsSet1
          Set for all fields except fields used in getWhereClause.
static java.lang.String getFieldsSetNULL
          Set values as NULL (or empty) including where clause
static java.lang.String getFieldsSetNULL1
          Set values as NULL (or empty) including where clause
static java.lang.String getWhereClause
          Where condition in " WHERE condition " format which must returns 1 unique document.
static java.lang.String getWhereClauseMD5
          Where condition in " WHERE condition " format which must returns 1 unique document and compares also MD5 value.
static java.lang.String getWhereEmpty
          Search empty document (docdate is null) in one legacy/storage
static java.lang.String index
          Final Index in Table LSDDbDocument
static java.lang.String index1
          Index in Table LSDDbDocument alter index "LSD"."
protected static java.lang.String insertfields
          DB field for all fields in insert command.
protected static java.lang.String insertfields1
          DB field for all fields in insert command.
protected static java.lang.String insertfields2
          DB field for all fields in insert command.
 long lid
          Legacy index
 java.lang.String md5
          MD5 for file
static int rdid
          DB field rank
static int rdocdate
          DB field rank
static int rlid
          DB field rank
static int rmd5
          DB field rank
static int rsid
          DB field rank
static int rsize
          DB field rank
 long sid
          Storage index
 long size
          Size of the document
static java.lang.String table
          information for DB manipulation: Table name
 
Constructor Summary
LSDDbDocument()
          Create an empty Document
LSDDbDocument(long lid, long sid, long did, long size)
          Create an Document from args
 
Method Summary
static boolean alterIndex(LSDDbAdmin admin)
          Alter rebuild all index associated with this Table
 void assign(long lid, long sid, long did, long size)
          Assign values to the object
 boolean del(LSDDbAdmin admin)
          Del the Document object from DB and update the associated Storage in the DB (size of the document is removed)
 boolean delNoLock(LSDDbAdmin admin)
          Del the Document object from DB and update the associated Storage in the DB (size of the document is removed).
protected  boolean eraseFromLSD(LSDDbAdmin admin, boolean isCommit)
          Erase some Values into BD
 boolean get(LSDDbAdmin admin, long lid, long sid, long did)
          Get the Document object from DB
 boolean get(java.sql.ResultSet resultSet)
          Get Values from ResultSet
static java.lang.String get1rstFieldsValues(long lid, long sid, long did, long size, java.sql.Timestamp docdate, java.lang.String md5)
          Get 1rst part of String for Setting as Values.
static java.lang.String getFieldsValues(long lid, long sid, long did, long size, java.sql.Timestamp docdate, java.lang.String md5)
          Get String for Setting as Values
 boolean getFromLSD(java.sql.ResultSet resultSet)
          Get Values from ResultSet
static java.lang.String getWhereCondPils(java.lang.String id)
          Get String for Where Condition
 boolean insert(LSDDbAdmin admin)
          Insert data into DB from object.
 boolean isIdsKO()
          Check if the Ids (lid,sid,did) are KO or not
 boolean set(LSDDbAdmin admin)
          Update or Insert data into DB from object
static LSDDbPreparedStatement setPDel(LSDDbAdmin admin, long lid, long sid, long did)
          Create the PreparedStatement for Delete
 LSDDbPreparedStatement setPGet(LSDDbAdmin admin, long lid, long sid, long did)
          Create the PreparedStatement for Get
static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin, long lid, long sid)
          Create the PreparedStatement for GetCount from Legacy and Storage
static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin, long lid, java.sql.Timestamp time)
          Create the PreparedStatement for GetCount from Legacy and Time
static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin, long lid, java.sql.Timestamp timestart, java.sql.Timestamp timestop)
          Create the PreparedStatement for GetCount from Legacy and Time start and stop
static int setPInsert(LSDDbAdmin admin, long lid, long sid, long did, long size, java.sql.Timestamp docdate, java.lang.String md5)
          Create the PreparedStatement for Insert
static LSDDbPreparedStatement setPUpdate(LSDDbAdmin admin, long lid, long sid, long did, long size, java.sql.Timestamp docdate, java.lang.String md5)
          Create the PreparedStatement for Update
 java.lang.String toString()
          Object to String
 boolean update(LSDDbAdmin admin, java.lang.String shash)
          Update some Values into BD
 boolean updateFromLSD(LSDDbAdmin admin, boolean isCommit, boolean hasdate)
          Update some Values into BD
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lid

public long lid
Legacy index


sid

public long sid
Storage index


did

public long did
Document index


size

public long size
Size of the document


docdate

public java.sql.Timestamp docdate
Date for insertion


md5

public java.lang.String md5
MD5 for file


EMPTYMD5

public static final java.lang.String EMPTYMD5
Empty MD5 value

See Also:
Constant Field Values

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

rdid

public static final int rdid
DB field rank

See Also:
Constant Field Values

rsize

public static final int rsize
DB field rank

See Also:
Constant Field Values

rdocdate

public static final int rdocdate
DB field rank

See Also:
Constant Field Values

rmd5

public static final int rmd5
DB field rank

See Also:
Constant Field Values

allfields1

protected static final java.lang.String allfields1
DB field for all fields in select command. This version is the base.


allfields

public static final java.lang.String allfields
DB field for all fields in select command. This version is the final one. This one shall be override by an extending package such as example LSDExtDbDocument to take into account the business data.


insertfields1

protected static final java.lang.String insertfields1
DB field for all fields in insert command. This version is the base.


insertfields2

protected static final java.lang.String insertfields2
DB field for all fields in insert command. This version is the last fields ")" only.

See Also:
Constant Field Values

insertfields

protected static final java.lang.String insertfields
DB field for all fields in insert command. This version is the final one. This one shall be override by an extending package such as example LSDExtDbDocument to take into account the business data.


getWhereClause

public static java.lang.String getWhereClause
Where condition in " WHERE condition " format which must returns 1 unique document.


getFieldsSet1

public static java.lang.String getFieldsSet1
Set for all fields except fields used in getWhereClause. This version is the base.


getFieldsSet

public static java.lang.String getFieldsSet
Set for all fields except fields used in getWhereClause


getWhereClauseMD5

public static java.lang.String getWhereClauseMD5
Where condition in " WHERE condition " format which must returns 1 unique document and compares also MD5 value.


getWhereEmpty

public static java.lang.String getWhereEmpty
Search empty document (docdate is null) in one legacy/storage


getFieldsSetNULL1

public static java.lang.String getFieldsSetNULL1
Set values as NULL (or empty) including where clause


getFieldsSetNULL

public static java.lang.String getFieldsSetNULL
Set values as NULL (or empty) including where clause


index1

public static final java.lang.String index1
Index in Table LSDDbDocument alter index "LSD"."IDX_DOC_LIDSIZEDOCMD5" rebuild; alter index "LSD"."IDX_DOC_LSDATE" rebuild; alter index "LSD"."PK_DOCUMENT" rebuild;

See Also:
Constant Field Values

index

public static java.lang.String index
Final Index in Table LSDDbDocument

Constructor Detail

LSDDbDocument

public LSDDbDocument()
Create an empty Document


LSDDbDocument

public LSDDbDocument(long lid,
                     long sid,
                     long did,
                     long size)
Create an Document from args

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

assign

public void assign(long lid,
                   long sid,
                   long did,
                   long size)
Assign values to the object

Parameters:
lid -
sid -
did -
size -

get

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

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

getFromLSD

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

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

get1rstFieldsValues

public static java.lang.String get1rstFieldsValues(long lid,
                                                   long sid,
                                                   long did,
                                                   long size,
                                                   java.sql.Timestamp docdate,
                                                   java.lang.String md5)
Get 1rst part of String for Setting as Values. The extend function of getFieldsValues should add the fields with first "," then all fields separated by "," and eventually surrounded with quotes when necessary, and finaly end the string with ") ".

Parameters:
lid -
sid -
did -
size -
docdate -
md5 -
Returns:
the string as result

getFieldsValues

public static java.lang.String getFieldsValues(long lid,
                                               long sid,
                                               long did,
                                               long size,
                                               java.sql.Timestamp docdate,
                                               java.lang.String md5)
Get String for Setting as Values

Parameters:
lid -
sid -
did -
size -
docdate -
md5 -
Returns:
the string as result

getWhereCondPils

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

Parameters:
id -
Returns:
the string as result

setPGet

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

Parameters:
admin -
lid -
sid -
did -
Returns:
LSDDbPreparedStatement

setPGetCount

public static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin,
                                                  long lid,
                                                  java.sql.Timestamp time)
Create the PreparedStatement for GetCount from Legacy and Time

Parameters:
admin -
lid -
time -
Returns:
LSDDbPreparedStatement

setPGetCount

public static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin,
                                                  long lid,
                                                  java.sql.Timestamp timestart,
                                                  java.sql.Timestamp timestop)
Create the PreparedStatement for GetCount from Legacy and Time start and stop

Parameters:
admin -
lid -
timestart -
timestop -
Returns:
LSDDbPreparedStatement

setPGetCount

public static LSDDbPreparedStatement setPGetCount(LSDDbAdmin admin,
                                                  long lid,
                                                  long sid)
Create the PreparedStatement for GetCount from Legacy and Storage

Parameters:
admin -
lid -
sid -
Returns:
LSDDbPreparedStatement

setPUpdate

public static LSDDbPreparedStatement setPUpdate(LSDDbAdmin admin,
                                                long lid,
                                                long sid,
                                                long did,
                                                long size,
                                                java.sql.Timestamp docdate,
                                                java.lang.String md5)
Create the PreparedStatement for Update

Parameters:
admin -
lid -
sid -
did -
size -
docdate -
md5 -
Returns:
LSDDbPreparedStatement

setPInsert

public static int setPInsert(LSDDbAdmin admin,
                             long lid,
                             long sid,
                             long did,
                             long size,
                             java.sql.Timestamp docdate,
                             java.lang.String md5)
Create the PreparedStatement for Insert

Parameters:
admin -
lid -
sid -
did -
size -
docdate -
md5 -
Returns:
the number of new line

setPDel

public static LSDDbPreparedStatement setPDel(LSDDbAdmin admin,
                                             long lid,
                                             long sid,
                                             long did)
Create the PreparedStatement for Delete

Parameters:
admin -
lid -
sid -
did -
Returns:
LSDDbPreparedStatement

get

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

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

isIdsKO

public boolean isIdsKO()
Check if the Ids (lid,sid,did) are KO or not

Returns:
True if the Ids are wrong, else False

set

public boolean set(LSDDbAdmin admin)
Update or Insert data into DB from object

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

insert

public boolean insert(LSDDbAdmin admin)
Insert data into DB from object. Do not commit the result since it is intend only for findFirstIndex where update Storage will commit the result and release the lock on the row.

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

update

public boolean update(LSDDbAdmin admin,
                      java.lang.String shash)
Update some Values into BD

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

updateFromLSD

public boolean updateFromLSD(LSDDbAdmin admin,
                             boolean isCommit,
                             boolean hasdate)
Update some Values into BD

Parameters:
admin -
isCommit -
hasdate - True if a new date should be set
Returns:
True if OK, else False

eraseFromLSD

protected boolean eraseFromLSD(LSDDbAdmin admin,
                               boolean isCommit)
Erase some Values into BD

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

del

public boolean del(LSDDbAdmin admin)
Del the Document object from DB and update the associated Storage in the DB (size of the document is removed)

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

delNoLock

public boolean delNoLock(LSDDbAdmin admin)
Del the Document object from DB and update the associated Storage in the DB (size of the document is removed). Lock must be set outside.

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

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()