sync
[Bookkeeping.git] / src / com / interrupt / bookkeeping / action / RemoveAction.java
blob9883398f1749158208a3763452c9173e7d4f7019
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.bookkeeping.account.IDebit;
10 import com.interrupt.bookkeeping.account.GDebit;
11 import com.interrupt.bookkeeping.account.ICredit;
12 import com.interrupt.bookkeeping.account.GCredit;
13 import com.interrupt.bookkeeping.account.IAccount;
14 import com.interrupt.bookkeeping.account.IAccounts;
15 import com.interrupt.bookkeeping.account.Accounts;
16 import com.interrupt.bookkeeping.cc.bkell.Bkell;
17 import com.interrupt.bookkeeping.journal.Transaction;
18 import com.interrupt.bookkeeping.journal.Entry;
19 import com.interrupt.bookkeeping.exception.EntryException;
20 import com.interrupt.bookkeeping.exception.AccountException;
21 import com.interrupt.bookkeeping.exception.WorkflowException;
22 import com.interrupt.bookkeeping.users.User;
23 import com.interrupt.bookkeeping.util.Util;
24 import com.interrupt.bookkeeping.workflow.StateManager;
25 import com.interrupt.bob.base.IBob;
26 import com.interrupt.bob.base.IVisitor;
28 public class RemoveAction extends AbstractAction implements IVisitor {
31 private Logger logger = Logger.getLogger(RemoveAction.class);
32 public void execute(IBob ibob, User user) {
34 super.execute(ibob, user);
35 ibob.accept(this);
38 public void visit(IBob bob) throws WorkflowException {
40 logger.debug("RemoveAction:visiting: ["+bob.getClass()+"]");
41 String svalue = (bob.getAttributes()).getValue("state");
42 if(svalue == null) {
43 //throw new WorkflowException("cannot find 'state' attribute");
44 return;
46 if(!svalue.equals(Util.CLOSED_STATE)) {
47 throw new WorkflowException("state of ["+bob.getClass()+"] must be 'CLOSED'");
50 StateManager smanager = new StateManager();
51 smanager.transition(bob,Util.REMOVED_STATE);