[cvs] expresso commit by yves: Yves Amaizo new changes commit today
JCorporate Ltd
jcorp at jcorporate.com
Tue Oct 18 22:55:22 UTC 2005
Log Message:
-----------
Yves Amaizo new changes commit today 2005/10/19 00:55 french time
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc:
JDBCExecutor.java
JDBCDataObject.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db:
DBConnection.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj:
DBObject.java
MultiDBObject.java
Revision Data
-------------
Index: DBConnection.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBConnection.java,v
retrieving revision 1.60
retrieving revision 1.61
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBConnection.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBConnection.java -u -r1.60 -r1.61
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBConnection.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/DBConnection.java
@@ -2310,6 +2310,214 @@
}
} /* getTypeMap() */
+ /**
+ * Return the value in the numbered field as a string, trimming off
+ * any trailing whitespace
+ *
+ * @param fieldNum The desired field number
+ * @return String The value of the field as a string, less any trailing
+ * whitespace
+ * @throws DBException If the value cannot be accessed
+ */
+ public String getCStmtString(int fieldNum)
+ throws DBException {
+
+ checkTimeOut();
+
+ if (callableStatement == null) {
+ throw new DBException("[2]Null callableStatement object (" + myDescription + ")");
+ }
+ try {
+ String resultValue = callableStatement.getString(fieldNum);
+
+ if (resultValue == null) {
+ return null;
+ }
+
+ return resultValue.trim();
+ } catch (SQLException se) {
+ if (strSQL == null) {
+ strSQL = ("null");
+ }
+
+ throw new DBException("Error fetching string field " + fieldNum + ":Last SQL was:" + strSQL + " (" +
+ myDescription + ")", se.getMessage());
+ }
+ } /* getCStmtString(int) */
+
+ /**
+ * Return the numbered field as a string, not trimming any trailing spaces
+ *
+ * @param fieldNum The number of the desired field
+ * @return String The string field value
+ * @throws DBException If an error occurrs accessing the given field
+ */
+ public String getCStmtStringNoTrim(int fieldNum)
+ throws DBException {
+ checkTimeOut();
+
+ if (callableStatement == null) {
+ throw new DBException("Null callableStatement object (" + myDescription + ")");
+ }
+ try {
+ String resultValue = callableStatement.getString(fieldNum);
+
+ if (resultValue == null) {
+ return null;
+ }
+
+ return resultValue;
+ } catch (SQLException se) {
+ throw new DBException("Error fetching string field " + fieldNum + ":Last SQL was:" + strSQL + " (" +
+ " (" + myDescription + ")", se.getMessage());
+ }
+ } /* getCStmtStringNoTrim(int) */
+
+
+ /**
+ * Return the value in the named field as a string, trimming off
+ * any trailing whitespace
+ *
+ * @param fieldNum The desired column name
+ * @return Date The value of the field as a Time format
+ * @throws DBException If the value cannot be accessed
+ * author Yves Henri AMAIZO
+ * @since Expresso 5.0
+ */
+ public Date getCStmtDate(int fieldNum)
+ throws DBException {
+ checkTimeOut();
+
+ if (callableStatement == null) {
+ throw new DBException("[2]Null callableStatement object (" +
+ myDescription + ")");
+ }
+ try {
+ Date resultValue = callableStatement.getDate(fieldNum);
+
+ return resultValue;
+ } catch (SQLException se) {
+ if (strSQL == null) {
+ strSQL = "null";
+ }
+
+ throw new DBException("Error fetching string field " + fieldNum +
+ ":Last SQL was:" + strSQL + " (" +
+ myDescription + ")", se.getMessage());
+ }
+ } /* getCStmtDate(int) */
+
+
+ /**
+ * Return the value in the named field as a string, trimming off
+ * any trailing whitespace
+ *
+ * @param fieldNum The desired column number
+ * @return Date The value of the field as a Date format
+ * @throws DBException If the value cannot be accessed
+ * author Yves Henri AMAIZO
+ * @since Expresso 5.0
+ */
+ public Date getCStmtTimestamp(int fieldNum)
+ throws DBException {
+ checkTimeOut();
+
+ if (callableStatement == null) {
+ throw new DBException("[2]Null callableStatement object (" +
+ myDescription + ")");
+ }
+ try {
+ Date resultValue = callableStatement.getTimestamp(fieldNum);
+
+ return resultValue;
+ } catch (SQLException se) {
+ if (strSQL == null) {
+ strSQL = ("null");
+ }
+
+ throw new DBException("Error fetching string field " + fieldNum +
+ ":Last SQL was:" + strSQL + " (" +
+ myDescription + ")", se.getMessage());
+ }
+ } /* getTimestamp(int) */
+
+
+ /**
+ * Return the value in the named field as a string, trimming off
+ * any trailing whitespace
+ *
+ * @param fieldNum The desired column number
+ * @return Date The value of the field as a Time format
+ * @throws DBException If the value cannot be accessed
+ * author Yves Henri AMAIZO
+ * @since Expresso 5.0
+ */
+ public Date getCStmtTime(int fieldNum)
+ throws DBException {
+ checkTimeOut();
+
+ if (callableStatement == null) {
+ throw new DBException("[2]Null callableStatement object (" +
+ myDescription + ")");
+ }
+ try {
+ Date resultValue = callableStatement.getTime(fieldNum);
+
+ return resultValue;
+ } catch (SQLException se) {
+ if (strSQL == null) {
+ strSQL = ("null");
+ }
+
+ throw new DBException("Error fetching string field " + fieldNum +
+ ":Last SQL was:" + strSQL + " (" +
+ myDescription + ")", se.getMessage());
+ }
+ } /* getTime(int) */
+
+
+ /**
+ * Fetch the given field of the current row as an integer
+ *
+ * @param fieldNum The number of the desired field
+ * @return int The integer value of the field
+ * @throws DBException If an error occurrs accessing the value
+ */
+ public int getCStmtInt(int fieldNum)
+ throws DBException {
+
+ try {
+ return callableStatement.getInt(fieldNum);
+ } catch (SQLException se) {
+ throw new DBException(THIS_CLASS + "getInt(int)" +
+ ":Error fetching int field " +
+ fieldNum + " (" + myDescription + ")",
+ se.getMessage());
+ }
+ } /* getInt(int) */
+
+
+ /**
+ * Fetch the given field of the current row as a double
+ *
+ * @param fieldNum The number of the field to return
+ * @return double The double value of the given field number
+ * @throws DBException if no such field or some other JDBC error
+ */
+ public double getCStmtDouble(int fieldNum)
+ throws DBException {
+
+ checkTimeOut();
+
+ try {
+ return callableStatement.getDouble(fieldNum);
+ } catch (SQLException se) {
+ throw new DBException(THIS_CLASS + "getDouble(int)" + ":Error fetching double field " +
+ fieldNum + " (" + myDescription + ")",
+ se.getMessage());
+ }
+ } /* getDouble(int) */
+
/**
* Returns the number of rows affected by the last operation .
* Only useful after an executeUpdate
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.69
retrieving revision 1.70
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.69 -r1.70
--- 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
@@ -84,6 +84,7 @@
import com.jcorporate.expresso.kernel.util.FastStringBuffer;
import org.apache.log4j.Logger;
+
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringReader;
@@ -485,7 +486,7 @@
String oneFieldName = null;
Map inputFieldNames = new HashMap(10);
- String[] fields = inputFields.split("\\|");
+ String[] fields = inputFields.split("\\|");
for (int i = 0; i < fields.length; i++) {
oneFieldName = fields[i];
inputFieldNames.put(oneFieldName, null);
@@ -525,8 +526,6 @@
String oneFieldName = null;
Map inputFieldNames = new HashMap(10);
-
-
for (Iterator i = theObject.getFieldsToInputIterator(); i.hasNext();) {
oneFieldName = (String) i.next();
inputFieldNames.put(oneFieldName, null);
@@ -569,7 +568,6 @@
continue;
}
-
if (!oneField.isVirtual()) {
if (needComma) {
sqlCommand.append(", ");
@@ -970,8 +968,25 @@
myStatement.append(", ");
}
- myStatement.append(theObject.selectFieldString(oneFieldName));
- needComma = true;
+
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+ // myStatement.append(theObject.selectFieldString(oneFieldName));
+ oneField = theObject.getFieldMetaData(oneFieldName);
+ if (oneField.isVirtual() && theObject.getDataField(oneFieldName).isValueSet() && !theObject.getDataField(oneFieldName).isNull()) {
+ String oneFieldValue = StringUtil.notNull(theObject.getDataField(oneField.getName()).asString());
+ if (needComma) {
+ myStatement.append(", ");
+ }
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ }
+ myStatement.append(theObject.selectFieldString(oneFieldName));
+ needComma = true;
} /* for each field */
for (Iterator i = theObject.getMetaData().getKeyFieldListArray().iterator();
@@ -995,16 +1010,42 @@
if (oneField.isBinaryObjectType()) {
continue;
}
+
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+
+// if (!oneField.isVirtual()) {
+// if (needComma) {
+// myStatement.append(", ");
+// }
+//
+// myStatement.append(theObject.selectFieldString(oneField.getName()));
+// needComma = true;
+// } /* if field is not virtual */
+
+ if (!oneField.isVirtual()) {
+ if (needComma) {
+ myStatement.append(", ");
+ }
- if (!oneField.isVirtual()) {
- if (needComma) {
- myStatement.append(", ");
- }
-
- myStatement.append(theObject.selectFieldString(oneField.getName()));
- needComma = true;
- } /* if field is not virtual */
-
+ myStatement.append(theObject.selectFieldString(oneField.getName()));
+ needComma = true;
+ } else {
+ if (oneField.isVirtual() && theObject.getDataField(oneField.getName()).isValueSet() && !theObject.getDataField(oneField.getName()).isNull()) {
+ String oneFieldValue = StringUtil.notNull(theObject.getDataField(oneField.getName()).asString());
+ if (needComma) {
+ myStatement.append(", ");
+ }
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ myStatement.append(theObject.selectFieldString(oneField.getName()));
+ needComma = true;
+ }
+ } /* if field is not virtual */
} /* for */
} /* if anyFieldsToRetrieve */
@@ -1627,7 +1668,7 @@
} else {
sqlCommand.append("{call ");
}
- sqlCommand.append(theObject.getJDBCMetaData().getTargetTable());
+ sqlCommand.append(theObject.getJDBCMetaData().getTargetSQLStoreProcedure(theObject.getDataContext()));
if (nbParams > 0) {
sqlCommand.append("(?");
@@ -1829,7 +1870,28 @@
String oneFieldName = null;
myConnection.executeProcedure();
try {
- if (myConnection.getResultSet() != null) {
+ // * @author Yves Henri AMAIZO
+ // Handle correctly data from resultSet data retrieve from Database
+ int returnCode = 1;
+ if (theObject.isStoreFunction()) {
+ // * @author Yves Henri AMAIZO
+ // Handle correctly data from return code in statment Object
+ oneField = theObject.getFieldMetaData(String.valueOf(returnCode));
+ if (oneField.isDateType()) {
+ oneFieldValue = theObject.getCustomStringFieldValue(myConnection,
+ oneField.getName());
+ } else {
+ if (myConnection.isStringNotTrim()) {
+ oneFieldValue = myConnection.getCStmtStringNoTrim(returnCode);
+ } else {
+ oneFieldValue = myConnection.getCStmtString(returnCode);
+ }
+ }
+ theObject.set(oneField.getName(), oneFieldValue);
+ }
+ // * @author Yves Henri AMAIZO
+ // Handle correctly date from resultSet data retrieve from Database
+ if (!theObject.isStoreFunction() && myConnection.getResultSet() != null && myConnection.next()) {
//Clear all non-key fields
for (Iterator allFields = theObject.getMetaData().getFieldNamesList().iterator(); allFields.hasNext();) {
oneFieldName = (String) allFields.next();
@@ -1860,9 +1922,9 @@
continue;
}
try {
- // * @author Yves Henri AMAIZO
- // Handle correctly date from resultSet data retrieve from Database
- if (oneField.isDateType()) {
+ // * @author Yves Henri AMAIZO
+ // Handle correctly data from resultSet data retrieve from Database
+ if (oneField.isDateType()) {
oneFieldValue = theObject.getCustomStringFieldValue(myConnection,
oneField.getName());
} else {
@@ -2016,7 +2078,7 @@
DataFieldMetaData oneField = oneObj.getFieldMetaData(oneFieldName);
oneObj.checkField(oneField.getName(), oneObj.getField(oneField.getName()));
- //Sematics . if oneStringValue == null then
+ //Semantics . if oneStringValue == null then
//we skip the field.
//if oneStringValue.equals("null"); then we add a nullable
//section to the PreparedStatement.
@@ -2054,8 +2116,6 @@
//We're done iterating through paramters/
int size = fieldData.size();
-
-
TypeMapper typeMapper = TypeMapper.getInstance(localConnection.getDataContext());
for (int j = 0; j < size; j++) {
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.49
retrieving revision 1.50
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.49 -r1.50
--- 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
@@ -94,6 +94,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Date;
/**
* Base class for JDBC-based data objects.
@@ -1065,7 +1066,21 @@
}
retrievedFieldList.add(oneFieldName);
- myStatement.append(selectFieldString(oneFieldName));
+// myStatement.append(selectFieldString(oneFieldName));
+
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+ DataFieldMetaData oneField = getFieldMetaData(oneFieldName);
+ if (oneField.isVirtual() && getDataField(oneFieldName).isValueSet() && !getDataField(oneFieldName).isNull()) {
+ String oneFieldValue = StringUtil.notNull(getDataField(oneField.getName()).asString());
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ }
+ myStatement.append(selectFieldString(oneFieldName));
needComma = true;
}
}
@@ -1074,16 +1089,41 @@
i.hasNext(); ) {
DBField oneField = (DBField) i.next();
- if (!oneField.isVirtual() && !oneField.isBinaryObjectType()) {
- if (needComma) {
- myStatement.append(", ");
- }
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+// if (!oneField.isVirtual() && !oneField.isBinaryObjectType()) {
+// if (needComma) {
+// myStatement.append(", ");
+// }
+//
+// retrievedFieldList.add(oneField.getName());
+// myStatement.append(selectFieldString(oneField.getName()));
+// needComma = true;
+// }
+
+ if (!oneField.isVirtual() && !oneField.isBinaryObjectType()) {
+ if (needComma) {
+ myStatement.append(", ");
+ }
+
+ retrievedFieldList.add(oneField.getName());
+ myStatement.append(selectFieldString(oneField.getName()));
+ needComma = true;
+ } else {
+ if (oneField.isVirtual() && getDataField(oneField.getName()).isValueSet() && !getDataField(oneField.getName()).isNull()) {
+ String oneFieldValue = StringUtil.notNull(getDataField(oneField.getName()).asString());
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ myStatement.append(selectFieldString(oneField.getName()));
+ needComma = true;
+ }
+ }
- retrievedFieldList.add(oneField.getName());
- myStatement.append(selectFieldString(oneField.getName()));
- needComma = true;
- }
- /* if field is not virtual */
+ /* if field is not virtual */
}
/* for each field */
@@ -1451,6 +1491,7 @@
throws DBException {
ConfigJdbc myConfig = null;
String oneFieldValue = null;
+ Date tempValue = null;
DateTimeForThread dateInstance = DateTimeForThread.getInstance(dbKey);
DataFieldMetaData fieldMetadata = this.getFieldMetaData(oneFieldName);
try {
@@ -1458,25 +1499,37 @@
} catch (ConfigurationException ce) {
throw new DBException(ce);
}
+ if (this.getDef().isReturningValue())
+ tempValue = connection.getTimestamp(oneFieldName);
+ else
+ tempValue = connection.getCStmtTimestamp(Integer.parseInt(oneFieldName));
+
if (fieldMetadata.isDateTimeType()) {
if (StringUtil.notNull(myConfig.getDateTimeSelectFormat()).length() > 0) {
- oneFieldValue = dateInstance.getDateTimeForDB(connection.getTimestamp(oneFieldName), dbKey);
+// oneFieldValue = dateInstance.getDateTimeForDB(connection.getTimestamp(oneFieldName), dbKey);
+ oneFieldValue = dateInstance.getDateTimeForDB(tempValue, dbKey);
} else {
oneFieldValue = connection.getString(oneFieldName);
}
}
if (fieldMetadata.isTimeType()) {
if (!StringUtil.notNull(myConfig.getTimeSelectFormat()).equals("")) {
- oneFieldValue = dateInstance.getTimeForDB(connection.getTime(oneFieldName), dbKey);
+// oneFieldValue = dateInstance.getTimeForDB(connection.getTime(oneFieldName), dbKey);
+ oneFieldValue = dateInstance.getTimeForDB(tempValue, dbKey);
} else {
oneFieldValue = connection.getString(oneFieldName);
}
}
if (fieldMetadata.isDateOnlyType()) {
if (!StringUtil.notNull(myConfig.getDateSelectFormat()).equals("")) {
- oneFieldValue = dateInstance.getDateForDB(connection.getDate(oneFieldName), dbKey);
+// oneFieldValue = dateInstance.getDateForDB(connection.getDate(oneFieldName), dbKey);
+ oneFieldValue = dateInstance.getDateForDB(tempValue, dbKey);
} else {
- oneFieldValue = connection.getString(oneFieldName);
+// oneFieldValue = connection.getString(oneFieldName);
+ if (this.getDef().isReturningValue())
+ oneFieldValue = connection.getCStmtString(Integer.parseInt(oneFieldName));
+ else
+ oneFieldValue = connection.getString(oneFieldName);
}
}
return oneFieldValue;
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.255
retrieving revision 1.256
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.255 -r1.256
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/DBObject.java
@@ -484,10 +484,10 @@
* 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
+ * @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>
@@ -495,9 +495,9 @@
*/
public void addAll(String valuesRequest, String fieldsToInput)
throws DBException {
-
+
getExecutor().addAll(this, valuesRequest, fieldsToInput);
-
+
/* Now log the change if we are logging */
if (getDef().isLoggingEnabled()) {
ChangeLog myChangeLog = new ChangeLog();
@@ -507,11 +507,11 @@
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);
@@ -1503,8 +1503,8 @@
//
// Created by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
// @since $DatabaseSchema $Date$
- // get SetupValues from mapped SetupContext in DBObject
- // important for application which use different database context for setupValues
+ // get SetupValues from mapped SetupContext in DBObject
+ // important for application which use different database context for setupValues
//
// check for configuration (Setup) switch which turns off all relational integrity checking
@@ -1593,8 +1593,8 @@
//
// Created by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
// @since $DatabaseSchema $Date$
- // get SetupValues from mapped SetupContext in DBObject
- // important for application which use different database context for setupValues
+ // get SetupValues from mapped SetupContext in DBObject
+ // important for application which use different database context for setupValues
//
// check for configuration (Setup) switch which turns off all relational integrity checking
@@ -3902,7 +3902,7 @@
public java.util.List getValidValuesList(String fieldName) throws DBException {
return new ArrayList(getValidValues(fieldName));
- // cannot use this impl. because getValidValues() can be overridden in subclasses, and we need to call it
+ // cannot use this impl. because getValidValues() can be overridden in subclasses, and we need to call it
// Vector valVector = getValidValuesPriv(fieldName);
// ArrayList result = null;
// if ( valVector == null ) {
@@ -5625,11 +5625,11 @@
* @throws DBException If the search could not be completed
*/
public synchronized DBConnection searchAndRetrieveList(String sqlSelectStatement, boolean customString) throws DBException {
-
+
DBConnection myConnection = null;
try {
myConnection = createAndExecuteSearch(sqlSelectStatement);
-
+
} catch (DBException de) {
log.error("Error performing searchAndRetrieveList", de);
throw new DBException(de);
@@ -6186,13 +6186,20 @@
" is a binary object field. You should not be" +
" calling setField directly");
}
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+
+// if (oneField.isVirtual()) {
+// throw new DBException("(" + myClassName + ") Field " +
+// fieldName +
+// " is a virtual field. Database object should " +
+// "extend setField method to handle requests for this field");
+// }
- if (oneField.isVirtual()) {
- throw new DBException("(" + myClassName + ") Field " +
- fieldName +
- " is a virtual field. Database object should " +
- "extend setField method to handle requests for this field");
- }
//
//If there was an error associated with this field before, then
//remove the error attribute.
@@ -6818,6 +6825,30 @@
getDef().setTargetTable(theTable);
} /* setTargetTable(String) */
+
+ /**
+ * set Store Procedure call to function returning value
+ *
+ * @throws DataException upon error
+ * <p/>
+ * author Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+ */
+ public void activateStoreFunction() throws DBException {
+ getDef().setReturningValue(true);
+ } /* activateStoreFunction() */
+
+
+ /**
+ * if dbobject is a Store function or not
+ *
+ * @throws DataException upon error
+ * <p/>
+ * author Yves Henri AMAIZO <amy_amaizo at compuserve.com>
+ */
+ public boolean isStoreFunction() throws DBException {
+ return getDef().isReturningValue();
+ } /* activateStoreFunction() */
+
/**
* Set the target table for this DBObject. Note that an object
* can span tables by the use of virtual fields, but that this table
@@ -6953,15 +6984,15 @@
* 'blind updates' can set the Setup value UPDATE_CHANGED_ONLY to true
* (a blind update is where the object is not retieved before values in it are reset)
*/
-
+
//
// Created by Yves Henri AMAIZO <amy_amaizo at compuserve.com>
// @since $DatabaseSchema $Date$
- // get SetupValues from mapped SetupContext in DBObject
- // important for application which use different database context for setupValues
+ // get SetupValues from mapped SetupContext in DBObject
+ // important for application which use different database context for setupValues
//
-
+
// String onlychanged = Setup.getValueUnrequired(getDataContext(), UPDATE_CHANGED_ONLY);
String onlychanged = Setup.getValueUnrequired(getSetupContext(), UPDATE_CHANGED_ONLY);
if (StringUtil.toBoolean(onlychanged)) {
@@ -7702,7 +7733,7 @@
* @since $DatabaseSchema $Date$
*/
public String getSetupContext() {
-
+
// set from RequestRegistry if this is first access
if (setupKey == null || setupKey.length() == 0) {
try {
@@ -7713,7 +7744,7 @@
setSetupContext(DBConnection.DEFAULT_DB_CONTEXT_NAME);
}
}
-
+
return setupKey;
}
@@ -7725,7 +7756,7 @@
* @since $DatabaseSchema $Date$
*/
public String getCacheContext() {
-
+
// set from RequestRegistry if this is first access
if (cacheKey == null || cacheKey.length() == 0) {
try {
@@ -7736,7 +7767,7 @@
setCacheContext(DBConnection.DEFAULT_DB_CONTEXT_NAME);
}
}
-
+
return cacheKey;
}
Index: MultiDBObject.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/MultiDBObject.java,v
retrieving revision 1.72
retrieving revision 1.73
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/MultiDBObject.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/MultiDBObject.java -u -r1.72 -r1.73
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/MultiDBObject.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dbobj/MultiDBObject.java
@@ -1715,9 +1715,13 @@
rowStringIndex++;
if (log.isDebugEnabled()) {
+ String str = "null";
+ if (tmpData != null) {
+ str = tmpData.toString();
+ }
log.debug("Setting " +
getTableName(oneObj) + "." +
- fieldName + " to " + tmpData.toString());
+ fieldName + " to " + str);
}
// myObj.setField((String) oneObj.getAttribute(SHORT_NAME),
@@ -1884,6 +1888,23 @@
if (needComma) {
myStatement.append(", ");
}
+// myStatement.append(selectFieldString(oneObj, oneFieldName));
+
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+
+ DataFieldMetaData oneField = oneObj.getFieldMetaData(oneFieldName);
+ if (oneField.isVirtual() && oneObj.getDataField(oneFieldName).isValueSet() && !oneObj.getDataField(oneFieldName).isNull()) {
+ String oneFieldValue = StringUtil.notNull(oneObj.getDataField(oneField.getName()).asString());
+ if (needComma) {
+ myStatement.append(", ");
+ }
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ }
myStatement.append(selectFieldString(oneObj, oneFieldName));
retrievedFieldList.add(oneFieldName);
needComma = true;
@@ -1897,16 +1918,38 @@
DataFieldMetaData metaData =
oneObj.getFieldMetaData(fieldName);
- if (!metaData.isVirtual()
- && !metaData.isBinaryObjectType()) {
- if (needComma) {
- myStatement.append(", ");
- }
-
- myStatement.append(selectFieldString(oneObj, fieldName));
- retrievedFieldList.add(fieldName);
- needComma = true;
- }
+// if (!metaData.isVirtual()
+// && !metaData.isBinaryObjectType()) {
+// if (needComma) {
+// myStatement.append(", ");
+// }
+// myStatement.append(selectFieldString(oneObj, fieldName));
+
+ // * @author Yves Henri AMAIZO
+ // * $Date: 2005/09/12 15:21:57
+ // Handle correctly virtual field set value for include as column expression in SELECT QUERY as
+ // SELECT -,-,-, DECODE(TO_CHAR('DATE_END'),"00/00/0000",0,1") ENCOURS FROM -,-,-, .... ORDER BY ENCOURS ......
+ // ! ENCOURS is a virtual field and it's expression is given before the from keyword.
+ if (!metaData.isVirtual() && !metaData.isBinaryObjectType()) {
+ if (needComma) {
+ myStatement.append(", ");
+ }
+
+ myStatement.append(selectFieldString(oneObj, fieldName));
+ retrievedFieldList.add(fieldName);
+ needComma = true;
+ } else {
+ if (metaData.isVirtual() && oneObj.getDataField(metaData.getName()).isValueSet() && !oneObj.getDataField(metaData.getName()).isNull()) {
+ String oneFieldValue = StringUtil.notNull(oneObj.getDataField(metaData.getName()).asString());
+ if (needComma) {
+ myStatement.append(", ");
+ }
+ myStatement.append(oneFieldValue);
+ myStatement.append(" ");
+ myStatement.append(oneObj.selectFieldString(metaData.getName()));
+ needComma = true;
+ }
+ }
/* if field is not virtual & not binary*/
}
More information about the cvs
mailing list