Expresso 5-6

com.jcorporate.expresso.core.dataobjects.jdbc
Class JoinedDataObjectMetaData

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObjectMetaData
All Implemented Interfaces:
DataObjectMetaData, Serializable

public class JoinedDataObjectMetaData
extends Object
implements DataObjectMetaData

Not yet released - do not use in your own code yet. This object provides an implementation of DataObjectMetaData that is used for the various join operations. It's job is to provide the descriptive services required for applications such as DBMaint to generically access the JoinedDataObject.

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $
Author:
Michael Rimov

Modify by Yves Henri AMAIZO

See Also:
Serialized Form

Nested Class Summary
 class JoinedDataObjectMetaData.FieldList
          Bean-like class for keeping track of required fields
 class JoinedDataObjectMetaData.Relation
          Bean-like class for keeping track of relations
 
Constructor Summary
JoinedDataObjectMetaData()
          Default constructor
 
Method Summary
 void addDataObject(Class dataObjectClass, String definitionName, String alias, String fieldExpressionList)
          Add a DB Object to the objects being used for this multidbobj query.
 boolean checkZeroUpdate()
          Retrieves whether or not checkZeroUpdate is enabled for this data object
 HashMap createNestedDataObjects()
          Creates a new copy of blank data objects for use in the main objects
 void disableLogging()
          Disable change logging of all objects of this type
 void enableLogging()
          Enable logging of changes to this object.
 List getAliasesInOrder()
          Retrieves a list of Aliases in order that they were added
 Set getAllAttributes(String fieldName)
          Retrieve all the attributes so you can iterate through them.
protected  Set getAllDetails()
           
 HashMap getAllFieldsMap()
          Return the "allFields" Hashtable, which contains all of the DBField objects that make up this DB object.
 HashMap getAllKeysMap()
          Return the "allKeys" hash, containing the DBField objects that make up the primary key for this db object.
 Map getAllRelations()
          Retrieve a list of all relations
 Object getAttribute(String fieldName, String attribName)
          Retrieve the attribute for the field
 int getCacheSize()
          Retrieves the cache size for the primary object
 String getCharset()
          return the current object's character set
 Map getDataObjects()
           
 List getDataObjectsInOrder()
          Retrieves a list of DataObjects that were used in Order
 String getDefaultValue(String fieldName)
          Retrieve the default value for the specified
 String getDescription()
          Retrieve the description of the dataobject join
 String getDescription(Locale l)
          Retrieve the table description in a localized way.
 String getDescription(Locale l, String fieldName)
          Retrieve an i18n'ized description as per the locale defined for the 'client'
 String getDescription(String fieldName)
          Get the unlocalized description for a field name
 String getDetailFieldsForeign(String detailName)
          Retrieve the foreign key fields
 String getDetailFieldsLocal(String detailName)
          Retrieve the local key fields.
 Set getDetailSet()
          Returns the detail set for the primary data object
 ArrayList getFieldListArray()
          Retrieve a list of all the field names
 DataFieldMetaData getFieldMetadata(String fieldName)
          Retrieve the metadata for the particular field
 String[] getFields()
          This convenience method iterates through all the fields belonging to this DBObject returns an array of field names ( String ).
 List getFieldsToRetrieve(String alias)
          Return the List containing the details of fields to retrieve for the DataObject with the given alias
protected  HashMap getForeignKeyToPrimaryKeyMap()
           
 ArrayList getKeyFieldListArray()
          Retrieves the key field list array... which in reality is the key fields of the primary data object
 String getLength(String fieldName)
          Return the length of a field
 int getLengthInt(String fieldName)
          Return the length of a field as an integer
 String getLookupField(String fieldName)
          When you get a lookup object, to perform a complete mapping between the two, you need to know what field name in the remote object maps to this field.
 String getLookupObject(String fieldName)
          Get a field's lookup object - this is the name of another database object that can be used to look up valid values for this object.
