fixing bookkeeping to add a user to the system instead of a 'users' block
[Bookkeeping.git] / src / com / interrupt / bookkeeping / cc / bkell / command / AddCommand.java
blob51b9582f77d3f4d8c4c19c80b1a268530c91d85b
1 package com.interrupt.bookkeeping.cc.bkell.command;
4 import java.util.List;
5 import java.util.Iterator;
7 import org.apache.log4j.Logger;
9 import com.interrupt.bookkeeping.journal.Journal;
11 import com.interrupt.bob.base.IBob;
12 import com.interrupt.bob.util.Util;
13 import com.interrupt.bookkeeping.cc.ExpressionVisitor;
14 import com.interrupt.bookkeeping.cc.bkell.command.ITokenLiterals;
15 import com.interrupt.bookkeeping.cc.bkell.command.IResult;
16 import com.interrupt.bookkeeping.cc.bkell.command.GResult;
17 import com.interrupt.bookkeeping.exception.CommandException;
18 import com.interrupt.bookkeeping.journal.IEntry;
19 import com.interrupt.bookkeeping.journal.IJournal;
20 import com.interrupt.bookkeeping.users.IUser;
22 public class AddCommand extends AddRemoveReverseCommon {
25 private Logger logger = Logger.getLogger(AddCommand.class);
27 public AddCommand() {
29 super();
30 this.setName("add");
34 /* execute this command, add the 'token.literals' to the 'token.reciever'
36 public IResult execute(IUser user) {
38 logger.debug("AddCommand.execute: "+ this.toXML(false));
39 super.execute(user);
41 IBob treciever = this.getTokenReciever();
43 ITokenLiterals tliterals = this.getTokenLiterals();
44 List allLiterals = tliterals.allChildren();
45 Iterator titer = allLiterals.iterator();
46 IBob eachLiteral = null;
47 while( titer.hasNext() ) {
49 eachLiteral = (IBob)titer.next();
51 Class defParams[] = { eachLiteral.getClass() };
52 IBob methParams[] = { eachLiteral };
54 logger.debug("adding >> treceiver["+treciever.getClass()+" / "+treciever+"] / token["+eachLiteral.getClass()+" / "+eachLiteral.getTagName()
55 +"] / defParams["+defParams+"] / methParams["+methParams+"]");
56 Util.evalReflectedAdd(treciever, eachLiteral.getTagName(), defParams, methParams);
60 //** TODO - update treciever into DB
63 IResult result = new GResult();
64 result.addChild(treciever);
66 return result;