com.is.jrf
Class CompoundPrimaryKeyColumnSpec

java.lang.Object
  |
  +--com.is.jrf.CompoundPrimaryKeyColumnSpec
All Implemented Interfaces:
ColumnSpec, JRFConstants

public class CompoundPrimaryKeyColumnSpec
extends java.lang.Object
implements ColumnSpec

This implementer of ColumnSpec holds multiple AbstractColumnSpec subclass instances that make up the primary key for a table.


Field Summary
protected static java.lang.Class s_class
           
 
Fields inherited from interface com.is.jrf.JRFConstants
CURRENT_DATE, CURRENT_TIMESTAMP, DEFAULT_TO_EMPTY_STRING, DEFAULT_TO_FALSE, DEFAULT_TO_NOW, DEFAULT_TO_NULL, DEFAULT_TO_ONE, DEFAULT_TO_TODAY, DEFAULT_TO_TRUE, DEFAULT_TO_ZERO, EQUALS, NATURAL_PRIMARY_KEY, NO_POST_FIND, NOT_EQUALS, OPTIMISTIC_LOCK, REQUIRED, SEQUENCED_PRIMARY_KEY, SUBTYPE_IDENTIFIER, UNIQUE
 
Constructor Summary
CompoundPrimaryKeyColumnSpec()
          Constructor for the CompoundPrimaryKeyColumnSpec object use the method addColumnSpec(...) in conjunction with this.
CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne, ColumnSpec columnTwo)
          Constructor for the CompoundPrimaryKeyColumnSpec object
CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne, ColumnSpec columnTwo, ColumnSpec columnThree)
          Constructor for the CompoundPrimaryKeyColumnSpec object
CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne, ColumnSpec columnTwo, ColumnSpec columnThree, ColumnSpec columnFour)
          Constructor for the CompoundPrimaryKeyColumnSpec object
CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne, ColumnSpec columnTwo, ColumnSpec columnThree, ColumnSpec columnFour, ColumnSpec columnFive)
          Constructor for the CompoundPrimaryKeyColumnSpec object
CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne, ColumnSpec columnTwo, ColumnSpec columnThree, ColumnSpec columnFour, ColumnSpec columnFive, ColumnSpec columnSix)
          Constructor for the CompoundPrimaryKeyColumnSpec object
 
Method Summary
 void addColumnSpec(ColumnSpec aColumnSpec)
          Adds a feature to the ColumnSpec attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.String buildNameValuePair(java.lang.Object pkOrPersistentObject, java.lang.String separator, java.lang.String tableName, DatabasePolicy dbPolicy)
          Build a string that represents a name/value pair
 java.lang.String buildWhereClause(java.lang.Object aPO, java.lang.String separator, java.lang.String tableName, DatabasePolicy dbPolicy)
          Build a compound where clause (without the WHERE).
 java.lang.String columnDefinitionString(DatabasePolicy dbPolicy)
          Return something like "id INTEGER, code VARCHAR(999)" for use in a CREATE TABLE statement.
 void copyAttribute(PersistentObject aPO1, PersistentObject aPO2)
          This is an override of the method in ColumnSpec.
 void copyColumnValueToPersistentObject(JDBCHelper helper, PersistentObject aPO)
          Ask each of my ColumnSpec instances to get the appropriate column from the helper and stick it into the PersistentObject.
 void decodeToPersistentObject(java.lang.String aString, PersistentObject aPO)
          The String parameter must have been encoded with the encodeFromPersistentObject(...) method.
 java.lang.String encodeFromPersistentObject(PersistentObject aPO)
          Convert the attribute for this object to a String that can be unconverted later by the decodeToPersistentObject(...) method.
 java.lang.String formatForSql(java.lang.Object obj, DatabasePolicy dbPolicy)
          Description of the Method
 java.lang.Class getColumnClass()
          Gets the ColumnClass attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.String getColumnName()
          Return the column names of my children.
 java.lang.Object getColumnValueFrom(JDBCHelper helper)
          Gets the ColumnValueFrom attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.Object getDefault()
          Gets the Default attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.String getFullyQualifiedColumnName(java.lang.String tableAlias)
          Return the column names (qualified with their table name/alias) of my children.
 java.lang.String getGetter()
          Gets the Getter attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.String getSetter()
          Gets the Setter attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.String getSqlValueFrom(PersistentObject aPO, DatabasePolicy dbPolicy)
          Return the SQL values of my children with a comma between each.
 java.lang.Object getValueFrom(PersistentObject aPO)
          Gets the ValueFrom attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isNaturalPrimaryKey()
          Gets the NaturalPrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isOptimisticLock()
          Gets the OptimisticLock attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isPrimaryKey()
          Gets the PrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isRequired()
          Gets the Required attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isSequencedPrimaryKey()
          Gets the SequencedPrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isSubtypeIdentifier()
          Gets the SubtypeIdentifier attribute of the CompoundPrimaryKeyColumnSpec object
 boolean isUnique()
          Gets the Unique attribute of the CompoundPrimaryKeyColumnSpec object
 void setRequired(boolean b)
          Sets the Required attribute of the CompoundPrimaryKeyColumnSpec object
 void setValueTo(java.lang.Object aValue, PersistentObject aPO)
          Sets the ValueTo attribute of the CompoundPrimaryKeyColumnSpec object
 java.lang.Object validateRequired(PersistentObject aPO)
          Make sure the PersistentObject object has these attributes.
 void validateUnique(PersistentObject aPO, JDBCHelper helper, ColumnSpec pkColumnSpec, DatabasePolicy dbPolicy, java.lang.String tableName)
          If this is a unique column (or columns), make sure the value doesn't already exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_class