protected  HashMap getMyDataObjects()
           
 String getName()
          Get the name of this object
 String[] getObjectAndField(String fieldName)
          Utility method Retrieve the object name and the field name
 Map getPermissions()
           
 int getPrecision(String fieldName)
          Retrieve the precision of a particular field
 String getPrimaryAlias()
          Retrieve the short name of the primary data object.
protected  HashMap getPrimaryToForeignKeyMap()
           
 JoinedDataObjectMetaData.Relation getRelation(String aliaslocal, String aliasJoined)
          Retrieve the relation bean for between two aliases
protected  HashMap getRelations()
           
 String getSchema()
          Retrieve the schema class name
protected  List getSqlRelationList()
           
 List getSQLRelationList()
          Retrieve a list of precalculated relations for the where clauses.
 String getTargetDbCatalog()
          Return the Schema Name of the current database object.
 String getTargetDbSchema()
          Return the Schema Name of the current database object.
 String getTargetSQLTable(String dataContext)
          Set the target table for this DBObject.
 String getType(String fieldName)
          Return the type of a field - this method returns the internal Expresso type
 boolean hasField(String fieldName)
          This method will return a boolean true if the field is defined in the DBOBject, false otherwise.
 boolean isAllowsNull(String fieldName)
          Retrieves whether the value is null
 boolean isField(String fieldName)
          Check if a certain name is a field (of any kind) in this DBOBject
 String isFieldIgnoreCase(String fieldName)
          Check if a certain name is a field (of any kind) in this DBOBject since SQL is case insensitive, ignore case of field name for match, this method takes longer, so use isField if the field name is known precisely
 boolean isLoggingEnabled()
          Retrieves whether or not change logging is enabled for a particular data object
 boolean isMultiValued(String fieldName)
          Method called to determine if a particular field is multi-valued, that is does it have a set of specific values and descriptions
 boolean isReadOnly(String fieldName)
          Is a given field readOnly - these fields are not offered for entry when a form is produced by the generic database maintenance servlet
 boolean isSecret(String fieldName)
          Is a given field 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet (DBMaint).
 boolean isSelectDistinct()
          Retrieve whether or not the Join should be distinct or not
 boolean isVirtual(String fieldName)
          Is a given field virtual?
 void removeAttribute(String fieldName, String attribName)
          Removes the attribute specified by field name and attrib name
 void setAttribute(String fieldName, String attribName, Object attribValue)
          Sets the attribute for the particular field
 void setCacheSize(int newValue)
          Sets the cache size for this DBObject
 void setCheckZeroUpdate(boolean newFlag)
          Turn on or off the facility to verify that when an update is made that at least one record got updated.
 void setDescription(String newDescription)
          Sets the description for the data object join
 void setForeignKey(String shortName, String foreignKey, String shortName2, String primaryKey, int joinType)
          Sets how the various dataobjects are connected, key-wise
 void setName(String theName)
          Sets the name for this joined data object metadata... in this case the definition name
 void setPermissions(Map newPermissions)
           
 void setSelectDistinct(boolean flag)
          Specify that the DISTINCT keyword for unique rows must be specified right after the SELECT keyword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JoinedDataObjectMetaData

public JoinedDataObjectMetaData()
Default constructor

Method Detail

getDataObjects

public Map getDataObjects()

getDataObjectsInOrder

public List getDataObjectsInOrder()
Retrieves a list of DataObjects that were used in Order

Returns:
java.util.List of JDBCDataObjects

getAliasesInOrder

public List getAliasesInOrder()
Retrieves a list of Aliases in order that they were added

Returns:
java.util.List of Strings

getDefaultValue

public String getDefaultValue(String fieldName)
Retrieve the default value for the specified

Specified by:
getDefaultValue in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to check
Returns:
java.lang.String

addDataObject

public void addDataObject(Class dataObjectClass,
                          String definitionName,
                          String alias,
                          String fieldExpressionList)
                   throws DataException,
                          IllegalArgumentException
