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/11/13 13:45:44 UTC
cvs commit: jakarta-commons-sandbox/scaffold/src/java/org/apache/commons/scaffold/sql StorageBeanBase.java
husted 2002/11/13 04:45:44
Modified: scaffold/src/java/org/apache/commons/scaffold/sql
StorageBeanBase.java
Log:
+ Storable, StorageBeanBase: Change "primaryKey" to "storageKey"
Revision Changes Path
1.13 +33 -16 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- StorageBeanBase.java 4 Nov 2002 23:28:51 -0000 1.12
+++ StorageBeanBase.java 13 Nov 2002 12:45:44 -0000 1.13
@@ -42,7 +42,7 @@
* <LI>Declare a subclass adding the properties to be stored.
* <LI>Provide in a set of standard SQL queries naming the properties
* to be stored as columns in the command
- * <LI>Override <code>getPrimaryKey</code> to return the property used
+ * <LI>Override <code>getStorageKey</code> to return the property used
* as the primary or unique key in the SQL commands.
* <LI>Override <code>getParameters</code> to return an array of
* properties as needed by object's insert and update SQL commands.
@@ -106,6 +106,23 @@
public class StorageBeanBase extends ProcessBeanBase implements StorageBean {
+ /**
+ * Convenience method to check for null, empty String,
+ * or "0" String.
+ */
+ protected boolean blank(String s) {
+ return ConvertUtils.blank(s);
+ }
+
+
+ /**
+ * Returns true if null or zero.
+ */
+ public static boolean blank(Number key) {
+ return ConvertUtils.blank(key);
+ }
+
+
// ------------------------------------------------------------------ Commands
// TODO: Refactor this to use a CommandStore
@@ -521,13 +538,13 @@
// See interface for JavaDoc
- public Object getPrimaryKey() {
+ public Object getStorageKey() {
return this.primaryKey;
}
// See interface for JavaDoc
- public void setPrimaryKey(Object primaryKey) {
+ public void setStorageKey(Object primaryKey) {
this.primaryKey = primaryKey;
}
@@ -685,7 +702,7 @@
// See interface for JavaDoc
public boolean isNew() {
- return (null==getPrimaryKey());
+ return (null==getStorageKey());
}
@@ -719,7 +736,7 @@
// See interface for JavaDoc
public void allocateKey() throws Exception {
- setPrimaryKey(createKey(TABLE));
+ setStorageKey(createKey(TABLE));
}
@@ -774,7 +791,7 @@
populate((Map) parameters);
String message = Tokens.DATA_RECORD_UPDATED;
- if (null==getPrimaryKey()) {
+ if (null==getStorageKey()) {
message = Tokens.DATA_RECORD_INSERTED;
}
@@ -782,7 +799,7 @@
ProcessResult result = new ProcessResultBase(getResult());
result.addMessage(message);
- result.addMessage(getPrimaryKey());
+ result.addMessage(getStorageKey());
result.setSingleForm(true);
return result;
}
@@ -793,7 +810,7 @@
// see interface for Javadoc
public void retrieve() throws Exception {
- boolean found = findElement(this,RETRIEVE,getPrimaryKey());
+ boolean found = findElement(this,RETRIEVE,getStorageKey());
if (found) {
@@ -811,7 +828,7 @@
public Object retrieve(Object parameters) throws Exception {
populate((Map) parameters);
- Object key = getPrimaryKey();
+ Object key = getStorageKey();
if (null==key) {
throw new ParameterException();
}
@@ -849,7 +866,7 @@
// Mark as deleted
result = StatementUtils.executeUpdate(null,
- lookup(DELETE),getPrimaryKey());
+ lookup(DELETE),getStorageKey());
}
catch (SQLException e) {
@@ -868,7 +885,7 @@
public Object delete(Object parameters) throws Exception {
populate((Map) parameters);
- Object key = getPrimaryKey();
+ Object key = getStorageKey();
if (null==key) {
throw new ParameterException();
}
@@ -906,7 +923,7 @@
// Mark as recycled
result = StatementUtils.executeUpdate(null,
- lookup(RECYCLE),getPrimaryKey());
+ lookup(RECYCLE),getStorageKey());
}
catch (SQLException e) {
@@ -923,7 +940,7 @@
public Object recycle(Object parameters) throws Exception {
populate((Map) parameters);
- Object key = getPrimaryKey();
+ Object key = getStorageKey();
if (null==key) {
throw new ParameterException();
}
@@ -964,7 +981,7 @@
try {
result = StatementUtils.executeUpdate(null,
- lookup(RESTORE),getPrimaryKey());
+ lookup(RESTORE),getStorageKey());
}
catch (SQLException e) {
@@ -988,7 +1005,7 @@
public Object restore(Object parameters) throws Exception {
populate((Map) parameters);
- Object key = getPrimaryKey();
+ Object key = getStorageKey();
if (null==key) {
throw new ParameterException();
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>