net.sf.dc.core.objects
Class DcObject

java.lang.Object
  extended bynet.sf.dc.core.objects.DcObject
Direct Known Subclasses:
BookCategory, DcMediaObject, Loan, Person, PersonType, SoftwareCategory

public abstract class DcObject
extends java.lang.Object

Base class for all Data Crow objects. Here the fields, values and required fields are stored. Checks are done to garantee uniqueness and validity of the items. Objects which extend this class need to override the save and load methods

Since:
1.3
Version:
0.5
Author:
Robert Jan van der Waals

Field Summary
static int _ID
           
static int _SYS_AVAILABLE
           
static int _SYS_LOANDURATION
           
static int _SYS_LOANEDBY
           
static int _SYS_MODULE
           
protected  java.util.Collection alChildren
           
protected static boolean alwaysGenerateID
           
protected  boolean bValidation
          Indicates of the data should be checked for validity
protected  int module
           
protected  int uiRowNumber
           
protected  java.util.Map values
           
 
Constructor Summary
protected DcObject()
          Creates an empty data crow object
 
Method Summary
 void addChild(DcObject child)
          Adds a child to this object
 void addChildren(java.util.Collection children)
           
 void addRequest(IRequest request)
          Add a requestor.
 void applySettings(DcFieldDefinitions definitions)
          Initialize all user settings on this data crow object
 void checkIntegrity(boolean update)
          Checks if the values are unique and if all the required fields have been filled
 void clearValues()
          Sets all values to empty
 void copy(DcObject dco)
           
 void delete()
           
 void finalize()
           
 java.lang.String[] getChangedFields()
          Returns the labels of the fields that have been marked as changed
 java.util.Collection getChildren()
          Retrieve all children of this object
 int getDatabaseFieldCount()
           
 java.lang.String getDatabaseFieldName(int index)
          Returns the database field name for the given field
 int[] getDisabledFields()
          Retrieves all disabled fields
 java.lang.String getDisplayString(int index)
           
 DcField getField(int index)
          Returns the field definition object for the given field index
 int[] getFieldIndices()
          Returns all field indices
 java.util.Collection getFields()
          Returns all the field definitions.
 int getFieldType(int index)
          Returns the UI field type for the given field
abstract  java.lang.String getFilename()
          Returns the filename
 java.util.Collection getHiddenFields()
          Retrieves all currently, to the user, hidden fields
abstract  javax.swing.ImageIcon getIcon()
          Returns the icon for this object.
 java.lang.String getID()
          Retrieves the ID for this data crow object
 java.lang.String getLabel(int index)
           
 int getMaxFieldLength(int index)
          Retrieves the maximum length for the given field
 DCModule getModule()
          Returns the module to which this object belongs.
 java.util.Collection getNotSearchableFields()
          Retrieves all fields on which a search cannot be performed.
 int getParentReferenceFieldIndex()
          Retrieve the field index holding the reference to the parent (the primary key of the parent)
 RequestCollection getRequests()
          Returns all requestors
 int getRow()
           
 boolean getSilence()
          Indicates if queries should display output
 java.lang.String getTableJoin()
           
 java.lang.String getTableName()
           
 java.lang.String getTableShortName()
           
 java.lang.Object getValue(int index)
          Returns the value of a field
protected  DcValue getValueDef(int index)
          Retrieves the value for the given field index
 java.util.Collection getVisibleFields()
          Retrieves the indices of the, for the user visible fields
 boolean isBatch()
          Part of a batch ?
 boolean isChanged()
          Indicates if changes have been made to this data crow object.
 boolean isChanged(int index)
          Indicates if changes have been made to the specified value.
 boolean isEnabled(int index)
          Indicates if the given field is visible to the user or not
 boolean isEndOfBatch()
          End of the batch ?
 boolean isRequired(int index)
          Indicates whether the given field is required or not
 boolean isSearchable(int index)
          Indicates whether the given field is required or not
 void isUnique(DcObject o, boolean bUpdateQuery)
          Checks to see whether the item already exists or not
 void load(QueryOptions options)
          Loads items.
 void markAsUnchanged()
          Sets all fields to 'unchanged'.
 void reload()
           
 void removeChildren()
          Remove all children from this object
 void removeRequestors()
          Remove all requestors listening in on this object
 void saveNew()
          Inserts a new item.
 void saveUpdate()
          Updates an item.
 void setBatch(boolean batch)
          Indicates this object being part of a larger operation
 void setChanged(int index, boolean b)
          Marks the specified value as changed (or not) This means that the value will be considered for an insert or update to the database
 void setChildren(java.util.Collection children)
           
 void setEndOfBatch(boolean end)
          Indicates this object to be the last in row of an update / insert or delete
 void setIDs()
          Apply the IDs on this object and its children