Add a DB Object to the objects being used for this multidbobj query. The object is specified with a full classname, then a "short" name used to refer to it in this object. For example, the class name might be com.jcorporate.expresso.services.dbobj.SchemaList, the short name might be "schema".

Parameters:
dataObjectClass - java.lang.String
alias - java.lang.String
definitionName - [optional] The definition name if the DataObject is Defineable
fieldExpressionList - [optional] pipe-delimited list of fields to retrieve for this DataObject
Throws:
IllegalArgumentException - if the Class is inappropriate for the system.
DataException

getDetailSet

public Set getDetailSet()
Returns the detail set for the primary data object

Specified by:
getDetailSet in interface DataObjectMetaData
Returns:
java.util.Set

getDetailFieldsLocal

public String getDetailFieldsLocal(String detailName)
Retrieve the local key fields.

Specified by:
getDetailFieldsLocal in interface DataObjectMetaData
Parameters:
detailName - the name of the detail dbobject
Returns:
java.lang.String

getDetailFieldsForeign

public String getDetailFieldsForeign(String detailName)
Retrieve the foreign key fields

Specified by:
getDetailFieldsForeign in interface DataObjectMetaData
Parameters:
detailName - the name of the detail dbobject
Returns:
java.lang.String

isAllowsNull

public boolean isAllowsNull(String fieldName)
                     throws DBException
Retrieves whether the value is null

Specified by:
isAllowsNull in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to check
Returns:
boolean true if it allows null
Throws:
DBException

removeAttribute

public void removeAttribute(String fieldName,
                            String attribName)
Removes the attribute specified by field name and attrib name

Specified by:
removeAttribute in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to modify
attribName - the attribute to remove

setAttribute

public void setAttribute(String fieldName,
                         String attribName,
                         Object attribValue)
                  throws DBException
Sets the attribute for the particular field

Specified by:
setAttribute in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to modify
attribName - the attribute to set
attribValue - the value to set the attribute for.
Throws:
DBException - upon error

getAttribute

public Object getAttribute(String fieldName,
                           String attribName)
                    throws DBException
Retrieve the attribute for the field

Specified by:
getAttribute in interface DataObjectMetaData
Parameters:
fieldName - the field name to get the attribute for
attribName - the attribute name
Returns:
Object the attribute value. [May be null]
Throws:
DBException - upon error

disableLogging

public void disableLogging()
Disable change logging of all objects of this type

Specified by:
disableLogging in interface DataObjectMetaData

enableLogging

public void enableLogging()
Enable logging of changes to this object. Change logging writes an entry to the ChangeLog object every time an add, update, or delete is made to this object. It is used to track important tables, such as user information, account information, etc.

Specified by:
enableLogging in interface DataObjectMetaData

isLoggingEnabled

public boolean isLoggingEnabled()
Retrieves whether or not change logging is enabled for a particular data object

Specified by:
isLoggingEnabled in interface DataObjectMetaData
Returns:
boolean true if logging is enabled.

isFieldIgnoreCase

public String isFieldIgnoreCase(String fieldName)
Check if a certain name is a field (of any kind) in this DBOBject since SQL is case insensitive, ignore case of field name for match, this method takes longer, so use isField if the field name is known precisely

Specified by:
isFieldIgnoreCase in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to check
Returns:
internal format for field name if matched, or null if no match

isField

public boolean isField(String fieldName)
Check if a certain name is a field (of any kind) in this DBOBject

Specified by:
isField in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to check
Returns:
true if the field name exists

getAllFieldsMap

public HashMap getAllFieldsMap()
Return the "allFields" Hashtable, which contains all of the DBField objects that make up this DB object. The field names are of the format [objectalias].[fieldname]

This does not return foreign fields that are keyed to local fields. They are automatically set whenever a foreign key in the local object is set.

Specified by:
getAllFieldsMap in interface DataObjectMetaData
Returns:
java.util.HashMap

getFieldsToRetrieve

public List getFieldsToRetrieve(String alias)
Return the List containing the details of fields to retrieve for the DataObject with the given alias

