| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
package org.homeunix.thecave.buddi.plugin.api.model; |
| 5 | |
|
| 6 | |
import java.io.File; |
| 7 | |
import java.util.Date; |
| 8 | |
|
| 9 | |
import org.homeunix.thecave.buddi.model.Account; |
| 10 | |
import org.homeunix.thecave.buddi.model.AccountType; |
| 11 | |
import org.homeunix.thecave.buddi.model.BudgetCategory; |
| 12 | |
import org.homeunix.thecave.buddi.model.ScheduledTransaction; |
| 13 | |
import org.homeunix.thecave.buddi.model.Transaction; |
| 14 | |
import org.homeunix.thecave.buddi.model.TransactionSplit; |
| 15 | |
import org.homeunix.thecave.buddi.model.impl.ModelFactory; |
| 16 | |
import org.homeunix.thecave.buddi.plugin.api.exception.ModelException; |
| 17 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.ImmutableSplitImpl; |
| 18 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableAccountImpl; |
| 19 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableAccountTypeImpl; |
| 20 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableBudgetCategoryImpl; |
| 21 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableDocumentImpl; |
| 22 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableScheduledTransactionImpl; |
| 23 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableTransactionImpl; |
| 24 | |
import org.homeunix.thecave.buddi.plugin.api.model.impl.MutableTransactionSplitImpl; |
| 25 | |
import org.homeunix.thecave.buddi.util.OperationCancelledException; |
| 26 | |
|
| 27 | |
import ca.digitalcave.moss.application.document.exception.DocumentLoadException; |
| 28 | |
|
| 29 | 0 | public class MutableModelFactory { |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
public static MutableDocument createDocument() throws ModelException { |
| 36 | 0 | return new MutableDocumentImpl(ModelFactory.createDocument()); |
| 37 | |
} |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
public static MutableDocument createDocument(File file) throws DocumentLoadException, OperationCancelledException { |
| 47 | 0 | return new MutableDocumentImpl(ModelFactory.createDocument(file)); |
| 48 | |
} |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
public static MutableAccount createMutableAccount(String name, long startingBalance, MutableAccountType type) throws ModelException { |
| 59 | 0 | Account a = ModelFactory.createAccount(name, type.getType()); |
| 60 | 0 | a.setStartingBalance(startingBalance); |
| 61 | |
|
| 62 | 0 | return new MutableAccountImpl(a); |
| 63 | |
} |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
public static ImmutableSplit createImmutableSplit() throws ModelException { |
| 78 | 0 | return new ImmutableSplitImpl(ModelFactory.createSplit()); |
| 79 | |
} |
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
public static MutableAccountType createMutableAccountType(String name, boolean credit) throws ModelException { |
| 89 | 0 | AccountType t = ModelFactory.createAccountType(name, credit); |
| 90 | |
|
| 91 | 0 | return new MutableAccountTypeImpl(t); |
| 92 | |
} |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
public static MutableBudgetCategory createMutableBudgetCategory(String name, ImmutableBudgetCategoryType periodType, boolean isIncome) throws ModelException { |
| 103 | 0 | BudgetCategory bc = ModelFactory.createBudgetCategory(name, periodType.getBudgetCategoryType(), isIncome); |
| 104 | |
|
| 105 | 0 | return new MutableBudgetCategoryImpl(bc); |
| 106 | |
} |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
public static MutableScheduledTransaction createMutableScheduledTransaction(String name, String message, Date startDate, Date endDate, String frequencyType, int scheduleDay, int scheduleWeek, int scheduleMonth, Date date, String description, long amount, MutableSource from, MutableSource to) throws ModelException{ |
| 114 | 0 | ScheduledTransaction st = ModelFactory.createScheduledTransaction(name, message, startDate, endDate, frequencyType, scheduleDay, scheduleWeek, scheduleMonth, description, amount, from.getSource(), to.getSource()); |
| 115 | |
|
| 116 | 0 | return new MutableScheduledTransactionImpl(st); |
| 117 | |
} |
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
public static MutableTransaction createMutableTransaction(Date date, String description, long amount, MutableSource from, MutableSource to) throws ModelException { |
| 130 | 0 | Transaction t = ModelFactory.createTransaction(date, description, amount, from.getSource(), to.getSource()); |
| 131 | |
|
| 132 | 0 | return new MutableTransactionImpl(t); |
| 133 | |
} |
| 134 | |
|
| 135 | |
public static MutableTransactionSplit createMutableTransactionSplit(MutableSource source, long amount) throws ModelException { |
| 136 | 0 | TransactionSplit t = ModelFactory.createTransactionSplit(source.getSource(), amount); |
| 137 | 0 | return new MutableTransactionSplitImpl(t); |
| 138 | |
} |
| 139 | |
} |