protected abstract  void setModuleIndex()
          Sets the module index / sets the ownership of this data crow object
 void setRow(int row)
           
 void setSilence(boolean silence)
          Disables the output of this query to the log and log screen.
 void setValidation(boolean validate)
          Specifies if values should be validated
 void setValue(int index, java.lang.Object o)
          Sets a value for the given field
 void setValueForColumn(java.lang.String column, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uiRowNumber

protected int uiRowNumber

module

protected int module

values

protected java.util.Map values

bValidation

protected boolean bValidation
Indicates of the data should be checked for validity


alwaysGenerateID

protected static boolean alwaysGenerateID

alChildren

protected java.util.Collection alChildren

_ID

public static final int _ID
See Also:
Constant Field Values

_SYS_MODULE

public static final int _SYS_MODULE
See Also:
Constant Field Values

_SYS_AVAILABLE

public static final int _SYS_AVAILABLE
See Also:
Constant Field Values

_SYS_LOANEDBY

public static final int _SYS_LOANEDBY
See Also:
Constant Field Values

_SYS_LOANDURATION

public static final int _SYS_LOANDURATION
See Also:
Constant Field Values
Constructor Detail

DcObject

protected DcObject()
Creates an empty data crow object

Method Detail

removeRequestors

public void removeRequestors()
Remove all requestors listening in on this object


setValueForColumn

public void setValueForColumn(java.lang.String column,
                              java.lang.Object value)

getRequests

public RequestCollection getRequests()
Returns all requestors


getTableName

public java.lang.String getTableName()

getTableShortName

public java.lang.String getTableShortName()

getTableJoin

public java.lang.String getTableJoin()

getDatabaseFieldCount

public int getDatabaseFieldCount()

getLabel

public java.lang.String getLabel(int index)

addRequest

public void addRequest(IRequest request)
Add a requestor. The requestor will be executed once the object is saved / deleted or updated


setEndOfBatch

public void setEndOfBatch(boolean end)
Indicates this object to be the last in row of an update / insert or delete

Parameters:
end -

setBatch

public void setBatch(boolean batch)
Indicates this object being part of a larger operation

Parameters:
batch - part of batch y/n

isBatch

public boolean isBatch()
Part of a batch ?


isEndOfBatch

public boolean isEndOfBatch()
End of the batch ?


removeChildren

public void removeChildren()
Remove all children from this object


setChildren

public void setChildren(java.util.Collection children)

addChildren

public void addChildren(java.util.Collection children)

addChild

public void addChild(DcObject child)
Adds a child to this object

Parameters:
child -

getChildren

public java.util.Collection getChildren()
Retrieve all children of this object


getParentReferenceFieldIndex

public int getParentReferenceFieldIndex()
Retrieve the field index holding the reference to the parent (the primary key of the parent)


getIcon

public abstract javax.swing.ImageIcon getIcon()
Returns the icon for this object. Example; Software Categories has an icon


getFilename

public abstract java.lang.String getFilename()
Returns the filename


getModule

public DCModule getModule()
Returns the module to which this object belongs. Shortcut for getting the module object instead of the module index.


getFields

public java.util.Collection getFields()
Returns all the field definitions. Shortcut; normally you would first have to ask for the module and then ask to the module which field definitions it contains.


markAsUnchanged

public void markAsUnchanged()
Sets all fields to 'unchanged'. This garantees that none of the values will be saved to the database when performing an update or insert. All 'setValue' calls are up to this moment are discarded


reload

public void reload()

isChanged

public boolean isChanged()
Indicates if changes have been made to this data crow object. A field is indicated as beign changed when the user or system has performed a set value.


isChanged

public boolean isChanged(int index)
Indicates if changes have been made to the specified value. A field is indicated as beign changed when the user or system has performed a set value.

Parameters:
index - the value index to check on

setChanged

public void setChanged(int index,
                       boolean b)
Marks the specified value as changed (or not) This means that the value will be considered for an insert or update to the database

Parameters:
index - the value index to mark as changed / unchanged
b - changed y/n

isEnabled

public boolean isEnabled(int index)
Indicates if the given field is visible to the user or not

Parameters:
index - field index

isRequired

public boolean isRequired(int index)
Indicates whether the given field is required or not

Parameters:
index - field index

isSearchable

public boolean isSearchable(int index)
Indicates whether the given field is required or not

Parameters:
index - field index

getDisabledFields

public int[] getDisabledFields()
Retrieves all disabled fields


getHiddenFields

public java.util.Collection getHiddenFields()
Retrieves all currently, to the user, hidden fields


getID

public java.lang.String getID()
Retrieves the ID for this data crow object


getNotSearchableFields

public java.util.Collection getNotSearchableFields()
Retrieves all fields on which a search cannot be performed. Example; a user can not perform a search on a picture field


getVisibleFields

public java.util.Collection getVisibleFields()
Retrieves the indices of the, for the user visible fields


setValue

public void setValue(int index,
                     java.lang.Object o)
Sets a value for the given field


clearValues

public void clearValues()
Sets all values to empty


getMaxFieldLength

public int getMaxFieldLength(int index)
Retrieves the maximum length for the given field

Parameters:
index - field index

getValue

public java.lang.Object getValue(int index)
Returns the value of a field

Returns:
(String) field value

getDisplayString

public java.lang.String getDisplayString(int index)

setRow

public void setRow(int row)

getRow

public int getRow()

getFieldType

public int getFieldType(int index)
Returns the UI field type for the given field

Returns:
UI field type index
See Also:
ComponentFactory

getDatabaseFieldName

public java.lang.String getDatabaseFieldName(int index)
Returns the database field name for the given field

Parameters:
index - field index

saveNew

public void saveNew()
             throws ValidationException
Inserts a new item. Requests to the UI can be passed.

Throws:
ValidationException

saveUpdate

public void saveUpdate()
                throws ValidationException
Updates an item. Requests to the UI can be passed.

Throws:
ValidationException

delete

public void delete()

load

public void load(QueryOptions options)
Loads items. Requests to the UI can be passed.

Parameters:
options - query options, can be null

setSilence

public void setSilence(boolean silence)
Disables the output of this query to the log and log screen. Also disables showing messageboxes when a query was success- fully executed

Parameters:
silence - show output y/n

getSilence

public boolean getSilence()
Indicates if queries should display output


setValidation

public void setValidation(boolean validate)
Specifies if values should be validated

Parameters:
validate - validate values y/n

getField

public DcField getField(int index)
Returns the field definition object for the given field index

Parameters:
index - field index

getChangedFields

public java.lang.String[] getChangedFields()
Returns the labels of the fields that have been marked as changed


checkIntegrity

public void checkIntegrity(boolean update)
                    throws ValidationException
Checks if the values are unique and if all the required fields have been filled

Parameters:
update - indicates if the values are new or existing
Throws:
ValidationException

isUnique

public void isUnique(DcObject o,
                     boolean bUpdateQuery)
              throws ValidationException
Checks to see whether the item already exists or not

Parameters:
o - object to be checked
bUpdateQuery - indicates whether the object is to be updated or if it is a new object
Throws:
ValidationException

getFieldIndices

public int[] getFieldIndices()
Returns all field indices


setModuleIndex

protected abstract void setModuleIndex()
Sets the module index / sets the ownership of this data crow object


applySettings

public void applySettings(DcFieldDefinitions definitions)
Initialize all user settings on this data crow object


setIDs

public void setIDs()
Apply the IDs on this object and its children


getValueDef

protected DcValue getValueDef(int index)
Retrieves the value for the given field index

Parameters:
index - field index

copy

public void copy(DcObject dco)

finalize

public void finalize()
              throws java.lang.Throwable
Throws:
java.lang.Throwable