[cvs] expresso commit by lhamel: remove addAll logic to just
JDBCExector
JCorporate Ltd
jcorp at jcorporate.com
Wed Dec 29 21:37:07 UTC 2004
Log Message:
-----------
remove addAll logic to just JDBCExector
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects:
DataExecutorInterface.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc:
JDBCDataObject.java
JDBCExecutor.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
DBObject.java
Revision Data
-------------
Index: JDBCExecutor.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCExecutor.java,v
retrieving revision 1.63
retrieving revision 1.64
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCExecutor.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCExecutor.java -u -r1.63 -r1.64
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCExecutor.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCExecutor.java
@@ -78,7 +78,6 @@
import com.jcorporate.expresso.core.dbobj.DBField;
import com.jcorporate.expresso.core.dbobj.DBObject;
import com.jcorporate.expresso.core.dbobj.NextNumber;
-import com.jcorporate.expresso.core.misc.ConfigJdbc;
import com.jcorporate.expresso.core.misc.ConfigManager;
import com.jcorporate.expresso.core.misc.ConfigurationException;
import com.jcorporate.expresso.core.misc.StringUtil;
@@ -424,218 +423,184 @@
}
- /**
- * Takes a <code>DataObject</code> and adds it to the underlying data source
- * @param valueObject the <code>DataObject</code> to add.
- * @param valuesRequest the <code>String</code> contains the database request to provide the values to add.
- * @throws DataException upon error adding the object to the data source
- * @throws DuplicateKeyException if the object already existed in the data
- * source.
- *
- * Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
- */
- public void addAll(DataObject valueObject, String valuesRequest) throws DataException, DuplicateKeyException {
- DBConnection myConnection = null;
- DBConnectionPool myPool = null;
- DBConnection localConnection = null;
-
- try {
- if (valueObject == null) {
- throw new IllegalArgumentException(myName + "addAll(DataObject, String): valueObject was null");
- }
-
- DBObject theObject = (DBObject) valueObject;
- JDBCObjectMetaData metadata = (JDBCObjectMetaData)valueObject.getMetaData();
-
- boolean needComma = false;
-
- //
- //The names of the database fiels that require prepared statements
- //to Add
- //
- List lobFieldOrder = null;
- List lobFieldType = null;
-
- //
- //The list of Strings to add to the file
- //
- List lobAdds = null;
-
-
- //
- //If myPool isn't set yet, then we need to use getDBName to
- //reset. FIXME: Have the system throw exceptions if DBName isn't
- //set instead.
- //
- myPool = DBConnectionPool.getInstance(theObject.getMappedDataContext());
- localConnection = theObject.getLocalConnection();
-
- theObject.checkAllRefsPublic();
-
- DataFieldMetaData oneField = null;
-
- /**
- * sqlCommand will eventually = sqlCommand + valuesCommand. The two
- * are assembled in parallel in the loop below.
- */
- FastStringBuffer sqlCommand = FastStringBuffer.getInstance();
- FastStringBuffer valuesCommand = FastStringBuffer.getInstance();
- String theSqlCommand = null;
- try {
-
- sqlCommand.append("INSERT INTO ");
- sqlCommand.append(metadata.getTargetSQLTable(theObject.getDataContext()));
- sqlCommand.append(" (");
-
- valuesCommand.append(") ");
-
- valuesCommand.append(valuesRequest);
-
- boolean needCommaValues = false;
-// for (Iterator i = metadata.getAllFieldsMap().values().iterator(); i.hasNext();) {
-// oneField = (DBField) i.next();
-//
-// if (!oneField.isVirtual()) {
-// theObject.checkField(oneField.getName(), theObject.getField(oneField.getName()));
-//
-// if (oneField.isBinaryObjectType()) {
-// if (log.isDebugEnabled()) {
-// log.debug("Skipping BINARY Object: " + oneField.getName());
-// }
-// continue;
-// }
-//
-// if (needComma) {
-// sqlCommand.append(", ");
-// }
-//
-// sqlCommand.append(oneField.getName());
-// needComma = true;
-//
-// } /* if field is not virtual */
-//
-// } /* for each field */
-
- if (theObject.getFieldsToInputCount() > 0) {
- String oneFieldName = null;
- Map inputFieldNames = new HashMap(10);
-
- for (Iterator i = theObject.getFieldsToInputIterator(); i.hasNext();) {
- oneFieldName = (String) i.next();
- inputFieldNames.put(oneFieldName, null);
-
- oneField = theObject.getMetaData().getFieldMetadata(oneFieldName);
- if (oneField != null) {
- if (!oneField.isVirtual()) {
- if (needComma) {
- sqlCommand.append(", ");
- }
- sqlCommand.append(theObject.selectFieldString(oneFieldName));
- } else {
- if (needComma) {
- sqlCommand.append(", ");
- }
- if (oneField.getTypeString().equalsIgnoreCase("varchar")) {
- sqlCommand.append("\'");
- sqlCommand.append(oneField.getDescription());
- sqlCommand.append("\'");
- }
- if (oneField.getTypeString().equalsIgnoreCase("int")) {
- sqlCommand.append(oneField.getDescription());
- }
- }
- needComma = true;
- } else {
- if (needComma) {
- sqlCommand.append(", ");
- }
- sqlCommand.append(oneFieldName);
- needComma = true;
- }
- } /* for each field */
-
- } else { /* for each key field */
- for (Iterator i = metadata.getAllFieldsMap().values().iterator(); i.hasNext();) {
- oneField = (DBField) i.next();
- //We aren't retrieving long objects
- if (oneField.isBinaryObjectType()) continue;
-
- if (!oneField.isVirtual()) {
- if (needComma) {
- sqlCommand.append(", ");
- }
-
- sqlCommand.append(theObject.selectFieldString(oneField.getName()));
- needComma = true;
- } /* if field is not virtual */
-
- if (oneField.isVirtual()) {
- if (needComma) {
- sqlCommand.append(", ");
- }
+ /**
+ * Takes a <code>DataObject</code> and adds it to the underlying data source
+ *
+ * @param valueObject the <code>DataObject</code> to add.
+ * @param valuesRequest the <code>String</code> contains the database request to provide the values to add.
+ * @param inputFields field names in valueObject which should receive input from the query (in precise order that the query will return, delimited by "|")
+ * @throws DataException upon error adding the object to the data source
+ * @throws DuplicateKeyException if the object already existed in the data
+ * source.
+ * <p/>
+ * Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+ */
+ public void addAll(DataObject valueObject, String valuesRequest,
+ String inputFields) throws DataException, DuplicateKeyException {
+ DBConnection myConnection = null;
+ DBConnectionPool myPool = null;
+ DBConnection localConnection = null;
+
+ try {
+ if (valueObject == null) {
+ throw new IllegalArgumentException(myName + "addAll(DataObject, String): valueObject was null");
+ }
+
+ DBObject theObject = (DBObject) valueObject;
+ JDBCObjectMetaData metadata = (JDBCObjectMetaData) valueObject.getMetaData();
+
+ boolean needComma = false;
+
+ //
+ //If myPool isn't set yet, then we need to use getDBName to
+ //reset. FIXME: Have the system throw exceptions if DBName isn't
+ //set instead.
+ //
+ myPool = DBConnectionPool.getInstance(theObject.getMappedDataContext());
+ localConnection = theObject.getLocalConnection();
+
+ theObject.checkAllRefsPublic();
+
+ DataFieldMetaData oneField = null;
+
+ /**
+ * sqlCommand will eventually = sqlCommand + valuesCommand. The two
+ * are assembled in parallel in the loop below.
+ */
+ FastStringBuffer sqlCommand = FastStringBuffer.getInstance();
+ FastStringBuffer valuesCommand = FastStringBuffer.getInstance();
+ String theSqlCommand = null;
+ try {
+
+ sqlCommand.append("INSERT INTO ");
+ sqlCommand.append(metadata.getTargetSQLTable(theObject.getDataContext()));
+ sqlCommand.append(" (");
+
+ valuesCommand.append(") ");
+
+ valuesCommand.append(valuesRequest);
+
+ if (inputFields != null && inputFields.length() > 0) {
+ String oneFieldName = null;
+ Map inputFieldNames = new HashMap(10);
+
+ String[] fields = inputFields.split("\\|");
+ for (int i = 0; i < fields.length; i++) {
+ oneFieldName = fields[i];
+ inputFieldNames.put(oneFieldName, null);
+
+ oneField = theObject.getMetaData().getFieldMetadata(oneFieldName);
+ if (oneField != null) {
+ if (!oneField.isVirtual()) {
+ if (needComma) {
+ sqlCommand.append(", ");
+ }
+ sqlCommand.append(theObject.selectFieldString(oneFieldName));
+ } else {
+ if (needComma) {
+ sqlCommand.append(", ");
+ }
if (oneField.getTypeString().equalsIgnoreCase("varchar")) {
- sqlCommand.append(oneField.getDescription());
+ sqlCommand.append("\'");
+ sqlCommand.append(oneField.getDescription());
+ sqlCommand.append("\'");
+ }
+ if (oneField.getTypeString().equalsIgnoreCase("int")) {
+ sqlCommand.append(oneField.getDescription());
}
- if (oneField.getTypeString().equalsIgnoreCase("int")) {
- sqlCommand.append(oneField.getDescription());
- }
- needComma = true;
- } /* if field is not virtual */
-
- } /* for */
-
- } /* if anyFieldsToInput */
-
- //Now we merge the values of the parallel loops
- sqlCommand.append(")");
- sqlCommand.append(valuesCommand);
- theSqlCommand = sqlCommand.toString();
- } catch (NullPointerException npe) {
- log.error("NPE", npe);
- throw new DataException("Null Pointer Exception", npe);
- } catch (DBException dbe) {
- log.error("DBException", dbe);
- throw dbe;
- } finally {
- sqlCommand.release();
- sqlCommand = null;
- valuesCommand.release();
- valuesCommand = null;
- }
-
- if (localConnection != null) {
- myConnection = localConnection;
- } else {
- try {
- myConnection = myPool.getConnection(getClass().getName());
- } catch (java.util.ConcurrentModificationException cme) {
- cme.printStackTrace();
- log.error(cme);
- throw new DataException("JDBCExecutor.addAll() ConcurrentModificationException"
- , cme);
- }
- }
-
- myConnection.executeUpdate(theSqlCommand);
-
- } catch (NullPointerException npe) {
- log.error("NPE", npe);
- throw new DataException("Null Pointer Exception", npe);
- }
- catch (DBException ex) {
- String msg = myName + "addAll(DataObject) error: ";
- log.error(msg, ex);
- throw new DataException(ex.getMessage());
- } finally {
- if (localConnection == null) {
- if (myPool != null && myConnection != null) {
- myPool.release(myConnection);
- }
- }
- }
-
- }
+ }
+ needComma = true;
+ } else {
+ if (needComma) {
+ sqlCommand.append(", ");
+ }
+ sqlCommand.append(oneFieldName);
+ needComma = true;
+ }
+ } /* for each field */
+
+ } else { /* for each key field */
+ for (Iterator i = metadata.getAllFieldsMap().values().iterator(); i.hasNext();) {
+ oneField = (DBField) i.next();
+ //We aren't retrieving long objects
+ if (oneField.isBinaryObjectType()) {
+ continue;
+ }
+
+ if (!oneField.isVirtual()) {
+ if (needComma) {
+ sqlCommand.append(", ");
+ }
+
+ sqlCommand.append(theObject.selectFieldString(oneField.getName()));
+ needComma = true;
+ } /* if field is not virtual */
+
+ if (oneField.isVirtual()) {
+ if (needComma) {
+ sqlCommand.append(", ");
+ }
+ if (oneField.getTypeString().equalsIgnoreCase("varchar")) {
+ sqlCommand.append(oneField.getDescription());
+ }
+ if (oneField.getTypeString().equalsIgnoreCase("int")) {
+ sqlCommand.append(oneField.getDescription());
+ }
+ needComma = true;
+ } /* if field is not virtual */
+
+ } /* for */
+
+ } /* if anyFieldsToInput */
+
+ //Now we merge the values of the parallel loops
+ sqlCommand.append(")");
+ sqlCommand.append(valuesCommand);
+ theSqlCommand = sqlCommand.toString();
+ } catch (NullPointerException npe) {
+ log.error("NPE", npe);
+ throw new DataException("Null Pointer Exception", npe);
+ } catch (DBException dbe) {
+ log.error("DBException", dbe);
+ throw dbe;
+ } finally {
+ sqlCommand.release();
+ sqlCommand = null;
+ valuesCommand.release();
+ valuesCommand = null;
+ }
+
+ if (localConnection != null) {
+ myConnection = localConnection;
+ } else {
+ try {
+ myConnection = myPool.getConnection(getClass().getName());
+ } catch (java.util.ConcurrentModificationException cme) {
+ cme.printStackTrace();
+ log.error(cme);
+ throw new DataException("JDBCExecutor.addAll() ConcurrentModificationException"
+ , cme);
+ }
+ }
+
+ myConnection.executeUpdate(theSqlCommand);
+
+ } catch (NullPointerException npe) {
+ log.error("NPE", npe);
+ throw new DataException("Null Pointer Exception", npe);
+ } catch (DBException ex) {
+ String msg = myName + "addAll(DataObject) error: ";
+ log.error(msg, ex);
+ throw new DataException(ex.getMessage());
+ } finally {
+ if (localConnection == null) {
+ if (myPool != null && myConnection != null) {
+ myPool.release(myConnection);
+ }
+ }
+ }
+
+ }
/**
* Takes a <code>DataObject</code> and deletes it from the underlying data source.
@@ -669,7 +634,6 @@
* @throws DataException upon error updating the object to the data source
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
public void update(DataObject valueObject, boolean updateChangedFieldsOnly) throws DataException {
if (valueObject == null) {
@@ -769,17 +733,9 @@
lobFieldType = new ArrayList();
}
Object tmpData = valueObject.get(oneField.getName());
- String data;
//
- //FIXME allow for appropriate support of other data types.
+ //todo FIXME allow for appropriate support of other data types.
//
- if (tmpData == null) {
- data = null;
- } else if (tmpData instanceof String) {
- data = (String) tmpData;
- } else {
- data = tmpData.toString();
- }
lobUpdates.add(tmpData);
lobFieldOrder.add(oneFieldName);
@@ -918,7 +874,6 @@
* @param valueObject the DataObject who's keys are already set to retrieve
* @return true if the data object was successfully retrieved
* @throws DataException Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
public boolean retrieve(DataObject valueObject) throws DataException {
if (valueObject == null) {
@@ -1215,7 +1170,6 @@
* @throws DBException upon error
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
protected String buildPreparedUpdateSQL(DataObject oneObjectType, boolean updateChangedFieldsOnly) throws DBException {
DBObject theObject = (DBObject) oneObjectType;
@@ -1298,7 +1252,6 @@
* @throws DBException upon error
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
protected String buildPreparedDeleteSQL(DataObject oneObjectType, boolean deleteWithSetFieldsOnly) throws DBException {
DBObject theObject = (DBObject) oneObjectType;
@@ -1380,7 +1333,6 @@
* @throws DBException upon error
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
protected String buildPreparedAddSQL(DataObject oneObjectType, boolean addChangedFieldsOnly) throws DBException {
DBObject theObject = (DBObject) oneObjectType;
@@ -1542,7 +1494,6 @@
* @throws DataException upon error updating the object to the data source
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
*/
public void updateAll(DataObject valueObject, boolean updateChangedCache)
throws DataException {
@@ -1642,7 +1593,6 @@
*
* @param criteria the JDBCDataObject to build from
* @param myCallableStatement the statement
- * @return A FastStringBuffer containing the "where" clause for the SQL statement
* @throws DataException upon error
*/
protected void buildStoreProcedureCallableStatement(DBObject criteria, CallableStatement myCallableStatement)
@@ -1657,24 +1607,12 @@
DataFieldMetaData oneField = null;
String oneFieldName = null;
String oneFieldValue = null;
- boolean postgresql = false;
- boolean skipText = false;
- boolean skipField = false;
boolean inField = false;
boolean outField = false;
TypeMapper typeMapper = null;
try {
- ConfigJdbc myConfig = ConfigManager.getJdbcRequired(criteria.getMappedDataContext());
- skipText = myConfig.skipText();
- //We have to do this because postgres won't be smart enough to
- //cast floating point literals to truly a floating point value. :(
- if ("org.postgresql.Driver".equals(myConfig.getDriver())) {
- postgresql = true;
- }
typeMapper = TypeMapper.getInstance(criteria.getDataContext());
- } catch (ConfigurationException ce) {
- throw new DataException(ce);
} catch (DBException de) {
throw new DataException(de);
}
@@ -1683,13 +1621,8 @@
while (fieldsToUse.hasNext()) {
oneFieldName = (String) fieldsToUse.next();
oneField = criteria.getFieldMetaData(oneFieldName);
- skipField = false;
- skipText = false;
inField = false;
outField = false;
- if (oneField.isVirtual()) {
- skipField = true;
- }
if (criteria.getDef().isInField(oneField.getName())) {
inField = true;
}
@@ -1800,7 +1733,6 @@
* valueObject parameter.
*
* @param valueObject the DataObject who's keys are already set to retrieve
- * @return true if the data object was successfully retrieved
*/
public void runStoreProcedure(DataObject valueObject)
throws DataException {
Index: JDBCDataObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java -u -r1.44 -r1.45
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/JDBCDataObject.java
@@ -168,12 +168,6 @@
*/
public HashMap retrieveFields = null;
- /**
- * The actual fields inserted or updated
- * Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- */
- public HashMap inputFields = null;
-
/**
* DBObjects themselves do not contain the "meta data" or the definition of
* what fields they contain and other information. Instead, a DBObjectRef object
@@ -192,15 +186,6 @@
*/
protected boolean anyFieldsToRetrieve = false;
- /**
- * If setFieldsToInput has been used to specify fields which will be
- * insert or update by the next query.
- * Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- */
- protected boolean anyFieldsToInput = false;
-
-
-
/**
* Local connection that we use if it's initialized, but
@@ -763,7 +748,7 @@
* <p/>
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
* @throws DBException upon database communication error
- * @since $DatabaseSchema $Date$
+
*/
public DBConnection createAndExecuteSearch(java.util.ArrayList retrievedFieldList)
throws DBException {
@@ -927,140 +912,6 @@
}
}
- /**
- * Create the SQL select statement to be executed if the if searchAndRetrieveList is
- * invoked
- *
- * SIDE-EFFECT: custom 'where' clause is set to null.
- *
- * @param retrievedFieldList instantiate an ArrayList and the function will
- * fill out the field order that the SQL statement will have it's fields in.
- * @throws DBException upon database communication error
- * @return String that has contains the select statement prepared.
- *
- * Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
- */
- public String createSQLSelectStatement(java.util.ArrayList retrievedFieldList)
- throws DBException
- {
- boolean needComma = false;
-
-
- myUpdates = null;
-
- DBConnection myConnection = null;
- JDBCObjectMetaData myMetadata = this.getJDBCMetaData();
- FastStringBuffer myStatement = FastStringBuffer.getInstance();
- try {
- if (localConnection != null) {
- myConnection = localConnection;
- } else {
- myConnection = this.getConnectionPool().getConnection(this.myClassName);
- }
-
- myStatement.append("SELECT ");
-
-
- if (anyFieldsDistinct) {
- String oneFieldName = null;
- myStatement.append(" ");
- myStatement.append(getConnectionPool().getDistinctRowsetKeyword());
- myStatement.append(" ");
-
- for (Iterator i = getDistinctFieldArrayList().iterator();
- i.hasNext();) {
- oneFieldName = (String) i.next();
- retrievedFieldList.add(oneFieldName);
-
- if (needComma) {
- myStatement.append(", ");
- }
-
- myStatement.append(selectFieldString(oneFieldName));
- needComma = true;
- }
- } else if (anyFieldsToRetrieve) { /* for each distinct field */
- String oneFieldName = null;
-
- for (Iterator i = getFieldsToRetrieveIterator(); i.hasNext();) {
- oneFieldName = (String) i.next();
-
- if (needComma) {
- myStatement.append(", ");
- }
-
- retrievedFieldList.add(oneFieldName);
- if (myMetadata.isField(oneFieldName)) {
- myStatement.append(selectFieldString(oneFieldName));
- } else {
- myStatement.append(oneFieldName);
- }
- needComma = true;
- }
- } else { /* for each field */
- for (Iterator i = myMetadata.getAllFieldsMap().values().iterator();
- i.hasNext();) {
- DBField oneField = (DBField) i.next();
-
- if (!oneField.isVirtual() && !oneField.isBinaryObjectType()) {
- if (needComma) {
- myStatement.append(", ");
- }
-
- retrievedFieldList.add(oneField.getName());
- myStatement.append(selectFieldString(oneField.getName()));
- needComma = true;
- } /* if field is not virtual */
-
- } /* for each field */
-
- } /* else this is a regular (non-distinct) search */
-
- myStatement.append(" FROM ");
- myStatement.append(myMetadata.getTargetSQLTable(this.getDataContext()));
-
- String whereClause;
-
- if (customWhereClause != null) {
- if (appendCustomWhere) {
- whereClause = buildWhereClause(true) + customWhereClause;
- appendCustomWhere = false;
- } else {
- whereClause = customWhereClause;
- }
- myStatement.append(whereClause);
- customWhereClause = null;
- } else {
- whereClause = buildWhereClause(true);
- myStatement.append(whereClause);
- }
-
- /* Add the ORDER BY clause if any sortKeys are specified */
- if (sortKeys != null && sortKeys.size() > 0) {
- myStatement.append(" ORDER BY ");
-
- boolean needComma2 = false;
-
- for (Iterator i = sortKeys.iterator(); i.hasNext();) {
- if (needComma2) {
- myStatement.append(", ");
- }
-
- myStatement.append((String) i.next());
- needComma2 = true;
- }
- }
-
- return myStatement.toString();
- } catch (DBException ex) {
- log.error("Error building select statement", ex);
- throw ex;
- } finally {
- myStatement.release();
- }
- }
-
/**
* Fills the given constructed data object with data from the connection
* given the field order specified in retrievedFieldList. Similar to
@@ -1233,26 +1084,6 @@
return retrieveFields.keySet().iterator();
}
- /**
- * Get a special <code>Iterator</code> object list of all
- * of the fields in this object that are set to <b>input</b>
- * <p>Author Yves henri Amaizo <amy_amaizo at compuserve.com></p>
- * @return An Iterator of all the
- * <b>retrieve</b> fieldNames in this object
- *
- * @throws DBException If the list cannot be input
- *
- */
- public Iterator getFieldsToInputIterator()
- throws DBException {
-
- //Do a dummy so we don't throw null pointer exceptions
- if (inputFields == null) {
- return new HashMap().keySet().iterator();
- }
-
- return inputFields.keySet().iterator();
- }
/**
* Build and return a string consisting of an SQL 'where' clause
* using the current field values as criteria for the search. See
Index: DataExecutorInterface.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/DataExecutorInterface.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/DataExecutorInterface.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/DataExecutorInterface.java -u -r1.13 -r1.14
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/DataExecutorInterface.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/DataExecutorInterface.java
@@ -89,15 +89,6 @@
*/
public void add(DataObject valueObject) throws DataException, DuplicateKeyException;
- /**
- * Takes a <code>DataObject</code> and adds it to the underlying data source
- * @param valueObject the <code>DataObject</code> to add.
- * @throws DataException upon error adding the object to the data source
- * @throws DuplicateKeyException if the object already existed in the data
- * source.
- */
- public void addAll(DataObject valueObject, String valuesRequest) throws DataException, DuplicateKeyException;
-
/**
* Takes a <code>DataObject</code> and deletes it from the underlying data source
*
Index: DBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java,v
retrieving revision 1.233
retrieving revision 1.234
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java -u -r1.233 -r1.234
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
@@ -470,46 +470,6 @@
notifyListeners(EVENT_ADD);
} /* add() */
- /**
- * Add records to the target table from the request ivoked inside DATABASE engine.
- * Assumes that the fields of this object are populated with data for the new
- * records. All key fields at least must be supplied with values, and all fields
- * that are specified as "no nulls". This method also validates all referential
- * integrity constraints specified by the object.
- *
- * @param valuesRequest The string contains the select request to be executed.
- * There is assumed to be a one to one or one to many relationship
- * from this object to the specified object
- *
- * @throws DBException If the record(s) cannot be added - this includes if the
- * record has a duplicate key
- * Added by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
- * @since $DatabaseSchema $Date$
- */
- public void addAll(String valuesRequest)
- throws DBException {
-
- getExecutor().addAll(this, valuesRequest);
-
- /* Now log the change if we are logging */
- if (getDef().isLoggingEnabled()) {
- ChangeLog myChangeLog = new ChangeLog();
- myChangeLog.setDataContext(getDataContext());
- myChangeLog.setField("ObjectChanged", myClassName);
- myChangeLog.setField("RecordKey", getMyKeys());
- myChangeLog.setField("Operation", EVENT_ADD);
- myChangeLog.setField("ChangedField", "ALL");
- myChangeLog.add();
-
- /* We're done tracking changes */
- myUpdates = null;
- } /* if */
-
- // after add(), we know that 'current' values are now the baseline for comparison
- setStatus(BaseDataObject.STATUS_CURRENT);
- notifyListeners(EVENT_ADD);
- } /* addAll(String) */
-
/**
* Hand a dbobject a connection that contains fields corresponding to
* what the dbobject expects, and it'll set itself.
@@ -1670,25 +1630,6 @@
}
} /* clearFieldsToRetrieve() */
- /**
- * This convenience method clears all the fileds to be input
- * <code>DBFields</code> belonging to this
- * <code>DBObject</code>
- * <p/>
- * author Yves Henri Amaizo <amy_amaizo at compuserve.com>
- *
- * @see #isFieldsToInput()
- */
- public synchronized void clearFieldsToInput()
- throws DBException {
- if (inputFields == null) {
- return;
- } else {
- inputFields = null;
- anyFieldsToInput = false;
- }
- } /* clearFieldsToInput() */
-
/**
* See if this field value contains wild cards (e.g. pattern matching
@@ -2067,7 +2008,7 @@
if (oneByOne) {
deleteAll();
} else {
- doDeleteAll(true);
+ deleteAllNoDetails();
}
} /* deleteAll(boolean) */
@@ -2075,12 +2016,11 @@
* Delete all records inside the database.
* Important: this method ignores any 'detail' records. Use this only if you are sure that the table has no detail records (i.e., it supplies no foreign keys--has no dependent records)
*
- * @param deleteAllRecords Delete associated detail records if true
* @throws DBException Modify
* @todo move code here to impl. of deleteAll(), using logic to figure out whether efficient technique below can be used; i.e., whether dbobject has any dependent details.
* @see DBObject#deleteAll to delete objects identified by non-key fields
*/
- private synchronized void doDeleteAll(boolean deleteAllRecords)
+ private synchronized void deleteAllNoDetails()
throws DBException {
FastStringBuffer sqlCommand = new FastStringBuffer(128);
@@ -3349,23 +3289,6 @@
}
} /* getFieldsToRetrieveCount() */
- /**
- * This convenience method counts
- * <code>DBFields</code> belonging to this
- * <code>DBObject</code> that are set to <b>input</b>.
- * author Yves Henri Amaizo <amy_amaizo at compuserve.com>
- *
- * @return int number of input fields.
- */
- public synchronized int getFieldsToInputCount()
- throws DBException {
- if (inputFields == null) {
- return 0;
- } else {
- return inputFields.size();
- }
- } /* getFieldsToInputCount() */
-
/**
* Return the number of records found in the last search operation. See also
@@ -4645,27 +4568,6 @@
}
} /* isFieldsToRetrieve() */
- /**
- * This method iterates through all the <code>DBFields</code> belonging
- * <code>DBObject</code> returns <code>true</code> if any of them are
- * between the <b>input</b> fields.
- * <p/>
- * author Yves Henri Amaizo <amy_amaizo at compuserve.com>
- *
- * @return true if there are specific fields to input
- * @see #isFieldsToInput(String)
- */
- public synchronized boolean isFieldsToInput()
- throws DBException {
- if (inputFields == null) {
- return false;
- } else if (inputFields.size() > 0) {
- return true;
- } else {
- return false;
- }
- } /* isFieldsToInput() */
-
/**
* Convenience method to check if a field is field to be retrieve or not
@@ -6235,61 +6137,6 @@
}
} /* setFieldsToRetrieve(String) */
- /**
- * Convenience method to set the fields to be input for add and update order
- * within this database object.
- * <b>NOTE AS OF EXPRESSO 5.0</b> setFieldsToInput() could cause you
- * some problems if you're attempting to input long objects since
- * everything will be converted to a STRING. Please use caution :).
- *
- * @param fieldNames contain the name of the fields separate by "|"
- * @throws DBException If the operation could not be completed
- * <p/>
- * author Yves Henri Amaizo <amy_amaizo at compuserve.com>
- * @see #isFieldsToInput()
- */
- public void setFieldsToInput(String fieldNames)
- throws DBException {
-
- if (fieldNames == null) {
- // Allows DBObject to be used within a MultiDBObject for join purposes
- // when no fields are required from this DBObject
- anyFieldsToInput = true;
- return;
- }
-
- if (inputFields == null) {
- inputFields = new HashMap();
- }
-
- String tempString = null;
- StringTokenizer stk = new StringTokenizer(fieldNames, "|");
-
- while (stk.hasMoreTokens()) {
- tempString = stk.nextToken();
-
- //
- //Will throw a DBException if the field doesn't exist.
- //
- if (getDef().isField(tempString)) {
- DataFieldMetaData oneField = getFieldMetaData(tempString);
-
- if (!oneField.isCharacterLongObjectType() && !oneField.isLongBinaryType() && oneField.isLongObjectType()) {
- log.warn("Ignoring field to retrieve for field name: " + tempString +
- " the field type is considered a binary large object and" +
- " should be retrieved separately");
-
- continue;
- }
-
- inputFields.put(oneField.getName(), oneField.getName());
- } else {
- inputFields.put(tempString, tempString);
- }
- anyFieldsToInput = true;
- }
- } /* setFieldsToInput(String) */
-
/**
* Set the values for each of the key fields of this object from
@@ -6555,23 +6402,6 @@
return ((DBField) oneField).getFilterMethod();
} /* getStringFilter(String) */
- /**
- * get the current filter for a particular field. This is the 'static', permanent filter.
- *
- * @param fieldName The name of the field to set a particular filter for.
- * @return java.lang.String the current filter method.
- * @throws DBException if: fieldName doesn't exist, or filterType String
- * isn't a valid value.
- * @see #getFilterClass() for a means to get a filter on just an instance
- * @see com.jcorporate.expresso.core.security.filters.FilterManager
- */
- public synchronized String getSQLSelectStatement()
- throws DBException {
-
- ArrayList retrievedFieldList = new ArrayList();
-
- return createSQLSelectStatement(retrievedFieldList);
- } /* getSQLSelectStatement() */
/**
* Set the target table for this DBObject. Note that an object
@@ -6912,21 +6742,19 @@
if (oneByOne) {
updateAll();
} else {
- doUpdateAll(true);
+ updateNoDetails();
}
} /* updateAll(boolean) */
/**
* Takes a <code>DataObject</code> and updates all to the underlying data source.
*
- * @param updateChangedCache if true only modified fields (isChanged = true)
- * will be included in the update
* @throws DataException upon error updating the object to the data source
* Modify by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
* @todo move code here to impl. of updateAll(), using logic to figure out whether efficient technique below can be used; i.e., whether dbobject has any dependent details.
* @todo add code for logging updates to db via ChangeLog.java
*/
- private void doUpdateAll(boolean updateChangedCache)
+ private void updateNoDetails()
throws DataException {
boolean needComma = false;
More information about the cvs
mailing list