Parameters:
alias -
Returns:
the list of FieldList objects with field details

getAllKeysMap

public HashMap getAllKeysMap()
Return the "allKeys" hash, containing the DBField objects that make up the primary key for this db object.

Specified by:
getAllKeysMap in interface DataObjectMetaData
Returns:
java.util.HashMap

getCharset

public String getCharset()
return the current object's character set

Specified by:
getCharset in interface DataObjectMetaData
Returns:
java.lang.String

getCacheSize

public int getCacheSize()
Retrieves the cache size for the primary object

Specified by:
getCacheSize in interface DataObjectMetaData
Returns:
int the size of the cache for the object

setCacheSize

public void setCacheSize(int newValue)
Sets the cache size for this DBObject

Specified by:
setCacheSize in interface DataObjectMetaData
Parameters:
newValue - the new value. Must be >= -2
Throws:
IllegalArgumentException - if newValue < -2

getDescription

public String getDescription()
Retrieve the description of the dataobject join

Specified by:
getDescription in interface DataObjectMetaData
Returns:
java.lang.String

getDescription

public String getDescription(Locale l,
                             String fieldName)
Retrieve an i18n'ized description as per the locale defined for the 'client'

Specified by:
getDescription in interface DataObjectMetaData
Parameters:
l - the Locale to use. If null, will use the System default Locale
fieldName - the name of the field to retrieve the i18n'ized description for.
Returns:
an i18n'ized string.

getDescription

public String getDescription(String fieldName)
                      throws DBException
Get the unlocalized description for a field name

Specified by:
getDescription in interface DataObjectMetaData
Parameters:
fieldName - name of the field
Returns:
java.lang.String
Throws:
DBException - upon error

getFieldMetadata

public DataFieldMetaData getFieldMetadata(String fieldName)
Retrieve the metadata for the particular field

Specified by:
getFieldMetadata in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to retrieve the metadata
Returns:
the Field metadata.

getFieldListArray

public ArrayList getFieldListArray()
Retrieve a list of all the field names

Specified by:
getFieldListArray in interface DataObjectMetaData
Returns:
java.util.ArrayList

getKeyFieldListArray

public ArrayList getKeyFieldListArray()
Retrieves the key field list array... which in reality is the key fields of the primary data object

Specified by:
getKeyFieldListArray in interface DataObjectMetaData
Returns:
java.util.ArrayList

getLength

public String getLength(String fieldName)
                 throws DBException
Return the length of a field

Specified by:
getLength in interface DataObjectMetaData
Parameters:
fieldName - The name of the field
Returns:
String: The length of the field
Throws:
DBException - If there is no such field in this object

getLengthInt

public int getLengthInt(String fieldName)
                 throws DBException
Return the length of a field as an integer

Specified by:
getLengthInt in interface DataObjectMetaData
Parameters:
fieldName - The name of the field
Returns:
integer: The length of the field
Throws:
DBException - If there is no such field in this object

getPrecision

public int getPrecision(String fieldName)
                 throws DBException
Retrieve the precision of a particular field

Specified by:
getPrecision in interface DataObjectMetaData
Parameters:
fieldName - The name of the field
Returns:
integer for demcimal precision of the field
Throws:
DBException

getLookupObject

public String getLookupObject(String fieldName)
                       throws DBException
Get a field's lookup object - this is the name of another database object that can be used to look up valid values for this object. The lookup object for a field is set in the db objects setupFields method, and is used by the DBMaint servlet to provide automatic lookup links for fields.

Specified by:
getLookupObject in interface DataObjectMetaData
Parameters:
fieldName - Field name to check
Returns:
String specifying the className of the lookup object
Throws:
DBException - If the specified field does not exist.

getLookupField

public String getLookupField(String fieldName)
When you get a lookup object, to perform a complete mapping between the two, you need to know what field name in the remote object maps to this field.

Specified by:
getLookupField in interface DataObjectMetaData
Parameters:
fieldName - the name of the field to look up.
Returns:
java.lang.String or null if there is no lookup field
Throws:
IllegalArgumentException - if the field name does not exist

