Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jcorporate.expresso.core.dataobjects.jdbc
Class JoinedDataObject  view JoinedDataObject download JoinedDataObject.java

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObject
All Implemented Interfaces:
com.jcorporate.expresso.core.cache.Cacheable, com.jcorporate.expresso.core.dataobjects.ContextNested, com.jcorporate.expresso.core.dataobjects.DataObject, com.jcorporate.expresso.core.dataobjects.Defineable, com.jcorporate.expresso.core.dataobjects.NestableDataObject, com.jcorporate.expresso.core.dataobjects.Securable, java.io.Serializable

public class JoinedDataObject
extends java.lang.Object
implements com.jcorporate.expresso.core.dataobjects.DataObject, com.jcorporate.expresso.core.dataobjects.Defineable, com.jcorporate.expresso.core.dataobjects.Securable, com.jcorporate.expresso.core.dataobjects.NestableDataObject

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
private  boolean appendCustomWhere
          Flag to indicate if the custom WHERE clause should be appended to the generated WHERE clause.
private  java.util.HashMap attributes
          Attributes of this DB Object
private  boolean caseSensitiveQuery
          This flag tells the buildWhereClause method(s) to either be case sensitive (normal queries) or to be case insensitive.
private  java.lang.String customWhereClause
          If we are using a custom where clause for this query, it's stored here.
private static java.util.Map definitions
          A list of definitions
static int INNER_JOIN
          Static variables for join type
static int LEFT_JOIN
          Static field to indicate LEFT_JOIN type
protected  com.jcorporate.expresso.core.db.DBConnection localConnection
          Local connection that we use if it's initialized, but if it's null we generate our own connection
private static org.apache.log4j.Logger log
          The logger instance.
private static org.apache.log4j.Logger LOG
           
protected  int maxRecords
          Max Records to retrieve in a single query.
private  java.util.HashMap myDataObjects
          Hash that contains the DB objects that relate to make up this query, indexed by the "short" name provided by the user.
private  java.util.Map myFields
          A list of my current fields.
private  java.util.Locale myLocale
          My Locale
protected  int offsetRecord
          The number of records we must skip over before we start reading the ResultSet proper in a searchAndRetrieve.
private  java.util.ArrayList recordSet
          The vector of MultiDB objects retrieved by the last searchAndRetrieve method
static int RIGHT_JOIN
          Static field to indicate RIGHT_JOIN type
private static JDBCUtil sJdbcUtil
          Utility class that currently provides help for getFieldDate() function.
private static java.lang.String thisClass
           
private  java.lang.String thisDefinitionName
          Pre-calculation that is performed upon construction to speed access to field definitions.
private  int uid
          Security UID of this data object
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, java.lang.String definitionName)
          Constructor for runtime initialization of custom joined data object.
JoinedDataObject(com.jcorporate.expresso.core.dbobj.RequestContext request)
          Creates a new JoinedDataObject object.
