net.sf.dc.core.objects
Class DCObject

java.lang.Object
  extended bynet.sf.dc.core.objects.DCObject
Direct Known Subclasses:
AudioCD, AudioTrack, Movie, MusicFile, Software, 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 records. Objects which extend this class need to override the save and load methods

Since:
1.3
Version:
DC0.50
Author:
Robert-Jan van der Waals

Field Summary
static int _ID
           
protected static boolean alwaysGenerateID
           
protected  boolean bValidation
          Indicates of the data should be checked for validity
protected  int module
           
protected  java.lang.String sSelectTableDef
           
protected  java.lang.String sTableName
           
protected  int uiRowNumber
           
protected  java.util.Vector values
           
protected  java.util.Vector vChildren
           
protected static WorkFlow wf
           
 
Constructor Summary
protected DCObject()
          Creates an empty data crow object
 
Method Summary
 void addChild(DCObject child)
          Adds a child to this object
 void addRequestor(Requestor requestor)
          Add a requestor.
 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 delete()
           
 java.lang.String[] getChangedFieldNames()
          Returns the labels of the fields that have been marked as changed
 java.lang.Object[] getChangedFieldValues()
          Returns the values of the fields that have been marked as changed
 DCObject[] getChildren()
          Retrieve all children of this object
 java.lang.String[] getCreateStatements()
          Returns the create statement for the table for this object
 java.lang.String getDatabaseFieldName(int index)
          Returns the database field name for the given field
 java.lang.String[] getDatabaseFieldNames()
          Returns all the database field names
 java.lang.String getDisplayString(int index)
           
 DCFieldDefinition getField(int index)
          Returns the field definition object for the given field index
 int[] getFieldIndices()
          Returns all field indices
 DCFieldDefinition[] getFields()
          Returns all the field definitions.
 int getFieldType(int index)
          Returns the UI field type for the given field
 int[] getFieldTypes()
          Returns all the UI field types
 int[] 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)
          Retrieves the label for the given field
 java.lang.String[] getLabels()
          Retrieves all field labels
 int getMaxFieldLength(int index)
          Retrieves the maximum length for the given field
 int[] getMaxFieldLengths()
          Retrieves the maximum length(s) for all the fields
 DCModule getModule()
          Returns the module to which this object belongs.
 int[] 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)
 int[] getReadOnlyFields()
          Returns the fields that are uneditable to the user
 RequestorCollection getRequestors()
          Returns all requestors
 int[] getRequiredFields()
          Returns the required field names
 java.lang.String getSelectTableDef()
           
 boolean getSilence()
          Indicates if queries should display output
 java.lang.String getTableName()
          Returns the table name for this data crow object
 int getUIRowID()
           
 java.lang.String getUnfilledRequiredFields()
          Checks to see whether al required fields have been filled
 java.lang.Object getValue(int index)
          Returns the value of a field
 java.lang.Object[] getValues()
          Returns all values
 int[] getVisibleFields()
          Retrieves the indices of the, for the user visible fields
 java.lang.Object[] getVisibleValues()
          Retrieves the values for the visible fields
protected abstract  void initializeSettings()
          Initialize all user settings on this data crow object
 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 isEndOfBatch()
          End of the batch ?
 boolean isHidden(int index)
          Indicates if the given field is visible to the user or not
 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 record already exists or not
 void load(QueryOptions options)
          Loads records.
 void removeChildren()
          Remove all children from this object
 void removeRequestors()
          Remove all requestors listening in on this object
 void saveNew()
          Inserts a new record.
 void saveUpdate()
          Updates a record.
static void setAlwaysGenerateID(boolean alwaysGenerateID)
          Deprecated.  
 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 setEndOfBatch(boolean end)
          Indicates this object to be the last in row of an update / insert or delete
protected abstract  void setModuleIndex()
          Sets the module index / sets the ownership of this data crow object
protected abstract  void setSelectTableDef()
           
 void setSilence(boolean silence)
          Disables the output of this query to the log and log screen.
