-- added fancybox 1.3.1 to project, initially for showing screenshots. See documentat...
[Bookkeeping.git] / src / com / interrupt / bookkeeping / action / ReverseAction.java
blobba9b93f5e33a38b0d8807f198fdbea844e5499b7
2 package com.interrupt.bookkeeping.action;
4 import java.util.List;
5 import java.util.Iterator;
7 import org.apache.log4j.Logger;
9 import com.interrupt.bob.base.BobSystem;
11 import com.interrupt.bookkeeping.account.IDebit;
12 import com.interrupt.bookkeeping.account.GDebit;
13 import com.interrupt.bookkeeping.account.ICredit;
14 import com.interrupt.bookkeeping.account.GCredit;
15 import com.interrupt.bookkeeping.account.IAccount;
16 import com.interrupt.bookkeeping.account.IAccounts;
17 import com.interrupt.bookkeeping.account.Accounts;
18 import com.interrupt.bookkeeping.journal.IEntry;
19 import com.interrupt.bookkeeping.journal.Transaction;
20 import com.interrupt.bookkeeping.journal.Entry;
21 import com.interrupt.bookkeeping.exception.EntryException;
22 import com.interrupt.bookkeeping.exception.AccountException;
23 import com.interrupt.bookkeeping.exception.WorkflowException;
24 import com.interrupt.bookkeeping.users.User;
25 import com.interrupt.bookkeeping.util.Util;
26 import com.interrupt.bookkeeping.workflow.StateManager;
27 import com.interrupt.bob.base.IBob;
28 import com.interrupt.bob.base.IVisitor;
30 public class ReverseAction extends AbstractAction implements IVisitor {
33 private Logger logger = Logger.getLogger(ReverseAction.class);
34 public void execute(IBob ibob, User user) {
36 super.execute(ibob, user);
37 ibob.accept(this);
40 public void visit(IBob bob) throws WorkflowException {
42 logger.debug("ReverseAction:visiting: ["+bob.getClass()+"]");
43 IEntry entry = null;
44 try {
46 entry = (IEntry)bob;
47 String svalue = entry.getState();
48 if(svalue == null) {
49 throw new WorkflowException("'state' value is NULL");
51 if(!svalue.equals(Util.CLOSED_STATE)) {
52 throw new WorkflowException("state of Entry["+entry.getId()+"] must be 'CLOSED' / ["+entry.getState()+"]");
55 StateManager smanager = new StateManager();
56 smanager.transition(entry,Util.REVERSED_STATE);
59 catch(ClassCastException e) {
61 // not a real error; we can only reverse <entry/>
62 //throw e;