JoinedDataObject(java.lang.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  java.lang.String buildFromClause()
          Builds the 'FROM' clause without the 'from' part.
private  java.lang.String buildJoin(java.lang.String leftShortName, java.lang.String leftColumn, java.lang.String rightShortName, java.lang.String rightColumn, int joinType)
          Builds a 'FROM' clause using ANSI 'JOIN' syntax.
protected  java.lang.String buildOrderByString(java.lang.String sortKeys)
          Create the 'ORDER BY' clause in the select statement.
protected  java.lang.String buildSelectFieldsString()
          Builds the part of the query that is for describing the fields/names to be selected
protected  java.lang.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  java.lang.String buildWhereClauseBuffer(boolean useAllFields, com.jcorporate.expresso.kernel.util.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(java.lang.String requestedFunction)
          See if the current user has permission to perform the permissions
 void checkField(java.lang.String fieldName, java.lang.String fieldValue)
          Retrieve a list of valid value object for this particular dbobject
private  void checkInitialized()
          One liner function that allows you to quickly enforce proper initialization or the system throws an exception.
 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(java.lang.Object otherObject)
          Tests whether two joined DataObjects are equal
 boolean find()
          Find the object.
private  void formatCustomWhereClause(com.jcorporate.expresso.kernel.util.FastStringBuffer myStatement)
          Replaces alias names in the customWhereClause with their correct table names
 java.lang.Object get(java.lang.String fieldName)
          Get the value object associated with the field specifieed.
 java.util.Map getAllAttributes()
          Retrieves all the attributes for this data object
 com.jcorporate.expresso.core.dataobjects.DataObject[] getAllNested()
          Retrieve an array of all nested data objects.
 java.lang.Object getAttribute(java.lang.String attributeName)
          Retrieve the attribute for this particular dataobject.
private  JDBCDataObject getByShortName(java.lang.String shortName)
          Retrieve the JDBCDataObject as defined by the 'short name'
 java.lang.String getDataContext()
          Returns the name of the currently set DataContext
 com.jcorporate.expresso.core.dataobjects.DataField getDataField(java.lang.String fieldName)
          Returns the object embedded within the field keyed by the fieldName parameter
 java.util.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.
 java.lang.String getDefinitionName()
          Retrieves the definition name in accordance with the
protected  java.lang.String getDistinct(com.jcorporate.expresso.core.db.DBConnectionPool contextPool)
          Add the DISTINCT keyword to the query if the join is supposed to be distinct.
 com.jcorporate.expresso.core.dataobjects.DataExecutorInterface getExecutor()
          Use this function to acquire the Executor interface that is associated with this data object
 java.lang.String getField(java.lang.String fieldName)
          Retrieve the field value as a String
 java.lang.String getFieldFromNestedName(java.lang.String fieldName)
          Often times, field names for the external interface will be different from the of a nested field name in a data object.
 com.jcorporate.expresso.core.dataobjects.DataFieldMetaData getFieldMetaData(java.lang.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.
 java.lang.String getKey()
          Retrieve the key used for this join
 java.util.Locale getLocale()
          Retrieve the Locale of the current object
 java.lang.String getMappedDataContext()
          Retrieve the mapped data context for this data object
 int getMaxRecords()
          Retrieve the maximum number of records.
 com.jcorporate.expresso.core.dataobjects.DataObjectMetaData getMetaData()
          Retrieve the database object's metadata.
 com.jcorporate.expresso.core.dataobjects.DataObject getNestedFromFieldName(java.lang.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.
 com.jcorporate.expresso.core.dataobjects.DataQueryInterface getQueryInterface()
          Retrieve the QueryInterface...
 int getRequestingUid()
          Retrieve the current UID definition name.
 java.lang.String getStatus()
          Retrieve the status of the data object
 java.util.List getValidValuesList(java.lang.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, java.lang.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(java.lang.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.
 java.util.ArrayList searchAndRetrieveList()
          Retrieve an unsorted array of DataObjects representing the results of the join fields
 java.util.ArrayList searchAndRetrieveList(java.lang.String sortOrder)
          Simple query method for querying dataobjects.
protected  java.lang.String selectFieldString(JDBCDataObject oneObj, java.lang.String fieldName)
          Build an appropriate String for use in the select part of an SQL statement
 void set(java.lang.String fieldName, java.lang.Object o)
          Sets the name of the field
 void setAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
          Set an attribute.
 void setCaseSensitiveQuery(boolean isCaseSensitiveQuery)
          This tells the buildWhereClause to either respect case (true) or ignore case (false).
 void setConnection(com.jcorporate.expresso.core.db.DBConnection newConnection)
          Set a specific DB connection for use with this JoinedDataObject.
 void setConnection(com.jcorporate.expresso.core.db.DBConnection newConnection, java.lang.String setupTablesContext)
          

Set a specific DB connection for use with this JoinedDataObject.

 void setCustomWhereClause(java.lang.String customWhereClause, boolean append)
          Set a custom WHERE clause
 void setDataContext(java.lang.String newContext)
          Sets the data context.
 void setDataField(java.lang.String fieldName, com.jcorporate.expresso.core.dataobjects.DataField o)
          Sets the field data for the named field.
 void setDefinitionName(java.lang.String definitionName)
          Use this method to set the key to the definition name for the Defineable database object.
 void setFieldsWithDefaults()
          null
 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(java.util.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....
 void setStatus(java.lang.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

thisClass

private static final transient java.lang.String thisClass

LOG

private static final org.apache.log4j.Logger LOG

UNSPECIFIED_JOIN

public static final int UNSPECIFIED_JOIN
See Also:
Constant Field Values

INNER_JOIN

public static final int INNER_JOIN
Static variables for join type

See Also:
Constant Field Values

RIGHT_JOIN

public static final int RIGHT_JOIN
Static field to indicate RIGHT_JOIN type

See Also:
Constant Field Values

LEFT_JOIN

public static final int LEFT_JOIN
Static field to indicate LEFT_JOIN type

See Also:
Constant Field Values

log

private static final transient org.apache.log4j.Logger log
The logger instance.


localConnection

protected transient com.jcorporate.expresso.core.db.DBConnection localConnection
Local connection that we use if it's initialized, but if it's null we generate our own connection


offsetRecord

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


maxRecords

protected int maxRecords
Max Records to retrieve in a single query. 0 means no limit


attributes

private java.util.HashMap attributes
Attributes of this DB Object


myDataObjects

private java.util.HashMap myDataObjects
Hash that contains the DB objects that relate to make up this query, indexed by the "short" name provided by the user.


recordSet

private java.util.ArrayList recordSet
The vector of MultiDB objects retrieved by the last searchAndRetrieve method


myLocale

private java.util.Locale myLocale
My Locale


customWhereClause

private java.lang.String customWhereClause
If we are using a custom where clause for this query, it's stored here. If null, then build the where clause


appendCustomWhere

private boolean appendCustomWhere
Flag to indicate if the custom WHERE clause should be appended to the generated WHERE clause. If false, customWhereClause will be used instead of generating one


caseSensitiveQuery

private boolean caseSensitiveQuery
This flag tells the buildWhereClause method(s) to either be case sensitive (normal queries) or to be case insensitive. The case insensitive query is useful when you want to do a search and retreive and want case insensitive matching.


thisDefinitionName

private java.lang.String thisDefinitionName
Pre-calculation that is performed upon construction to speed access to field definitions.


definitions

private static transient java.util.Map definitions
A list of definitions


uid

private int uid
Security UID of this data object


sJdbcUtil

private static final transient JDBCUtil sJdbcUtil
Utility class that currently provides help for getFieldDate() function.


myFields

private java.util.Map myFields
A list of my current fields. It is keyed by localAlias.FieldName. This one ONLY contains the DataFields that are mapped to both objects. [Ie part of the join.] If you set one field, you'll that way, set both.

Constructor Detail

JoinedDataObject

public JoinedDataObject()
Creates a new JoinedDataObject object, setting db context and UID from thread context (set by servlet filter)


JoinedDataObject

public JoinedDataObject(com.jcorporate.expresso.core.dbobj.RequestContext request)
Creates a new JoinedDataObject object.


JoinedDataObject

public JoinedDataObject(java.lang.String xmlFileURL)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Uses the classloader to load the given xml file url as the definition of the JoinedDataObject


JoinedDataObject

public JoinedDataObject(JoinedDataObject definition)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Constructs a new joined data object to have the same definition as the parameter passed in.


JoinedDataObject

public JoinedDataObject(JoinedDigesterBean definition,
                        java.lang.String definitionName)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Constructor for runtime initialization of custom joined data object. The definition MUST be unique across the application lifetime, and this constructor has to be only called once. The definition will exist for the lifetime of the object.

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.

Method Detail

getDefinitionName

public java.lang.String getDefinitionName()
Retrieves the definition name in accordance with the

Specified by:
getDefinitionName in interface com.jcorporate.expresso.core.dataobjects.Defineable

init

protected void init()
             throws com.jcorporate.expresso.core.dataobjects.DataException
Initialize the dataobject.


constructMetadata

protected JoinedDataObjectMetaData constructMetadata()
Construction method so that you can create custom derived metadata classes derived from JoinedDataObjectMetaData for custom fields, etc.


initWithBean

protected void initWithBean(JoinedDigesterBean digesterBean,
                            java.lang.String definitionName)
                     throws com.jcorporate.expresso.core.dataobjects.DataException
Initializes the JoinedDataobject with a digester bean and a definition name This is useful for users creating joins on the fly


initializeFromJoinedDigesterBean

protected void initializeFromJoinedDigesterBean(JoinedDigesterBean digesterBean,
                                                JoinedDataObjectMetaData metadata)
                                         throws com.jcorporate.expresso.core.dataobjects.DataException
Initialization step based upon the digester bean either handed in, or loaded from XML data.


initializeXML

protected void initializeXML(JoinedDataObjectMetaData metadata)
                      throws com.jcorporate.expresso.core.dataobjects.DataException
Initialize the metadata based upon XML.


getAllAttributes

public java.util.Map getAllAttributes()
Retrieves all the attributes for this data object

Specified by:
getAllAttributes in interface com.jcorporate.expresso.core.dataobjects.DataObject

setAttribute

public void setAttribute(java.lang.String attributeName,
                         java.lang.Object attributeValue)
Set an attribute. Attributes are temporary (e.g. not stored in the DBMS) values associated with this particular DB object instance.

Specified by:
setAttribute in interface com.jcorporate.expresso.core.dataobjects.DataObject

getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName)
Retrieve the attribute for this particular dataobject.

Specified by:
getAttribute in interface com.jcorporate.expresso.core.dataobjects.DataObject

setCaseSensitiveQuery

public void setCaseSensitiveQuery(boolean isCaseSensitiveQuery)
This tells the buildWhereClause to either respect case (true) or ignore case (false). You can call this method before doing a search and retreive if you want to match without worrying about case. For example if you where to call this method with isCaseSensitiveQuery = FALSE then this comparison would match in the search: vendor_name actual value = "My Name" query value = "my name" This would match in a search and retrieve.


setCustomWhereClause

public void setCustomWhereClause(java.lang.String customWhereClause,
                                 boolean append)
Set a custom WHERE clause


setDataContext

public void setDataContext(java.lang.String newContext)
Sets the data context. Also sets the data context for all the nested data obejcts

Specified by:
setDataContext in interface com.jcorporate.expresso.core.dataobjects.ContextNested

getDataContext

public java.lang.String getDataContext()
Returns the name of the currently set DataContext

Specified by:
getDataContext in interface com.jcorporate.expresso.core.dataobjects.ContextNested

setDataField

public void setDataField(java.lang.String fieldName,
                         com.jcorporate.expresso.core.dataobjects.DataField o)
                  throws com.jcorporate.expresso.core.dataobjects.DataException
Sets the field data for the named field. This particular implementation assumes that the proper data fields have already been created, and we're only resetting the appropriate types.


getDataField

public com.jcorporate.expresso.core.dataobjects.DataField getDataField(java.lang.String fieldName)
                                                                throws com.jcorporate.expresso.core.db.DBException
Returns the object embedded within the field keyed by the fieldName parameter

Specified by:
getDataField in interface com.jcorporate.expresso.core.dataobjects.DataObject

getExecutor

public com.jcorporate.expresso.core.dataobjects.DataExecutorInterface getExecutor()
Use this function to acquire the Executor interface that is associated with this data object

Specified by:
getExecutor in interface com.jcorporate.expresso.core.dataobjects.DataObject

getFieldMetaData

public com.jcorporate.expresso.core.dataobjects.DataFieldMetaData getFieldMetaData(java.lang.String fieldName)
Retrieve the Field MetaData for the specified field name

Specified by:
getFieldMetaData in interface com.jcorporate.expresso.core.dataobjects.DataObject

set

public void set(java.lang.String fieldName,
                java.lang.Object o)
         throws com.jcorporate.expresso.core.dataobjects.DataException
Sets the name of the field

Specified by:
set in interface com.jcorporate.expresso.core.dataobjects.DataObject

get

public java.lang.Object get(java.lang.String fieldName)
                     throws com.jcorporate.expresso.core.dataobjects.DataException
Get the value object associated with the field specifieed.

Specified by:
get in interface com.jcorporate.expresso.core.dataobjects.DataObject

getKey

public java.lang.String getKey()
Retrieve the key used for this join

Specified by:
getKey in interface com.jcorporate.expresso.core.cache.Cacheable

setLocale

public void setLocale(java.util.Locale newLocale)
SEt the locale of the object

Specified by:
setLocale in interface com.jcorporate.expresso.core.dataobjects.DataObject

getLocale

public java.util.Locale getLocale()
Retrieve the Locale of the current object

Specified by:
getLocale in interface com.jcorporate.expresso.core.dataobjects.DataObject

getMappedDataContext

public java.lang.String getMappedDataContext()
Retrieve the mapped data context for this data object

Specified by:
getMappedDataContext in interface com.jcorporate.expresso.core.dataobjects.DataObject

setMaxRecords

public void setMaxRecords(int newMax)
                   throws com.jcorporate.expresso.core.db.DBException
Set the maximum number of records to receive

Specified by:
setMaxRecords in interface com.jcorporate.expresso.core.dataobjects.DataObject

getMaxRecords

public int getMaxRecords()
Retrieve the maximum number of records.

Specified by:
getMaxRecords in interface com.jcorporate.expresso.core.dataobjects.DataObject

getMetaData

public com.jcorporate.expresso.core.dataobjects.DataObjectMetaData getMetaData()
Retrieve the database object's metadata. Metadata is a description of the database object, so it contains static information such as as description, field names, field types. Etc.

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

Specified by:
getMetaData in interface com.jcorporate.expresso.core.dataobjects.DataObject

getJoinMetaData

public JoinedDataObjectMetaData getJoinMetaData()
Type safe return to the metadata for internal use.


getDataObjects

public java.util.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. Because of the nature of the object, if you modify the underlying dataobjects in any way, it is recommended that you discard the join that created them since integrity between the dataobjects might be compromised.


setOffsetRecord

public void setOffsetRecord(int newOffset)
                     throws com.jcorporate.expresso.core.db.DBException
Specifies the number of records that should be skipped over before any data from the 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.

Specified by:
setOffsetRecord in interface com.jcorporate.expresso.core.dataobjects.DataObject

getOffsetRecord

public int getOffsetRecord()
Gets the number of records that be skipped. The offset records. A DB Object can be told to skip a certain number of records, before reading records from the ResultSet.

Specified by:
getOffsetRecord in interface com.jcorporate.expresso.core.dataobjects.DataObject

getQueryInterface

public com.jcorporate.expresso.core.dataobjects.DataQueryInterface getQueryInterface()
Retrieve the QueryInterface... currently not supported

Specified by:
getQueryInterface in interface com.jcorporate.expresso.core.dataobjects.DataObject

getStatus

public java.lang.String getStatus()
Retrieve the status of the data object

Specified by:
getStatus in interface com.jcorporate.expresso.core.dataobjects.DataObject

setStatus

public void setStatus(java.lang.String newValue)
Sets the status of the joined data object

Specified by:
setStatus in interface com.jcorporate.expresso.core.dataobjects.DataObject

getValidValuesList

public java.util.List getValidValuesList(java.lang.String fieldName)
                                  throws com.jcorporate.expresso.core.db.DBException
Retrieve a list of valid value object for this particular dbobject

Specified by:
getValidValuesList in interface com.jcorporate.expresso.core.dataobjects.DataObject

add

public void add()
         throws com.jcorporate.expresso.core.db.DBException
Adds records to all joined tables based upon the values input. If another record exists [due to relations], the existing record, is skipped.

Specified by:
add in interface com.jcorporate.expresso.core.dataobjects.DataObject

checkField

public void checkField(java.lang.String fieldName,
                       java.lang.String fieldValue)
                throws com.jcorporate.expresso.core.db.DBException
Retrieve a list of valid value object for this particular dbobject

Specified by:
checkField in interface com.jcorporate.expresso.core.dataobjects.DataObject

checkAllowed

public boolean checkAllowed(java.lang.String requestedFunction)
                     throws com.jcorporate.expresso.core.db.DBException
See if the current user has permission to perform the permissions


clear

public void clear()
           throws com.jcorporate.expresso.core.db.DBException
Clears all currently loaded fields

Specified by:
clear in interface com.jcorporate.expresso.core.dataobjects.DataObject

getDistinct

protected java.lang.String getDistinct(com.jcorporate.expresso.core.db.DBConnectionPool contextPool)
Add the DISTINCT keyword to the query if the join is supposed to be distinct.


count

public int count()
          throws com.jcorporate.expresso.core.db.DBException
Retrieves the count of any particular join based upon the field values of the data object.

Specified by:
count in interface com.jcorporate.expresso.core.dataobjects.DataObject

delete

public void delete()
            throws com.jcorporate.expresso.core.db.DBException
Deletes the join. Use with extreme care since you could wipe out referential integrity with other objects.

Specified by:
delete in interface com.jcorporate.expresso.core.dataobjects.DataObject

equals

public boolean equals(java.lang.Object otherObject)
Tests whether two joined DataObjects are equal

Specified by:
equals in interface com.jcorporate.expresso.core.dataobjects.DataObject

hashCode

public int hashCode()
Returns a hash code value for the object.


find

public boolean find()
             throws com.jcorporate.expresso.core.db.DBException
Find the object.

Specified by:
find in interface com.jcorporate.expresso.core.dataobjects.DataObject

searchAndRetrieveList

public java.util.ArrayList searchAndRetrieveList(java.lang.String sortOrder)
                                          throws com.jcorporate.expresso.core.db.DBException
Simple query method for querying dataobjects. Retrieve a list of all objects matching the given criteria.

Specified by:
searchAndRetrieveList in interface com.jcorporate.expresso.core.dataobjects.DataObject
Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

searchAndRetrieveList

public java.util.ArrayList searchAndRetrieveList()
                                          throws com.jcorporate.expresso.core.db.DBException
Retrieve an unsorted array of DataObjects representing the results of the join fields

Specified by:
searchAndRetrieveList in interface com.jcorporate.expresso.core.dataobjects.DataObject

selectFieldString

protected java.lang.String selectFieldString(JDBCDataObject oneObj,
                                             java.lang.String fieldName)
                                      throws com.jcorporate.expresso.core.db.DBException
Build an appropriate String for use in the select part of an SQL statement

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

update

public void update()
            throws com.jcorporate.expresso.core.db.DBException
Update the current join to the database. All this does is search for exiting objects and if it finds it, updates, if not, it

Specified by:
update in interface com.jcorporate.expresso.core.dataobjects.DataObject

addOrUpdate

public void addOrUpdate(JDBCDataObject testObject)
                 throws com.jcorporate.expresso.core.db.DBException
Determine if a record with these fields exists already - if so, update. If not, add a new record.


getByShortName

private JDBCDataObject getByShortName(java.lang.String shortName)
                               throws com.jcorporate.expresso.core.dataobjects.DataException
Retrieve the JDBCDataObject as defined by the 'short name'


buildJoin

private java.lang.String buildJoin(java.lang.String leftShortName,
                                   java.lang.String leftColumn,
                                   java.lang.String rightShortName,
                                   java.lang.String rightColumn,
                                   int joinType)
                            throws com.jcorporate.expresso.core.db.DBException
Builds a 'FROM' clause using ANSI 'JOIN' syntax.

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

setDefinitionName

public void setDefinitionName(java.lang.String definitionName)
                       throws com.jcorporate.expresso.core.dataobjects.DataException
Use this method to set the key to the definition name for the Defineable database object. The actual meaning of the definitionName may be different. For example, AutoDBObject's definition name is the database table name. JoinedDataObject's definition name is the classpath URL location to the definition XML file.

Specified by:
setDefinitionName in interface com.jcorporate.expresso.core.dataobjects.Defineable

getRequestingUid

public int getRequestingUid()
Retrieve the current UID definition name.

Specified by:
getRequestingUid in interface com.jcorporate.expresso.core.dataobjects.Securable

setRequestingUid

public void setRequestingUid(int newUid)
Sets the UID for the operations.... also sets the UID for all contained elements.

Specified by:
setRequestingUid in interface com.jcorporate.expresso.core.dataobjects.Securable

isAllowed

public void isAllowed(java.lang.String requestedFunction)
               throws java.lang.SecurityException,
                      com.jcorporate.expresso.core.db.DBException
Check if the function is allowed. It does this by checking all the nested data objects ot make sure that each one is allowed.

Specified by:
isAllowed in interface com.jcorporate.expresso.core.dataobjects.Securable

checkInitialized

private void checkInitialized()
One liner function that allows you to quickly enforce proper initialization or the system throws an exception.


isInitialized

protected boolean isInitialized()
Function that checks if initialized.


buildFromClause

protected java.lang.String buildFromClause()
                                    throws com.jcorporate.expresso.core.dataobjects.DataException
Builds the 'FROM' clause without the 'from' part. [That way Update works too]

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

buildSelectFieldsString

protected java.lang.String buildSelectFieldsString()
                                            throws com.jcorporate.expresso.core.db.DBException
Builds the part of the query that is for describing the fields/names to be selected

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

buildUpdateFieldString

protected java.lang.String buildUpdateFieldString()
                                           throws com.jcorporate.expresso.core.dataobjects.DataException
Builds the update field string portion setting question marks for all the field values to be formatted and parsed later in a Prepared statement

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

buildOrderByString

protected java.lang.String buildOrderByString(java.lang.String sortKeys)
                                       throws com.jcorporate.expresso.core.db.DBException
Create the 'ORDER BY' clause in the select statement.

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

buildWhereClauseBuffer

protected java.lang.String buildWhereClauseBuffer(boolean useAllFields,
                                                  com.jcorporate.expresso.kernel.util.FastStringBuffer myStatement)
                                           throws com.jcorporate.expresso.core.db.DBException
Build and return a string consisting of an SQL 'where' clause using the current field values as criteria for the search. See setCustomWhereClause for information on specifying a more complex where clause.

Since:
$DatabaseSchema $Date: 2004/12/01 07:56:43 $

formatCustomWhereClause

private void formatCustomWhereClause(com.jcorporate.expresso.kernel.util.FastStringBuffer myStatement)
                              throws com.jcorporate.expresso.core.db.DBException
Replaces alias names in the customWhereClause with their correct table names


getNestedFromFieldName

public com.jcorporate.expresso.core.dataobjects.DataObject getNestedFromFieldName(java.lang.String fieldName)
Retrieves a nested dataobject based upon the public field name that the DataObject publishes. For example, in JoinedDataObjects, the field name ""abcd.efgh" represents DataObject 'abcd', and field name 'efgh'.

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

Specified by:
getNestedFromFieldName in interface com.jcorporate.expresso.core.dataobjects.NestableDataObject

getAllNested

public com.jcorporate.expresso.core.dataobjects.DataObject[] getAllNested()
Retrieve an array of all nested data objects. May be empty if there are no nested data objects. Ordering is undefined by this function.

Specified by:
getAllNested in interface com.jcorporate.expresso.core.dataobjects.NestableDataObject

getFieldFromNestedName

public java.lang.String getFieldFromNestedName(java.lang.String fieldName)
Often times, field names for the external interface will be different from the of a nested field name in a data object. Use this function to get the internal field name for the DataObject returned by getNestedFromFieldName()

Specified by:
getFieldFromNestedName in interface com.jcorporate.expresso.core.dataobjects.NestableDataObject

getField

public java.lang.String getField(java.lang.String fieldName)
                          throws com.jcorporate.expresso.core.db.DBException
Retrieve the field value as a String

Specified by:
getField in interface com.jcorporate.expresso.core.dataobjects.DataObject

setConnection

public void setConnection(com.jcorporate.expresso.core.db.DBConnection newConnection)
                   throws com.jcorporate.expresso.core.db.DBException
Set a specific DB connection for use with this JoinedDataObject. If you do not set a connection, the db object will request it's own connection from the appropriate connection pool & release it again after every operation (e.g. add, update, etc). It is important to use your own explicit connection when dealing with a database transactional environment (e.g. commit(), rollback()).


setConnection

public void setConnection(com.jcorporate.expresso.core.db.DBConnection newConnection,
                          java.lang.String setupTablesContext)
                   throws com.jcorporate.expresso.core.db.DBException

Set a specific DB connection for use with this JoinedDataObject. If you do not set a connection, the object will request it's own connection from the appropriate connection pool & release it again after every operation (e.g. add, update, etc). It is important to use your own explicit connection when dealing with a database transactional environment (e.g. commit(), rollback()).

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


setGlobalMask

public 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. The mask should already be compiled by the regular expression compiler

Specified by:
setGlobalMask in interface com.jcorporate.expresso.core.dataobjects.DataObject

getGlobalMask

public org.apache.oro.text.regex.Pattern getGlobalMask()
Get the compiled regular expression for this base data object.

Specified by:
getGlobalMask in interface com.jcorporate.expresso.core.dataobjects.DataObject

isGlobalMasked

public boolean isGlobalMasked()
Return boolean if the data object has a mask set

Specified by:
isGlobalMasked in interface com.jcorporate.expresso.core.dataobjects.DataObject

setFieldsWithDefaults

public void setFieldsWithDefaults()
                           throws com.jcorporate.expresso.core.dataobjects.DataException
null

Specified by:
setFieldsWithDefaults in interface com.jcorporate.expresso.core.dataobjects.DataObject