protected abstract  void setTableName()
          Sets the database table name for this object
 void setUIRowNumber(int row)
           
 void setValidation(boolean validate)
          Specifies if values should be validated
 void setValue(int index, java.lang.Object value)
          Sets a value for the given field
 void setValues(java.lang.Object[] row)
          Sets a complete set of values on the object calls setValue for each individual value
 QueryCondition toQueryCondition(boolean select)
          Creates a query condition for select statements by using the field names and their values
 void undoChanges()
          Sets all fields to 'unchanged'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uiRowNumber

protected int uiRowNumber

module

protected int module

values

protected java.util.Vector values

bValidation

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


alwaysGenerateID

protected static boolean alwaysGenerateID

wf

protected static final WorkFlow wf

sTableName

protected java.lang.String sTableName

sSelectTableDef

protected java.lang.String sSelectTableDef

vChildren

protected java.util.Vector vChildren

_ID

public static final int _ID
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


getRequestors

public RequestorCollection getRequestors()
Returns all requestors


addRequestor

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

Parameters:
requestor -

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


addChild

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

Parameters:
child -

getChildren

public DCObject[] 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)


setValues

public void setValues(java.lang.Object[] row)
Sets a complete set of values on the object calls setValue for each individual value

See Also:
setValue(int, Object)

getIcon

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


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 DCFieldDefinition[] 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.


undoChanges

public void undoChanges()
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


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

isHidden

public boolean isHidden(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

getHiddenFields

public int[] 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 int[] 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 int[] getVisibleFields()
Retrieves the indices of the, for the user visible fields


getVisibleValues

public java.lang.Object[] getVisibleValues()
Retrieves the values for the visible fields


setAlwaysGenerateID

public static void setAlwaysGenerateID(boolean alwaysGenerateID)
Deprecated.  

Hack: always generate a new ID. Only used for upgrades of old CD Library database. Otherwise: don't touch

Parameters:
alwaysGenerateID -

setValue

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


clearValues

public void clearValues()
Sets all values to empty


getLabels

public java.lang.String[] getLabels()
Retrieves all field labels


getSelectTableDef

public java.lang.String getSelectTableDef()

getTableName

public java.lang.String getTableName()
Returns the table name for this data crow object


getLabel

public java.lang.String getLabel(int index)
Retrieves the label for the given field

Parameters:
index - field index

getMaxFieldLengths

public int[] getMaxFieldLengths()
Retrieves the maximum length(s) for all the fields


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)

getValues

public java.lang.Object[] getValues()
Returns all values

Returns:
value array

setUIRowNumber

public void setUIRowNumber(int row)

getUIRowID

public int getUIRowID()

getFieldTypes

public int[] getFieldTypes()
Returns all the UI field types

Returns:
UI field type indices
See Also:
ComponentFactory

getFieldType

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

Returns:
UI field type index
See Also:
ComponentFactory

getDatabaseFieldNames

public java.lang.String[] getDatabaseFieldNames()
Returns all the database field names

Returns:
database field names array

getDatabaseFieldName

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

Parameters:
index - field index

getRequiredFields

public int[] getRequiredFields()
Returns the required field names


getReadOnlyFields

public int[] getReadOnlyFields()
Returns the fields that are uneditable to the user


saveNew

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

Throws:
ValidationException

saveUpdate

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

Throws:
ValidationException

delete

public void delete()

load

public void load(QueryOptions options)
Loads records. 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

toQueryCondition

public QueryCondition toQueryCondition(boolean select)
Creates a query condition for select statements by using the field names and their values

Parameters:
select - indicates if this is about a select query

getField

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

Parameters:
index - field index

getChangedFieldNames

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


getChangedFieldValues

public java.lang.Object[] getChangedFieldValues()
Returns the values 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

getCreateStatements

public java.lang.String[] getCreateStatements()
Returns the create statement for the table for this object


isUnique

public void isUnique(DCObject o,
                     boolean bUpdateQuery)
              throws ValidationException
Checks to see whether the record 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

getUnfilledRequiredFields

public java.lang.String getUnfilledRequiredFields()
Checks to see whether al required fields have been filled


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


initializeSettings

protected abstract void initializeSettings()
Initialize all user settings on this data crow object


setSelectTableDef

protected abstract void setSelectTableDef()

setTableName

protected abstract void setTableName()
Sets the database table name for this object