org.bibalex.daf.managers.checkin
Class ExternalID

java.lang.Object
  extended by org.bibalex.daf.managers.checkin.ExternalID

public class ExternalID
extends java.lang.Object

Represents a row in the ExternalID table.

Author:
Shehab.Kamal

Field Summary
private  DBConnection conn
           
private  int id
           
private  boolean isDefault
           
private  int jobID
           
private  java.util.Date timeStamp
           
private  int typeID
           
private  java.lang.String typeName
           
private  java.lang.String value
           
 
Constructor Summary
ExternalID()
          Creates a new instance of ExternalID.
This constructor leaves all the fields empty.
ExternalID(DataTable table)
          Creates a new instance of ExternalID.
This constructor fills all the fields from the DataTable.
ExternalID(int id, java.lang.String value, int typeID, boolean isDefault, int jobID, java.util.Date timeStamp)
          Creates a new instance of ExternalID.
 
Method Summary
 boolean add()
          Adds this entry to the database.
Note: The date is ignored while adding as the underlying stored procedure uses Now() for the date.
static ExternalID getByID(int id)
          Gets the ExternalID object that has the given ID.
static ExternalID[] getByJob(int jobID)
          Gets all the external IDs that belong to this job.
 DBConnection getConn()
           
static ExternalID getDefaults(int jobID)
          Gets dafult ExtID value and ExtID type
 int getID()
           
 int getJobID()
           
 java.util.Date getTimeStamp()
           
 int getTypeID()
           
 java.lang.String getTypeName()
           
 java.lang.String getValue()
           
 boolean isDefault()
           
static int occurrencesInDatabase(int typeID, java.lang.String value)
          Gets the number of the occurrences for the given type-value pair.
 void setDefault(boolean isDefault)
           
 void setFieldsFromDataTable(DataTable table)
          Uses the given DataTable to set the fields.
 void setID(int id)
           
 void setJobID(int jobID)
           
 void setTimeStamp(java.util.Date timeStamp)
           
 void setTypeID(int typeID)
           
 void setTypeName(java.lang.String typeName)
           
 void setValue(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

private DBConnection conn

id

private int id

value

private java.lang.String value

typeID

private int typeID

typeName

private java.lang.String typeName

isDefault

private boolean isDefault

jobID

private int jobID

timeStamp

private java.util.Date timeStamp
Constructor Detail

ExternalID

public ExternalID()
Creates a new instance of ExternalID.
This constructor leaves all the fields empty.


ExternalID

public ExternalID(int id,
                  java.lang.String value,
                  int typeID,
                  boolean isDefault,
                  int jobID,
                  java.util.Date timeStamp)
Creates a new instance of ExternalID.

Parameters:
id - The ID value.
value - The value.
typeID - The type ID value.
isDefault - The is Default value.
jobID - The job ID value.
timeStamp - The TimeStamp value.

ExternalID

public ExternalID(DataTable table)
           throws java.lang.Exception
Creates a new instance of ExternalID.
This constructor fills all the fields from the DataTable. Remarks: Fields that correspond to null database columns are left to default values, i.e. String and Date will be null and int will be 0.

Parameters:
table - The DataTable used to construct the object.
Throws:
java.lang.Exception - If the ExternalID couldn't be constructed from the DataTable.
Method Detail

setFieldsFromDataTable

public void setFieldsFromDataTable(DataTable table)
                            throws java.lang.Exception
Uses the given DataTable to set the fields.

Parameters:
table - The DataTable used to set the fields.
Throws:
java.lang.Exception - If the fields couldn't be filled from the DataTable.

add

public boolean add()
Adds this entry to the database.
Note: The date is ignored while adding as the underlying stored procedure uses Now() for the date.

Returns:
True if this instance has been added to the database otherwise false.

getConn

public DBConnection getConn()
Returns:
Returns the conn.

getID

public int getID()
Returns:
Returns the ID.

setID

public void setID(int id)
Parameters:
id - The id to set.

isDefault

public boolean isDefault()
Returns:
Returns the isDefault.

setDefault

public void setDefault(boolean isDefault)
Parameters:
isDefault - The isDefault to set.

getJobID

public int getJobID()
Returns:
Returns the jobID.

setJobID

public void setJobID(int jobID)
Parameters:
jobID - The jobID to set.

getTimeStamp

public java.util.Date getTimeStamp()
Returns:
Returns the timeStamp.

setTimeStamp

public void setTimeStamp(java.util.Date timeStamp)
Parameters:
timeStamp - The timeStamp to set.

getTypeID

public int getTypeID()
Returns:
Returns the typeID.

setTypeID

public void setTypeID(int typeID)
Parameters:
typeID - The typeID to set.

getTypeName

public java.lang.String getTypeName()
Returns:
Returns the typeName.

setTypeName

public void setTypeName(java.lang.String typeName)
Parameters:
typeName - The typeName to set.

getValue

public java.lang.String getValue()
Returns:
Returns the value.

setValue

public void setValue(java.lang.String value)
Parameters:
value - The value to set.

getByJob

public static ExternalID[] getByJob(int jobID)
                             throws java.lang.Exception
Gets all the external IDs that belong to this job.

Parameters:
jobID - The ID of the job to get its ExternalID rows.
Returns:
An ExternalID[] holding all the ExternalID rows that correspond to this job.
Empty array if the job has no related rows.
Throws:
java.lang.Exception - If the database couldn't be queried.

getByID

public static ExternalID getByID(int id)
                          throws java.lang.Exception
Gets the ExternalID object that has the given ID.

Parameters:
id - The ID of the ExternalID object.
Returns:
The ExternalID object with the given ID.
Null if the object is not found.
Throws:
java.lang.Exception - If the database couldn't be queried.

getDefaults

public static ExternalID getDefaults(int jobID)
                              throws java.lang.Exception
Gets dafult ExtID value and ExtID type

Parameters:
jobID -
Returns:
ExternalID
Throws:
java.lang.Exception - If the database couldn't be queried.

occurrencesInDatabase

public static int occurrencesInDatabase(int typeID,
                                        java.lang.String value)
Gets the number of the occurrences for the given type-value pair.

Parameters:
typeID - The type ID to search for
value - The value to search for.
Returns:
The number of occurrences for the given type-value pair.
If the database couldn't be queried -1 is returned.