sync
[Bookkeeping.git] / src / com / interrupt / bookkeeping / cc / executor / LoadHelper.java
blob1bbae94fbf51a0ee4d5dd439bed04eead5aaa79b
1 package com.interrupt.bookkeeping.cc.executor;
4 import org.apache.log4j.Logger;
6 import com.interrupt.bob.base.Bob;
7 import com.interrupt.bob.base.IBob;
8 import com.interrupt.bookkeeping.cc.CommandOptionVisitor;
9 import com.interrupt.bookkeeping.cc.ExpressionVisitor;
10 import com.interrupt.bookkeeping.cc.bkell.Bkell;
11 import com.interrupt.bookkeeping.cc.bkell.aauth.Aauthentication;
12 import com.interrupt.bookkeeping.cc.bkell.command.IResult;
13 import com.interrupt.bookkeeping.cc.bkell.command.LoadCommand;
14 import com.interrupt.bookkeeping.cc.node.AOptsCommandInput;
15 import com.interrupt.bookkeeping.cc.node.AXmlCommandInput;
16 import com.interrupt.bookkeeping.cc.node.AXpathCommandInput;
17 import com.interrupt.bookkeeping.users.IUser;
18 import com.interrupt.bookkeeping.users.User;
19 import com.interrupt.bookkeeping.util.Util;
21 public class LoadHelper extends AbstractHelper {
24 private Logger logger = Logger.getLogger(LoadHelper.class);
25 public static IResult execute(IUser user, LoadCommand loadCommand, AXmlCommandInput cinput) {
27 String cinput_s = cinput.toString();
29 /** filter XML to get rid of spaces
31 String input_3 = Util.filterSpacesFromXML(cinput_s);
32 Logger.getLogger(LoadHelper.class).debug("LoadHelper / CommandInput / XML["+input_3+"]"); //** generate token, option, input
33 Logger.getLogger(LoadHelper.class).debug(loadCommand.toXML(false));
35 // setup command
36 Bob bob = new Bob();
37 IBob created = bob.load( input_3, "xml/bookkeeping.system.xml" );
38 loadCommand.addTokenLiteral(created);
40 // execute command
41 IResult result = loadCommand.execute(user);
42 return result;
44 public static IResult execute(IUser user, LoadCommand loadCommand, AOptsCommandInput cinput) {
46 CommandOptionVisitor covisitor = new CommandOptionVisitor();
47 covisitor.setCommand(loadCommand);
48 cinput.apply(covisitor);
50 // execute command
51 Logger.getLogger(LoadHelper.class).debug(loadCommand);
53 IResult result = loadCommand.execute(user);
54 return result;
56 public static IResult execute(IUser user, LoadCommand loadCommand, AXpathCommandInput cinput) {
58 IResult result = loadCommand.execute(user);
59 return result;
63 public static void main(String args[]) {
65 LoadHelper.reparse("<debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' />");