getName

public String getName()
Get the name of this object

Specified by:
getName in interface DataObjectMetaData
Returns:
String The database object name, or the table name if none has been assigned

getType

public String getType(String fieldName)
               throws DBException
Return the type of a field - this method returns the internal Expresso type

Specified by:
getType in interface DataObjectMetaData
Parameters:
fieldName - The name of the field
Returns:
String: The type of the field
Throws:
DBException - If there is no such field in this object

hasField

public boolean hasField(String fieldName)
This method will return a boolean true if the field is defined in the DBOBject, false otherwise. Creation date: (8/8/00 11:04:32 AM)

Specified by:
hasField in interface DataObjectMetaData
Parameters:
fieldName - java.lang.String
Returns:
boolean

isMultiValued

public boolean isMultiValued(String fieldName)
                      throws DBException
Method called to determine if a particular field is multi-valued, that is does it have a set of specific values and descriptions

Specified by:
isMultiValued in interface DataObjectMetaData
Parameters:
fieldName - Name of the field
Returns:
boolean True if the field is multi-valued, false if not
Throws:
DBException - If there is no such field

isReadOnly

public boolean isReadOnly(String fieldName)
                   throws DBException
Is a given field readOnly - these fields are not offered for entry when a form is produced by the generic database maintenance servlet

Specified by:
isReadOnly in interface DataObjectMetaData
Parameters:
fieldName - name of the field to check
Returns:
true of the field is "read only", false if it is not
Throws:
DBException - Ff there is no such field

isSecret

public boolean isSecret(String fieldName)
                 throws DBException
Is a given field 'secret' - these fields are not shown when a list is produced by the generic database maintenance servlet (DBMaint). This means that only users with update permission to the record can see the value of the specified field.

see #setSecret(String)

Specified by:
isSecret in interface DataObjectMetaData
Parameters:
fieldName - The name of the field to check
Returns:
True if the field is 'secret', false if it is not
Throws:
DBException - If there is no such field.

isVirtual

public boolean isVirtual(String fieldName)
                  throws DBException
Is a given field virtual? A virtual field is not stored in the target table for this object - it may be computed, or stored in another table.

Specified by:
isVirtual in interface DataObjectMetaData
Parameters:
fieldName - The name of the field to check see #addVirtualField(String, String, int, String)
Returns:
True of the field is virtual, false if it is not
Throws:
DBException - If there is no such field

setCheckZeroUpdate

public void setCheckZeroUpdate(boolean newFlag)
Turn on or off the facility to verify that when an update is made that at least one record got updated. If this flag is on, and no records get updated, the update() method throws an Exception. Note that for some databases, if the existing record is not changed (e.g. it was already identical to what was being updated) this counts "no update" (notably, mySQL does this).

Specified by:
setCheckZeroUpdate in interface DataObjectMetaData
Parameters:
newFlag - True to turn on checking, false to turn it off

checkZeroUpdate

public boolean checkZeroUpdate()
Retrieves whether or not checkZeroUpdate is enabled for this data object

Specified by:
checkZeroUpdate in interface DataObjectMetaData
Returns:
true if checkZeroUpdate() is enabled

setDescription

public void setDescription(String newDescription)
Sets the description for the data object join

Parameters:
newDescription - the description to set for the Join

setName

public void setName(String theName)
Sets the name for this joined data object metadata... in this case the definition name

