|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObject
DataObject for use with 1:1 joins between database objects. This class provides a multi-dbobject view of the underlying databases. It is similar to MultiDBObject in that it joins several JDBC-based dataobjects together. The biggest differences are:
Limitation: Although the definitions can list LEFT RIGHT and INNER joins, if you are chaining 3 or more tables, you can only LEFT, RIGHT or INNER join the very last relation or all the relations.
| Field Summary | |
static int |
INNER_JOIN
Static variables for join type |
static int |
LEFT_JOIN
Static field to indicate LEFT_JOIN type |
protected DBConnection |
localConnection
Local connection that we use if it's initialized, but if it's null we generate our own connection |
protected int |
maxRecords
Max Records to retrieve in a single query. 0 means no limit |
protected int |
offsetRecord
The number of records we must skip over before we start reading the ResultSet proper in a searchAndRetrieve. 0 means no limit |
static int |
RIGHT_JOIN
Static field to indicate RIGHT_JOIN type |
static int |
UNSPECIFIED_JOIN
|
| Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject |
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED |
| Fields inherited from interface com.jcorporate.expresso.core.dataobjects.Securable |
SYSTEM_ACCOUNT |
| Constructor Summary | |
JoinedDataObject()
Creates a new JoinedDataObject object, setting db context and UID from thread context (set by servlet filter) |
|
JoinedDataObject(JoinedDataObject definition)
Constructs a new joined data object to have the same definition as the parameter passed in. |
|
JoinedDataObject(JoinedDigesterBean definition,
String definitionName)
Constructor for runtime initialization of custom joined data object. |
|
JoinedDataObject(RequestContext request)
Creates a new JoinedDataObject object. |
|
JoinedDataObject(String xmlFileURL)
Uses the classloader to load the given xml file url as the definition of the JoinedDataObject |
|
| Method Summary | |
void |
add()
Adds records to all joined tables based upon the values input. |
void |
addOrUpdate(JDBCDataObject testObject)
Determine if a record with these fields exists already - if so, update. |
protected String |
buildFromClause()
Builds the 'FROM' clause without the 'from' part. |
protected String |
buildOrderByString(String sortKeys)
Create the 'ORDER BY' clause in the select statement. |
protected String |
buildSelectFieldsString()
Builds the part of the query that is for describing the fields/names to be selected |
protected String |
buildUpdateFieldString()
Builds the update field string portion setting question marks for all the field values to be formatted and parsed later in a Prepared statement |
protected String |
buildWhereClauseBuffer(boolean useAllFields,
FastStringBuffer myStatement)
Build and return a string consisting of an SQL 'where' clause using the current field values as criteria for the search. |
boolean |
checkAllowed(String requestedFunction)
See if the current user has permission to perform the permissions |
void |
checkField(String fieldName,
String fieldValue)
Retrieve a list of valid value object for this particular dbobject |
void |
clear()
Clears all currently loaded fields |
protected JoinedDataObjectMetaData |
constructMetadata()
Construction method so that you can create custom derived metadata classes derived from JoinedDataObjectMetaData for custom fields, etc. |
int |
count()
Retrieves the count of any particular join based upon the field values of the data object. |
void |
delete()
Deletes the join. |
boolean |
equals(Object otherObject)
Tests whether two joined DataObjects are equal |
boolean |
find()
Find the object. |
Object |
get(String fieldName)
Get the value object associated with the field specifieed. |
Map |
getAllAttributes()
Retrieves all the attributes for this data object |
DataObject[] |
getAllNested()
Retrieve an array of all nested data objects. |
Object |
getAttribute(String attributeName)
Retrieve the attribute for this particular dataobject. |
String |
getDataContext()
Returns the name of the currently set DataContext |
DataField |
getDataField(String fieldName)
Returns the object embedded within the field keyed by the fieldName parameter |
ArrayList |
getDataObjects()
This function is useful for low level work where you want to modify the underlying data objects in a behavior diffent that the default behavior of the JoinedDataObject. |
String |
getDefinitionName()
Retrieves the definition name in accordance with the |
protected String |
getDistinct(DBConnectionPool contextPool)
Add the DISTINCT keyword to the query if the join is supposed to be distinct. |
DataExecutorInterface |
getExecutor()
Use this function to acquire the Executor interface that is associated with this data object |
String |
getField(String fieldName)
Retrieve the field value as a String |
String |
getFieldFromNestedName(String fieldName)
Often times, field names for the external interface will be different from the of a nested field name in a data object. |
DataFieldMetaData |
getFieldMetaData(String fieldName)
Retrieve the Field MetaData for the specified field name |
org.apache.oro.text.regex.Pattern |
getGlobalMask()
Get the compiled regular expression for this base data object. |
JoinedDataObjectMetaData |
getJoinMetaData()
Type safe return to the metadata for internal use. |
String |
getKey()
Retrieve the key used for this join |
Locale |
getLocale()
Retrieve the Locale of the current object |
String |
getMappedDataContext()
Retrieve the mapped data context for this data object |
int |
getMaxRecords()
Retrieve the maximum number of records. |
DataObjectMetaData |
getMetaData()
Retrieve the database object's metadata. |
DataObject |
getNestedFromFieldName(String fieldName)
Retrieves a nested dataobject based upon the public field name that the DataObject publishes. |
int |
getOffsetRecord()
Gets the number of records that be skipped. |
DataQueryInterface |
getQueryInterface()
Retrieve the QueryInterface... currently not supported |
int |
getRequestingUid()
Retrieve the current UID definition name. |
String |
getStatus()
Retrieve the status of the data object |
List |
getValidValuesList(String fieldName)
Retrieve a list of valid value object for this particular dbobject |
int |
hashCode()
Returns a hash code value for the object. |
protected void |
init()
Initialize the dataobject. |
protected void |
initializeFromJoinedDigesterBean(JoinedDigesterBean digesterBean,
JoinedDataObjectMetaData metadata)
Initialization step based upon the digester bean either handed in, or loaded from XML data. |
protected void |
initializeXML(JoinedDataObjectMetaData metadata)
Initialize the metadata based upon XML. |
protected void |
initWithBean(JoinedDigesterBean digesterBean,
String definitionName)
Initializes the JoinedDataobject with a digester bean and a definition name This is useful for users creating joins on the fly |
void |
isAllowed(String requestedFunction)
Check if the function is allowed. |
boolean |
isGlobalMasked()
Return boolean if the data object has a mask set |
protected boolean |
isInitialized()
Function that checks if initialized. |
ArrayList |
searchAndRetrieveList()
Retrieve an unsorted array of DataObjects representing the results of the join fields |
ArrayList |
searchAndRetrieveList(String sortOrder)
Simple query method for querying dataobjects. |
protected String |
selectFieldString(JDBCDataObject oneObj,
String fieldName)
Build an appropriate String for use in the select part of an SQL statement |
void |
set(String fieldName,
Object o)
Sets the name of the field |
void |
setAttribute(String attributeName,
Object attributeValue)
Set an attribute. |
void |
setCaseSensitiveQuery(boolean isCaseSensitiveQuery)
This tells the buildWhereClause to either respect case (true) or ignore case (false). |
void |
setConnection(DBConnection newConnection)
Set a specific DB connection for use with this JoinedDataObject. |
void |
setConnection(DBConnection newConnection,
String setupTablesContext)
Set a specific DB connection for use with this JoinedDataObject. |
void |
setCustomWhereClause(String customWhereClause,
boolean append)
Set a custom WHERE clause |
void |
setDataContext(String newContext)
Sets the data context. |
void |
setDataField(String fieldName,
DataField o)
Sets the field data for the named field. |
void |
setDefinitionName(String definitionName)
Use this method to set the key to the definition name for the Defineable database object. |
void |
setFieldsWithDefaults()
Sets the fields of this object with the default values defined in the metadata. The behavior of this function is such that it only populates fields if there is no current value set. This is the same behavior that existed previously in DefaultAutoElement. |
void |
setGlobalMask(org.apache.oro.text.regex.Pattern newMask)
Set a regular expression "mask" for this base data object that specifies it's valid values. |
void |
setLocale(Locale newLocale)
SEt the locale of the object |
void |
setMaxRecords(int newMax)
Set the maximum number of records to receive |
void |
setOffsetRecord(int newOffset)
Specifies the number of records that should be skipped over before any data from the ResultSet is retrieved in any subsequent
searchAndRetrieve() call. |
void |
setRequestingUid(int newUid)
Sets the UID for the operations.... also sets the UID for all contained elements. |
void |
setStatus(String newValue)
Sets the status of the joined data object |
void |
update()
Update the current join to the database. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int UNSPECIFIED_JOIN
public static final int INNER_JOIN
public static final int RIGHT_JOIN
public static final int LEFT_JOIN
protected transient DBConnection localConnection
protected int offsetRecord
ResultSet proper in a searchAndRetrieve. 0 means no limit
protected int maxRecords
| Constructor Detail |
public JoinedDataObject()
public JoinedDataObject(RequestContext request)
request - based on the controller request object as most likely implemented.
public JoinedDataObject(String xmlFileURL)
throws DataException
xmlFileURL - the name of the XML file URL
DataException - upon error
public JoinedDataObject(JoinedDataObject definition)
throws DataException
definition - the definition to duplicate
DataException - upon initialization error
public JoinedDataObject(JoinedDigesterBean definition,
String definitionName)
throws DataException
Note:You may get strange errors if the definition already exists, it will appear that this constructor didn't 'take' and you'll get a different definition.
definition - the definition bean to utilizedefinitionName - the name of the definition
DataException - upon error| Method Detail |
public String getDefinitionName()
getDefinitionName in interface Defineable
protected void init()
throws DataException
DataException - upon errorprotected JoinedDataObjectMetaData constructMetadata()
protected void initWithBean(JoinedDigesterBean digesterBean,
String definitionName)
throws DataException
digesterBean - Filled out metadata BeandefinitionName - the name of the definition
DataException - upon error
protected void initializeFromJoinedDigesterBean(JoinedDigesterBean digesterBean,
JoinedDataObjectMetaData metadata)
throws DataException
digesterBean - the digester bean with populated datametadata - the meatadata to load the digester bean into
DataException - upon error
protected void initializeXML(JoinedDataObjectMetaData metadata)
throws DataException
metadata - the metadata object to fill out with the XML data
DataExceptionpublic Map getAllAttributes()
getAllAttributes in interface DataObject
public void setAttribute(String attributeName,
Object attributeValue)
setAttribute in interface DataObjectattributeName - The name of the attribute being definedattributeValue - The object to store under this attribute namepublic Object getAttribute(String attributeName)
getAttribute in interface DataObjectattributeName - the name of the attribute to get
public void setCaseSensitiveQuery(boolean isCaseSensitiveQuery)
isCaseSensitiveQuery - boolean
public void setCustomWhereClause(String customWhereClause,
boolean append)
customWhereClause - the custom where clause to use.append - if true the supplied WHERE clause will be appended to the one
generated, else it will replace itpublic void setDataContext(String newContext)
setDataContext in interface ContextNestednewContext - A valid data context name.public String getDataContext()
getDataContext in interface ContextNested
public void setDataField(String fieldName,
DataField o)
throws DataException
fieldName - The data field to set. It is defined by [shortname].[fieldname]o - The Object to set it by.
DataException
public DataField getDataField(String fieldName)
throws DBException
getDataField in interface DataObjectfieldName - The name of the field to get
DBException - upon errorpublic DataExecutorInterface getExecutor()
getExecutor in interface DataObjectpublic DataFieldMetaData getFieldMetaData(String fieldName)
getFieldMetaData in interface DataObjectfieldName - The name of the field in a 'alias.fieldname' format.
public void set(String fieldName,
Object o)
throws DataException
set in interface DataObjectfieldName - the name of the field to seto - the object to set.
IllegalArgumentException - if filedName is improperly formatted
DataException
public Object get(String fieldName)
throws DataException
get in interface DataObjectfieldName - The field name in a [alias].[fieldname] format
DataException - upon errorpublic String getKey()
getKey in interface Cacheablepublic void setLocale(Locale newLocale)
setLocale in interface DataObjectnewLocale - the new localepublic Locale getLocale()
getLocale in interface DataObjectpublic String getMappedDataContext()
getMappedDataContext in interface DataObject
public void setMaxRecords(int newMax)
throws DBException
setMaxRecords in interface DataObjectnewMax - the new maximum number of records to retrieve
DBException - If the max number is less than 0public int getMaxRecords()
getMaxRecords in interface DataObjectpublic DataObjectMetaData getMetaData()
For implementers of this interface: It is best to store the metadata somewhere rather than recreating it each and every time. For low-memory requirements, a WeakHashMap is recommended
getMetaData in interface DataObjectpublic JoinedDataObjectMetaData getJoinMetaData()
public ArrayList getDataObjects()
public void setOffsetRecord(int newOffset)
throws DBException
ResultSet is retrieved in any subsequent
searchAndRetrieve() call. Records will be skipped over (in the
specified sort order) until the record counts is equal to or greater
than the offset record. Specifying zero indicates that no records
should be skipped over and the ResultSet immediately from
the start.
setOffsetRecord in interface DataObjectnewOffset - The maximum number of records to retrieve.
DBException - If the max number is less than 0public int getOffsetRecord()
ResultSet.
getOffsetRecord in interface DataObjectsetOffsetRecord(int)public DataQueryInterface getQueryInterface()
getQueryInterface in interface DataObjectpublic String getStatus()
getStatus in interface DataObjectpublic void setStatus(String newValue)
setStatus in interface DataObjectnewValue - see BaseDataObject for possible values
public List getValidValuesList(String fieldName)
throws DBException
getValidValuesList in interface DataObjectfieldName - name of the field to retrieve the list for. Should be
of the format [shortname].[fieldname]
DBException - upon error
public void add()
throws DBException
add in interface DataObjectDBException - upon database access error
public void checkField(String fieldName,
String fieldValue)
throws DBException
checkField in interface DataObjectfieldName - name of the field to retrieve the list for.fieldValue - the String value of the field
DBException - upon error
IllegalArgumentException - if unable to parse the fieldName
public boolean checkAllowed(String requestedFunction)
throws DBException
requestedFunction - (A)dd, (U)pdate, (D)elete, (S)earch
DBExceptionisAllowed(java.lang.String)
public void clear()
throws DBException
clear in interface DataObjectDBExceptionprotected String getDistinct(DBConnectionPool contextPool)
contextPool - the connection pool for the current context
public int count()
throws DBException
count in interface DataObjectDBException - upon data access error
DataException - for metadata access error
public void delete()
throws DBException
delete in interface DataObjectDBException - upon errorpublic boolean equals(Object otherObject)
equals in interface DataObjectotherObject - the object to compare against
public int hashCode()
public boolean find()
throws DBException
find in interface DataObjectDBException - upon database access errorDataObject.find()
public ArrayList searchAndRetrieveList(String sortOrder)
throws DBException
searchAndRetrieveList in interface DataObjectsortOrder - A pipe delimited set of fields to sort the resultset
with.
DBException - upon database access error
Modify by Yves Henri AMAIZO
public ArrayList searchAndRetrieveList()
throws DBException
searchAndRetrieveList in interface DataObjectDBException - upon data access error.
protected String selectFieldString(JDBCDataObject oneObj,
String fieldName)
throws DBException
oneObj - Database object containing the fieldfieldName - The name of the field to be handled
DBException - upon data access error
Modify by Yves Henri AMAIZO
public void update()
throws DBException
update in interface DataObjectDBException - upon database access error
public void addOrUpdate(JDBCDataObject testObject)
throws DBException
testObject - the JDBCObject to add or update.
DBException
public void setDefinitionName(String definitionName)
throws DataException
setDefinitionName in interface DefineabledefinitionName - java.lang.String, the actual definition of the
dataobject.
DataException - if the DataObject is unable to initialize itself
with the given definition name.public int getRequestingUid()
getRequestingUid in interface Securablepublic void setRequestingUid(int newUid)
setRequestingUid in interface SecurablenewUid - the user id for the operation.
public void isAllowed(String requestedFunction)
throws SecurityException,
DBException
isAllowed in interface SecurablerequestedFunction - the function name to check
SecurityException - if the method is not allowed.
DBExceptionprotected boolean isInitialized()
protected String buildFromClause()
throws DataException
DataException - upon construction error
Modify by Yves Henri AMAIZO
protected String buildSelectFieldsString()
throws DBException
DBException - if there's an error creating the string.
Modify by Yves Henri AMAIZO
protected String buildUpdateFieldString()
throws DataException
DataException - upon error
Modify by Yves Henri AMAIZO
protected String buildOrderByString(String sortKeys)
throws DBException
sortKeys - pipe delimited field names in the format [alias].[fieldName]
DBException - Modify by Yves Henri AMAIZO
protected String buildWhereClauseBuffer(boolean useAllFields,
FastStringBuffer myStatement)
throws DBException
useAllFields - True if all fields are to be used, false for only key fieldsmyStatement - the preallocated buffer to append to
DBException - upon errorpublic DataObject getNestedFromFieldName(String fieldName)
The actual usage of the naming convention will differ from the, thus
you'll need to use getMetaData().getFieldList() to get the names of the
fields of a Nestable object to get a valid field Name
getNestedFromFieldName in interface NestableDataObjectfieldName - the full field name to get the nested data object.
IllegalArgumentException - if the field name does not map to any
DataObjectpublic DataObject[] getAllNested()
getAllNested in interface NestableDataObjectpublic String getFieldFromNestedName(String fieldName)
getNestedFromFieldName()
getFieldFromNestedName in interface NestableDataObjectfieldName - The external name of the field
IllegalArgumentException - if the given field name cannot map
to a field.
public String getField(String fieldName)
throws DBException
getField in interface DataObjectfieldName - the name of the field to retrieve
DBException - upon error
IllegalArgumentException - if fieldname is invalid
public void setConnection(DBConnection newConnection)
throws DBException
newConnection - The new DBConnection object to be used by this DB Object
DBException
public void setConnection(DBConnection newConnection,
String setupTablesContext)
throws DBException
The difference between this and setConnection(DBConnection) is that this is used for using otherDB capabilities within a transaction. So you use a dbconnection from your other pool, but the setup tables are in a different context
newConnection - The new DBConnection object to be used by this DB ObjectsetupTablesContext - the data context that is used for the expresso setup tables.
DBExceptionsetConnection(DBConnection)public void setGlobalMask(org.apache.oro.text.regex.Pattern newMask)
setGlobalMask in interface DataObjectnewMask - The compiled regular expression maskpublic org.apache.oro.text.regex.Pattern getGlobalMask()
getGlobalMask in interface DataObjectpublic boolean isGlobalMasked()
isGlobalMasked in interface DataObject
public void setFieldsWithDefaults()
throws DataException
setFieldsWithDefaults in interface DataObjectDataException - upon setField error.
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||