Coverage Report - org.homeunix.thecave.buddi.plugin.api.model.impl.MutableTransactionImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
MutableTransactionImpl
0%
0/82
0%
0/18
1.432
 
 1  
 /*
 2  
  * Created on Aug 23, 2007 by wyatt
 3  
  */
 4  
 package org.homeunix.thecave.buddi.plugin.api.model.impl;
 5  
 
 6  
 import java.util.ArrayList;
 7  
 import java.util.Date;
 8  
 import java.util.List;
 9  
 
 10  
 import org.homeunix.thecave.buddi.model.Account;
 11  
 import org.homeunix.thecave.buddi.model.BudgetCategory;
 12  
 import org.homeunix.thecave.buddi.model.Split;
 13  
 import org.homeunix.thecave.buddi.model.Transaction;
 14  
 import org.homeunix.thecave.buddi.model.TransactionSplit;
 15  
 import org.homeunix.thecave.buddi.model.impl.WrapperLists;
 16  
 import org.homeunix.thecave.buddi.plugin.api.exception.InvalidValueException;
 17  
 import org.homeunix.thecave.buddi.plugin.api.model.ImmutableSource;
 18  
 import org.homeunix.thecave.buddi.plugin.api.model.ImmutableTransaction;
 19  
 import org.homeunix.thecave.buddi.plugin.api.model.ImmutableTransactionSplit;
 20  
 import org.homeunix.thecave.buddi.plugin.api.model.MutableSource;
 21  
 import org.homeunix.thecave.buddi.plugin.api.model.MutableTransaction;
 22  
 import org.homeunix.thecave.buddi.plugin.api.model.MutableTransactionSplit;
 23  
 
 24  0
 public class MutableTransactionImpl extends MutableModelObjectImpl implements MutableTransaction {
 25  
 
 26  
         public MutableTransactionImpl(Transaction transaction) {
 27  0
                 super(transaction);
 28  0
         }
 29  
         
 30  
         public Transaction getTransaction(){
 31  0
                 return (Transaction) getRaw();
 32  
         }
 33  
         
 34  
         public boolean isClearedFrom() {
 35  0
                 return getTransaction().isClearedFrom();
 36  
         }
 37  
         public boolean isClearedTo() {
 38  0
                 return getTransaction().isClearedTo();
 39  
         }
 40  
         public boolean isReconciledFrom() {
 41  0
                 return getTransaction().isReconciledFrom();
 42  
         }
 43  
         public boolean isReconciledTo() {
 44  0
                 return getTransaction().isReconciledTo();
 45  
         }
 46  
 
 47  
         public Date getDate() {
 48  0
                 return getTransaction().getDate();
 49  
         }
 50  
         public String getDescription() {
 51  0
                 return getTransaction().getDescription();
 52  
         }
 53  
         public String getMemo() {
 54  0
                 return getTransaction().getMemo();
 55  
         }
 56  
         public String getNumber() {
 57  0
                 return getTransaction().getNumber();
 58  
         }
 59  
         public boolean isScheduled() {
 60  0
                 return getTransaction().isScheduled();
 61  
         }
 62  
         public MutableSourceImpl getFrom(){
 63  0
                 if (getTransaction().getFrom() instanceof Account)
 64  0
                         return new MutableAccountImpl((Account) getTransaction().getFrom());
 65  0
                 if (getTransaction().getFrom() instanceof BudgetCategory)
 66  0
                         return new MutableBudgetCategoryImpl((BudgetCategory) getTransaction().getFrom());
 67  0
                 if (getTransaction().getFrom() instanceof Split)
 68  0
                         return new MutableSplitImpl((Split) getTransaction().getFrom());
 69  0
                 return null;
 70  
         }
 71  
         public MutableSourceImpl getTo(){
 72  0
                 if (getTransaction().getTo() instanceof Account)
 73  0
                         return new MutableAccountImpl((Account) getTransaction().getTo());
 74  0
                 if (getTransaction().getTo() instanceof BudgetCategory)
 75  0
                         return new MutableBudgetCategoryImpl((BudgetCategory) getTransaction().getTo());
 76  0
                 if (getTransaction().getTo() instanceof Split)
 77  0
                         return new MutableSplitImpl((Split) getTransaction().getTo());
 78  0
                 return null;
 79  
         }
 80  
         public List<ImmutableTransactionSplit> getImmutableFromSplits(){
 81  0
                 return new WrapperLists.ImmutableObjectWrapperList<ImmutableTransactionSplit, TransactionSplit>(getRaw().getDocument(), ((Transaction) getRaw()).getFromSplits());
 82  
         }
 83  
         public List<ImmutableTransactionSplit> getImmutableToSplits(){
 84  0
                 return new WrapperLists.ImmutableObjectWrapperList<ImmutableTransactionSplit, TransactionSplit>(getRaw().getDocument(), ((Transaction) getRaw()).getToSplits());
 85  
         }
 86  
         public long getBalance(ImmutableSource source) {
 87  0
                 return getTransaction().getBalance(source.getUid());
 88  
         }
 89  
         public boolean isInflow(){
 90  0
                 return getTransaction().isInflow();
 91  
         }
 92  
         public long getAmount(){
 93  0
                 return getTransaction().getAmount();
 94  
         }
 95  
         
 96  
         @Override
 97  
         public boolean equals(Object obj) {
 98  0
                 if (obj instanceof ImmutableTransaction)
 99  0
                         return getUid().equals(((ImmutableTransaction) obj).getUid());
 100  0
                 return false;
 101  
         }
 102  
 
 103  
         public void setAmount(long amount) {
 104  0
                 getTransaction().setAmount(amount);
 105  0
         }
 106  
 
 107  
         public void setClearedFrom(boolean cleared) throws InvalidValueException{
 108  0
                 getTransaction().setClearedFrom(cleared);
 109  0
         }
 110  
 
 111  
         public void setClearedTo(boolean cleared) throws InvalidValueException{
 112  0
                 getTransaction().setClearedTo(cleared);
 113  0
         }
 114  
 
 115  
         public void setDate(Date date) throws InvalidValueException{
 116  0
                 getTransaction().setDate(date);
 117  0
         }
 118  
 
 119  
         public void setDescription(String description) throws InvalidValueException{
 120  0
                 getTransaction().setDescription(description);
 121  0
         }
 122  
 
 123  
         public void setFrom(MutableSource from) throws InvalidValueException{
 124  0
                 if (from == null)
 125  0
                         getTransaction().setFrom(null);
 126  
                 else
 127  0
                         getTransaction().setFrom(from.getSource());
 128  0
         }
 129  
 
 130  
         public void setMemo(String memo) throws InvalidValueException{
 131  0
                 getTransaction().setMemo(memo);
 132  0
         }
 133  
 
 134  
         public void setNumber(String number) throws InvalidValueException{
 135  0
                 getTransaction().setNumber(number);
 136  0
         }
 137  
 
 138  
         public void setReconciledFrom(boolean reconciled) throws InvalidValueException{
 139  0
                 getTransaction().setReconciledFrom(reconciled);
 140  0
         }
 141  
 
 142  
         public void setReconciledTo(boolean reconciled) throws InvalidValueException{
 143  0
                 getTransaction().setReconciledTo(reconciled);
 144  0
         }
 145  
 
 146  
         public void setTo(MutableSource to) throws InvalidValueException{
 147  0
                 if (to == null)
 148  0
                         getTransaction().setTo(null);
 149  
                 else
 150  0
                         getTransaction().setTo(to.getSource());
 151  0
         }
 152  
         
 153  
         public void setScheduled(boolean scheduled) throws InvalidValueException{
 154  0
                 getTransaction().setScheduled(scheduled);
 155  0
         }
 156  
         
 157  
         public boolean isDeleted() {
 158  0
                 return getTransaction().isDeleted();
 159  
         }
 160  
         
 161  
         public void setDeleted(boolean deleted) throws InvalidValueException {
 162  0
                 getTransaction().setDeleted(deleted);
 163  0
         }
 164  
         
 165  
         public void addFromSplit(MutableTransactionSplit split) throws InvalidValueException {
 166  0
                 List<TransactionSplit> splits = new ArrayList<TransactionSplit>(getTransaction().getFromSplits());
 167  0
                 splits.add((TransactionSplit) split.getRaw());
 168  0
                 getTransaction().setFromSplits(splits);
 169  0
         }
 170  
         
 171  
         public void removeFromSplit(MutableTransactionSplit split) throws InvalidValueException {
 172  0
                 List<TransactionSplit> splits = new ArrayList<TransactionSplit>(getTransaction().getFromSplits());
 173  0
                 splits.remove(split.getRaw());
 174  0
                 getTransaction().setFromSplits(splits);                
 175  0
         }
 176  
         public void addToSplit(MutableTransactionSplit split) throws InvalidValueException {
 177  0
                 List<TransactionSplit> splits = new ArrayList<TransactionSplit>(getTransaction().getToSplits());
 178  0
                 splits.add((TransactionSplit) split.getRaw());
 179  0
                 getTransaction().setToSplits(splits);
 180  0
         }
 181  
         
 182  
         public void removeToSplit(MutableTransactionSplit split) throws InvalidValueException {
 183  0
                 List<TransactionSplit> splits = new ArrayList<TransactionSplit>(getTransaction().getToSplits());
 184  0
                 splits.remove(split.getRaw());
 185  0
                 getTransaction().setToSplits(splits);                
 186  0
         }
 187  
 }