protected static java.lang.Class s_class
Constructor Detail

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec()
Constructor for the CompoundPrimaryKeyColumnSpec object use the method addColumnSpec(...) in conjunction with this.

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne,
                                    ColumnSpec columnTwo)
Constructor for the CompoundPrimaryKeyColumnSpec object
Parameters:
columnOne - a ColumnSpec
columnTwo - a ColumnSpec

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne,
                                    ColumnSpec columnTwo,
                                    ColumnSpec columnThree)
Constructor for the CompoundPrimaryKeyColumnSpec object
Parameters:
columnOne - a ColumnSpec
columnTwo - a ColumnSpec
columnThree - a ColumnSpec

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne,
                                    ColumnSpec columnTwo,
                                    ColumnSpec columnThree,
                                    ColumnSpec columnFour)
Constructor for the CompoundPrimaryKeyColumnSpec object
Parameters:
columnOne - a ColumnSpec
columnTwo - a ColumnSpec
columnThree - a ColumnSpec
columnFour - a ColumnSpec

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne,
                                    ColumnSpec columnTwo,
                                    ColumnSpec columnThree,
                                    ColumnSpec columnFour,
                                    ColumnSpec columnFive)
Constructor for the CompoundPrimaryKeyColumnSpec object
Parameters:
columnOne - a ColumnSpec
columnTwo - a ColumnSpec
columnThree - a ColumnSpec
columnFour - a ColumnSpec
columnFive - a ColumnSpec

CompoundPrimaryKeyColumnSpec

public CompoundPrimaryKeyColumnSpec(ColumnSpec columnOne,
                                    ColumnSpec columnTwo,
                                    ColumnSpec columnThree,
                                    ColumnSpec columnFour,
                                    ColumnSpec columnFive,
                                    ColumnSpec columnSix)
Constructor for the CompoundPrimaryKeyColumnSpec object
Parameters:
columnOne - a ColumnSpec
columnTwo - a ColumnSpec
columnThree - a ColumnSpec
columnFour - a ColumnSpec
columnFive - a ColumnSpec
columnSix - a ColumnSpec
Method Detail

addColumnSpec

public void addColumnSpec(ColumnSpec aColumnSpec)
Adds a feature to the ColumnSpec attribute of the CompoundPrimaryKeyColumnSpec object
Parameters:
aColumnSpec - The feature to be added to the ColumnSpec attribute

copyColumnValueToPersistentObject

