You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hu...@apache.org on 2002/08/20 23:33:31 UTC
cvs commit: jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql StorageBeanBase.java AccessBase.java
husted 2002/08/20 14:33:31
Modified: scaffold/src/java/org/apache/commons/scaffold/sql
StorageBeanBase.java AccessBase.java
Log:
+ StorageBeanBase.retrieve, recycle,delete: Add call to result.setSingleForm.
+ StorageBeanBase.findElement: Swap key,command parameters
+ StorageBeanBase: Added findCollection convenience methods.
+ StorageBeanBase: Add marked as a base property.
+ AccessBase: deprecate class. Add note about findElement
parameters.
Revision Changes Path
1.4 +65 -30 jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java
Index: StorageBeanBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/StorageBeanBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StorageBeanBase.java 19 Aug 2002 22:33:12 -0000 1.3
+++ StorageBeanBase.java 20 Aug 2002 21:33:31 -0000 1.4
@@ -19,6 +19,7 @@
import org.apache.commons.scaffold.lucene.Engine;
import org.apache.commons.scaffold.sql.StatementUtils;
+import org.apache.commons.scaffold.text.ConvertUtils;
import org.apache.commons.scaffold.util.ResourceUtils;
import org.apache.commons.scaffold.util.StorageBean;
@@ -95,6 +96,7 @@
* of properties, like Struts Actions).
* @todo Switch to CommandStore (or eliminate that object if not
* needed).
+ * @todo Add properties to manage optimistic locking
* @todo Change from BeanUtil.populate to copyProperties in 1.1
* version.
* @author Ted Husted
@@ -168,7 +170,7 @@
}
-// --------------------------------------------------------
+// ---------------------------------------- Base Properties
/**
@@ -257,6 +259,39 @@
}
+ /**
+ * The marked status of the record.
+ * <p>
+ * Records to be deleted are marked and may be
+ * restored before they are removed from the
+ * database.
+ * The default value is "0" - not marked.
+ */
+ private Short marked = ConvertUtils.SHORT_ZERO;
+
+
+ /**
+ * Return the marked status.
+ * <p>
+ * @return the marked status
+ */
+ public Short getMarked() {
+ return (this.marked);
+ }
+
+
+ /**
+ * Set the marked status.
+ * @param marked The new marked status
+ */
+ public void setMarked(Short marked) {
+ this.marked = marked;
+ }
+
+
+// ----------------------------------------------------- Public Methods
+
+
// See inteface for JavaDoc
public void populate(Map parameters) throws Exception {
@@ -293,8 +328,8 @@
// See inteface for JavaDoc
public boolean findElement(
Object target,
- Object key,
- String command) throws ResourceException {
+ String command,
+ Object key) throws ResourceException {
boolean found = false;
@@ -330,43 +365,40 @@
} // end findCollection
- /*
- // convenience method
+ /**
+ * Convenience method that calls
+ * <CODE>findCollection(Object,String,Object[])</CODE>
+ * with appropriate parameters.
+ */
public Collection findCollection(Object target,
String command) throws ResourceException {
- try {
-
- return StatementUtils.getCollection(null,
- target,getCommand(command));
-
- }
- catch (SQLException e) {
- throw new ResourceException(e);
- }
+ return findCollection(target,command,null);
} // end findCollection
- // convenience method
+
+ /**
+ * Convenience method that calls
+ * <CODE>findCollection(Object,String,Object[])</CODE>
+ * with appropriate parameters.
+ */
protected final Collection findCollection(Object target,
String command, Object parameter) throws ResourceException {
- try {
+ Object[] parameters = new Object[1];
+ parameters[0] = parameter;
- return StatementUtils.getCollection(null,
- target,getCommand(command),parameter);
-
- }
- catch (SQLException e) {
- throw new ResourceException(e);
- }
+ return findCollection(target,command,parameters);
} // end findCollection
- */
- /*
- // convenience method
+ /**
+ * Convenience method that calls
+ * <CODE>findCollection(Object,String,Object[])</CODE>
+ * with appropriate parameters.
+ */
protected final Collection findCollection(Object target,
String command, int parameter) throws ResourceException {
@@ -374,7 +406,6 @@
} // end findCollection
- */
// See inteface for JavaDoc
@@ -394,6 +425,7 @@
} // end findCollectionLike
+
// See inteface for JavaDoc
public Collection findByProperty(
Object target,
@@ -581,7 +613,7 @@
// see interface for Javadoc
public void retrieve() throws Exception {
- boolean found = findElement(this,getPrimaryKey(),RETRIEVE);
+ boolean found = findElement(this,RETRIEVE,getPrimaryKey());
if (found) {
@@ -608,7 +640,8 @@
int resultCode = getResultCode();
ProcessResult result = new ProcessResultBase(this);
- if (resultCode==0)
+ result.setSingleForm(true);
+ if (resultCode==0)
result.addMessage(Tokens.DATA_ACCESS_EMPTY);
else
result.addMessage(Tokens.DATA_RECORD_RETRIEVED);
@@ -662,6 +695,7 @@
int resultCode = getResultCode();
ProcessResult result = new ProcessResultBase(this);
+ result.setSingleForm(true);
if (resultCode==0)
result.addMessage(Tokens.DATA_ACCESS_EMPTY);
else
@@ -714,6 +748,7 @@
int resultCode = getResultCode();
ProcessResult result = new ProcessResultBase(this);
+ result.setSingleForm(true);
if (resultCode==0)
result.addMessage(Tokens.DATA_ACCESS_EMPTY);
else
1.2 +8 -3 jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/AccessBase.java
Index: AccessBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql/AccessBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AccessBase.java 14 Aug 2002 17:51:42 -0000 1.1
+++ AccessBase.java 20 Aug 2002 21:33:31 -0000 1.2
@@ -23,6 +23,7 @@
* @author Ted Husted
* @author OK State DEQ
* @version $Revision$ $Date$
+ * @deprecated Use StorageBean instead.
*/
public class AccessBase {
@@ -149,7 +150,11 @@
/**
* Retrieve entry from data storage.
- * <p>
+ * <P>
+ * <B>NOTE</B> that the key and command parameters to this utility
+ * should have been swapped for consistency with other
+ * methods in this package. But since this class is deprecated,
+ * a fix has not been made.
* @return Collection with record or empty collection
* @exception ResourceException if SQL error occurs
* @param key The primary key of the entry
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>