001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com> and
003: * JR Boyens <gnu-jrb[remove] at gmx dot net>
004: * Distributed under the terms of either:
005: * - the common development and distribution license (CDDL), v1.0; or
006: * - the GNU Lesser General Public License, v2.1 or later
007: * $Id: CallbacksSparseBean.java 3634 2007-01-08 21:42:24Z gbevin $
008: */
009: package com.uwyn.rife.database.querymanagers.generic.beans;
010:
011: import com.uwyn.rife.database.querymanagers.generic.Callbacks;
012: import com.uwyn.rife.database.querymanagers.generic.beans.CallbacksSparseBean;
013: import com.uwyn.rife.site.ConstrainedProperty;
014: import com.uwyn.rife.site.Validation;
015: import java.util.ArrayList;
016: import java.util.List;
017:
018: public class CallbacksSparseBean extends Validation implements
019: Callbacks<CallbacksSparseBean> {
020: private int mId = -1;
021: private String mTestString = null;
022:
023: private List<String> mExecutedCallbacks = new ArrayList<String>();
024:
025: private boolean mBeforeValidateReturn = true;
026: private boolean mBeforeInsertReturn = true;
027: private boolean mBeforeDeleteReturn = true;
028: private boolean mBeforeSaveReturn = true;
029: private boolean mBeforeUpdateReturn = true;
030: private boolean mAfterValidateReturn = true;
031: private boolean mAfterInsertReturn = true;
032: private boolean mAfterDeleteReturn = true;
033: private boolean mAfterSaveReturn = true;
034: private boolean mAfterUpdateReturn = true;
035: private boolean mAfterRestoreReturn = true;
036:
037: public void activateValidation() {
038: addConstraint(new ConstrainedProperty("id").identifier(true)
039: .sparse(true));
040: }
041:
042: public void setId(int id) {
043: mId = id;
044: }
045:
046: public int getId() {
047: return mId;
048: }
049:
050: public void setTestString(String testString) {
051: this .mTestString = testString;
052: }
053:
054: public String getTestString() {
055: return mTestString;
056: }
057:
058: public String toString() {
059: return mId + ";" + mTestString;
060: }
061:
062: public List<String> getExecutedCallbacks() {
063: return mExecutedCallbacks;
064: }
065:
066: public void clearExecuteCallbacks() {
067: mExecutedCallbacks = new ArrayList<String>();
068: }
069:
070: public void setBeforeValidateReturn(boolean beforeValidateReturn) {
071: mBeforeValidateReturn = beforeValidateReturn;
072: }
073:
074: public void setBeforeInsertReturn(boolean beforeInsertReturn) {
075: mBeforeInsertReturn = beforeInsertReturn;
076: }
077:
078: public void setBeforeDeleteReturn(boolean beforeDeleteReturn) {
079: mBeforeDeleteReturn = beforeDeleteReturn;
080: }
081:
082: public void setBeforeSaveReturn(boolean beforeSaveReturn) {
083: mBeforeSaveReturn = beforeSaveReturn;
084: }
085:
086: public void setBeforeUpdateReturn(boolean beforeUpdateReturn) {
087: mBeforeUpdateReturn = beforeUpdateReturn;
088: }
089:
090: public void setAfterValidateReturn(boolean afterValidateReturn) {
091: mAfterValidateReturn = afterValidateReturn;
092: }
093:
094: public void setAfterInsertReturn(boolean afterInsertReturn) {
095: mAfterInsertReturn = afterInsertReturn;
096: }
097:
098: public void setAfterDeleteReturn(boolean afterDeleteReturn) {
099: mAfterDeleteReturn = afterDeleteReturn;
100: }
101:
102: public void setAfterSaveReturn(boolean afterSaveReturn) {
103: mAfterSaveReturn = afterSaveReturn;
104: }
105:
106: public void setAfterUpdateReturn(boolean afterUpdateReturn) {
107: mAfterUpdateReturn = afterUpdateReturn;
108: }
109:
110: public void setAfterRestoreReturn(boolean afterRestoreReturn) {
111: mAfterRestoreReturn = afterRestoreReturn;
112: }
113:
114: public boolean beforeValidate(CallbacksSparseBean object) {
115: mExecutedCallbacks.add("beforeValidate " + object.toString());
116: return mBeforeValidateReturn;
117: }
118:
119: public boolean beforeInsert(CallbacksSparseBean object) {
120: mExecutedCallbacks.add("beforeInsert " + object.toString());
121: return mBeforeInsertReturn;
122: }
123:
124: public boolean beforeDelete(int objectId) {
125: mExecutedCallbacks.add("beforeDelete " + objectId);
126: return mBeforeDeleteReturn;
127: }
128:
129: public boolean beforeSave(CallbacksSparseBean object) {
130: mExecutedCallbacks.add("beforeSave " + object.toString());
131: return mBeforeSaveReturn;
132: }
133:
134: public boolean beforeUpdate(CallbacksSparseBean object) {
135: mExecutedCallbacks.add("beforeUpdate " + object.toString());
136: return mBeforeUpdateReturn;
137: }
138:
139: public boolean afterValidate(CallbacksSparseBean object) {
140: mExecutedCallbacks.add("afterValidate " + object.toString());
141: return mAfterValidateReturn;
142: }
143:
144: public boolean afterInsert(CallbacksSparseBean object,
145: boolean success) {
146: mExecutedCallbacks.add("afterInsert " + success + " "
147: + object.toString());
148: return mAfterInsertReturn;
149: }
150:
151: public boolean afterDelete(int objectId, boolean success) {
152: mExecutedCallbacks.add("afterDelete " + success + " "
153: + objectId);
154: return mAfterDeleteReturn;
155: }
156:
157: public boolean afterSave(CallbacksSparseBean object, boolean success) {
158: mExecutedCallbacks.add("afterSave " + success + " "
159: + object.toString());
160: return mAfterSaveReturn;
161: }
162:
163: public boolean afterUpdate(CallbacksSparseBean object,
164: boolean success) {
165: mExecutedCallbacks.add("afterUpdate " + success + " "
166: + object.toString());
167: return mAfterUpdateReturn;
168: }
169:
170: public boolean afterRestore(CallbacksSparseBean object) {
171: mExecutedCallbacks.add("afterRestore " + object.toString());
172: return mAfterRestoreReturn;
173: }
174: }
|