public void copyColumnValueToPersistentObject(JDBCHelper helper,
                                              PersistentObject aPO)
                                       throws java.sql.SQLException
Ask each of my ColumnSpec instances to get the appropriate column from the helper and stick it into the PersistentObject.
Specified by:
copyColumnValueToPersistentObject in interface ColumnSpec
Parameters:
helper - a value of type 'JDBCHelper'
aPO - a value of type 'PersistentObject'
Throws:
java.sql.SQLException - if an error occurs

encodeFromPersistentObject

public java.lang.String encodeFromPersistentObject(PersistentObject aPO)
Convert the attribute for this object to a String that can be unconverted later by the decodeToPersistentObject(...) method. The result of this method is not for use in SQL.
Specified by:
encodeFromPersistentObject in interface ColumnSpec
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
Description of the Returned Value

decodeToPersistentObject

public void decodeToPersistentObject(java.lang.String aString,
                                     PersistentObject aPO)
The String parameter must have been encoded with the encodeFromPersistentObject(...) method. This is used by AbstractDomain.decodePrimaryKey(aString). Parse out the String into tokens. Ask each columnspec to convert the string to the appropriate object, then for each of my column specs, convert the given String into a PersistentObject.
Specified by:
decodeToPersistentObject in interface ColumnSpec
Parameters:
aString - a value of type 'String'
aPO - a value of type 'PersistentObject'

copyAttribute

public void copyAttribute(PersistentObject aPO1,
                          PersistentObject aPO2)
This is an override of the method in ColumnSpec.
Specified by:
copyAttribute in interface ColumnSpec
Parameters:
aPO1 - a value of type 'PersistentObject'
aPO2 - a value of type 'PersistentObject'

buildWhereClause

public java.lang.String buildWhereClause(java.lang.Object aPO,
                                         java.lang.String separator,
                                         java.lang.String tableName,
                                         DatabasePolicy dbPolicy)
Build a compound where clause (without the WHERE).
Specified by:
buildWhereClause in interface ColumnSpec
Parameters:
aPO - a value of type 'PersistentObject'
separator - a value of type 'String'
tableName - a value of type 'String'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

validateRequired

public java.lang.Object validateRequired(PersistentObject aPO)
                                  throws MissingAttributeException
Make sure the PersistentObject object has these attributes. All compound primary key columns are required by definition.
Specified by:
validateRequired in interface ColumnSpec
Parameters:
aPO - a value of type 'PersistentObject'
Returns:
Description of the Returned Value
Throws:
MissingAttributeException - if an error occurs

getFullyQualifiedColumnName

public java.lang.String getFullyQualifiedColumnName(java.lang.String tableAlias)
Return the column names (qualified with their table name/alias) of my children. The names are separated by commas.
Specified by:
getFullyQualifiedColumnName in interface ColumnSpec
Parameters:
tableAlias - a value of type 'String'
Returns:
a value of type 'String'

getColumnName

public java.lang.String getColumnName()
Return the column names of my children. The names are separated by commas.
Specified by:
getColumnName in interface ColumnSpec
Returns:
a value of type 'String'

getSqlValueFrom

public java.lang.String getSqlValueFrom(PersistentObject aPO,
                                        DatabasePolicy dbPolicy)
Return the SQL values of my children with a comma between each.
Specified by:
getSqlValueFrom in interface ColumnSpec
Parameters:
aPO - a value of type 'PersistentObject'
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

columnDefinitionString

public java.lang.String columnDefinitionString(DatabasePolicy dbPolicy)
Return something like "id INTEGER, code VARCHAR(999)" for use in a CREATE TABLE statement.
Specified by:
columnDefinitionString in interface ColumnSpec
Parameters:
dbPolicy - a value of type 'DatabasePolicy'
Returns:
a value of type 'String'

validateUnique

public void validateUnique(PersistentObject aPO,
                           JDBCHelper helper,
                           ColumnSpec pkColumnSpec,
                           DatabasePolicy dbPolicy,
                           java.lang.String tableName)
                    throws DuplicateRowException