Parameters:
theName - the name of the join [Usually =='s the definition]

getSchema

public String getSchema()
Retrieve the schema class name

Specified by:
getSchema in interface DataObjectMetaData
Returns:
the schema class of for the join

getTargetDbSchema

public String getTargetDbSchema()
Return the Schema Name of the current database object.

Returns:
String: Schema name of the target table of this database object
Throws:
DataException - upon error

author Yves Henri AMAIZO


getTargetDbCatalog

public String getTargetDbCatalog()
Return the Schema Name of the current database object.

Returns:
String: Schema name of the target table of this database object
Throws:
DataException - upon error

author Yves Henri AMAIZO


getTargetSQLTable

public String getTargetSQLTable(String dataContext)
                         throws DataException
Set the target table for this DBObject. Note that an object can span tables by the use of virtual fields, but that this table is the default table for the object.

Throws:
DBException - author Yves Henri AMAIZO
DataException

getFields

public String[] getFields()

This convenience method iterates through all the fields belonging to this DBObject returns an array of field names ( String ).

Specified by:
getFields in interface DataObjectMetaData
Returns:
String array of all field names in this object.

author Peter Pilgrim

See Also:
#getFieldList()

getDescription

public String getDescription(Locale l)
Retrieve the table description in a localized way. If l == null, the function uses the system locale to generate the value. If unable to locate the key in the message bundle, the key becomes the return value.

Specified by:
getDescription in interface DataObjectMetaData
Parameters:
l - the Locale to use for rendering the table description
Returns:
java.lang.String

setSelectDistinct

public void setSelectDistinct(boolean flag)
Specify that the DISTINCT keyword for unique rows must be specified right after the SELECT keyword

Parameters:
flag - true if DISTINCT supported right after SELECT, false (default) otherwise.

getAllAttributes

public Set getAllAttributes(String fieldName)
Retrieve all the attributes so you can iterate through them.

Specified by:
getAllAttributes in interface DataObjectMetaData
Parameters:
fieldName - the name of the field's attributes to retrieve
Returns:
Set of all attributes

isSelectDistinct

public boolean isSelectDistinct()
Retrieve whether or not the Join should be distinct or not

Returns:
true if the join should be distinct.

setForeignKey

public void setForeignKey(String shortName,
                          String foreignKey,
                          String shortName2,
                          String primaryKey,
                          int joinType)
                   throws DBException
Sets how the various dataobjects are connected, key-wise

Parameters:
shortName - java.lang.String the local short name
foreignKey - java.lang.String the local key
shortName2 - java.lang.String the foreign short name
primaryKey - java.lang.String the foreign key
joinType - the type of Join
Throws:
DBException - upon error

Modify by Yves Henri AMAIZO

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

getRelation

public JoinedDataObjectMetaData.Relation getRelation(String aliaslocal,
                                                     String aliasJoined)
Retrieve the relation bean for between two aliases

Parameters:
aliaslocal - the local alias
aliasJoined - the foreign alias
Returns:
JoinedDataObjectMetaData.Relation or null if the relation doesn't exist.

getAllRelations

public Map getAllRelations()
Retrieve a list of all relations

Returns:
java.util.Map

getSQLRelationList

public List getSQLRelationList()
Retrieve a list of precalculated relations for the where clauses.

Returns:
java.util.List

createNestedDataObjects

public HashMap createNestedDataObjects()
                                throws DataException
Creates a new copy of blank data objects for use in the main objects

Returns:
java.util.HashMap
Throws:
DataException - upon construction error

getPrimaryAlias

public String getPrimaryAlias()
Retrieve the short name of the primary data object. It is the primary alias that we set the keys for to form the join.

Returns:
java.lang.String
Throws:
IllegalStateException - if there are improperly described relations in the metadata

getObjectAndField

public final String[] getObjectAndField(String fieldName)
Utility method Retrieve the object name and the field name

Parameters:
fieldName - the [dataobject].field
Returns:
Array of Strings. String[0] = object alias String[1] = Object's Field Name

getAllDetails

protected Set getAllDetails()

getForeignKeyToPrimaryKeyMap

protected HashMap getForeignKeyToPrimaryKeyMap()

getMyDataObjects

protected HashMap getMyDataObjects()

getPermissions

public Map getPermissions()

setPermissions

public void setPermissions(Map newPermissions)

getPrimaryToForeignKeyMap

protected HashMap getPrimaryToForeignKeyMap()

getRelations

protected HashMap getRelations()

getSqlRelationList

protected List getSqlRelationList()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.