If this is a unique column (or columns), make sure the value doesn't already exist.
Specified by:
validateUnique in interface ColumnSpec
Parameters:
aPO - a value of type 'PersistentObject'
helper - a value of type 'JDBCHelper'
pkColumnSpec - a value of type 'ColumnSpec'
dbPolicy - a value of type 'DatabasePolicy'
tableName - a value of type 'String'
Throws:
DuplicateRowException - if an error occurs

buildNameValuePair

public java.lang.String buildNameValuePair(java.lang.Object pkOrPersistentObject,
                                           java.lang.String separator,
                                           java.lang.String tableName,
                                           DatabasePolicy dbPolicy)
Build a string that represents a name/value pair
Specified by:
buildNameValuePair in interface ColumnSpec
Parameters:
pkOrPersistentObject - a primary key value or a PersistentObject
separator - usually "="
tableName - name of the table
dbPolicy - a value of type 'DatabasePolicy'
Returns:
The built name-value pair

setValueTo

public void setValueTo(java.lang.Object aValue,
                       PersistentObject aPO)
Sets the ValueTo attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
setValueTo in interface ColumnSpec
Parameters:
aValue - The new ValueTo value
aPO - The new ValueTo value

getValueFrom

public java.lang.Object getValueFrom(PersistentObject aPO)
Gets the ValueFrom attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getValueFrom in interface ColumnSpec
Parameters:
aPO - Description of Parameter
Returns:
The value of ValueFrom

formatForSql

public java.lang.String formatForSql(java.lang.Object obj,
                                     DatabasePolicy dbPolicy)
Description of the Method
Specified by:
formatForSql in interface ColumnSpec
Parameters:
obj - Description of Parameter
dbPolicy - Description of Parameter
Returns:
Description of the Returned Value

getColumnValueFrom

public java.lang.Object getColumnValueFrom(JDBCHelper helper)
                                    throws java.sql.SQLException
Gets the ColumnValueFrom attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getColumnValueFrom in interface ColumnSpec
Parameters:
helper - a JDBCHelper
Returns:
The value of ColumnValueFrom
Throws:
java.sql.SQLException - If SQLException is thrown by the JDBC driver.

getColumnClass

public java.lang.Class getColumnClass()
Gets the ColumnClass attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getColumnClass in interface ColumnSpec
Returns:
The value of ColumnClass

getGetter

public java.lang.String getGetter()
Gets the Getter attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getGetter in interface ColumnSpec
Returns:
The value of Getter

getSetter

public java.lang.String getSetter()
Gets the Setter attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getSetter in interface ColumnSpec
Returns:
The value of Setter

isRequired

public boolean isRequired()
Gets the Required attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isRequired in interface ColumnSpec
Returns:
The value of Required

isSequencedPrimaryKey

public boolean isSequencedPrimaryKey()
Gets the SequencedPrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isSequencedPrimaryKey in interface ColumnSpec
Returns:
The value of SequencedPrimaryKey

isNaturalPrimaryKey

public boolean isNaturalPrimaryKey()
Gets the NaturalPrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isNaturalPrimaryKey in interface ColumnSpec
Returns:
The value of NaturalPrimaryKey

isSubtypeIdentifier

public boolean isSubtypeIdentifier()
Gets the SubtypeIdentifier attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isSubtypeIdentifier in interface ColumnSpec
Returns:
The value of SubtypeIdentifier

isPrimaryKey

public boolean isPrimaryKey()
Gets the PrimaryKey attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isPrimaryKey in interface ColumnSpec
Returns:
The value of PrimaryKey

isUnique

public boolean isUnique()
Gets the Unique attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isUnique in interface ColumnSpec
Returns:
The value of Unique

getDefault

public java.lang.Object getDefault()
Gets the Default attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
getDefault in interface ColumnSpec
Returns:
The value of Default

isOptimisticLock

public boolean isOptimisticLock()
Gets the OptimisticLock attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
isOptimisticLock in interface ColumnSpec
Returns:
The value of OptimisticLock

setRequired

public void setRequired(boolean b)
Sets the Required attribute of the CompoundPrimaryKeyColumnSpec object
Specified by:
setRequired in interface ColumnSpec
Parameters:
b - The new Required value