|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjgnash.engine.Engine
public class Engine
Engine class
When objects are removed, they are wrapped in a TrashObject so they may still be referenced for messaging and cleanup operations. After a predefined period of time, they are permanently removed.
| Field Summary | |
|---|---|
private java.util.concurrent.locks.ReentrantReadWriteLock |
accountLock
|
private java.lang.String |
accountSeparator
Cached for performance |
private java.util.concurrent.locks.ReentrantReadWriteLock |
commodityLock
|
private Config |
config
Cached for performance |
private java.util.concurrent.locks.ReentrantReadWriteLock |
configLock
|
static float |
CURRENT_VERSION
Current version for the file format |
private EngineDAO |
eDAO
|
private java.util.concurrent.locks.ReentrantReadWriteLock |
engineLock
|
private ExchangeRateDAO |
exchangeRateDAO
|
private java.util.logging.Logger |
logger
|
private static long |
MAXIMUM_TRASH_AGE
|
private static java.math.MathContext |
mc
|
private MessageBus |
messageBus
All engine instances will share the same message bus |
private java.lang.String |
name
Named identifier for this engine instance |
private Resource |
rb
|
private RootAccount |
rootAccount
Cached for performance |
private static java.math.RoundingMode |
roundingMode
|
private java.util.concurrent.ScheduledExecutorService |
trashExecutor
|
private java.lang.String |
uuid
Unique identifier for this engine instance |
| Constructor Summary | |
|---|---|
Engine(EngineDAO eDAO,
java.lang.String name)
|
|
| Method Summary | |
|---|---|
boolean |
addAccount(Account parent,
Account child)
Adds a new account |
private boolean |
addAccountSecurity(Account account,
SecurityNode node)
Adds a SecurityNode from a InvestmentAccount |
boolean |
addCommodity(CommodityNode node)
|
boolean |
addReminder(Reminder reminder)
|
boolean |
addSecurityHistory(SecurityNode node,
SecurityHistoryNode hNode)
Add a SecurityHistoryNode node to a SecurityNode |
boolean |
addTransaction(Transaction transaction)
|
(package private) static java.lang.String |
buildExchangeRateId(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency)
|
private void |
checkAndCorrect()
Corrects minor issues with a database that may occur because of prior bugs |
private void |
clearCachedAccountBalance(Account account)
Clears an Accounts cached balance and recursively works up the tree to the root. |
private void |
clearCachedAccountBalance(SecurityNode node)
Forces all investment accounts containing the security to clear the cached account balance and reconciled account balance and recalculate when queried. |
private void |
clearObsoleteExchangeRates()
|
private void |
emptyTrash()
Empty the trash if any objects are older than the defined time |
Account |
getAccountByName(java.lang.String accountName)
Search for an account with a matching account number |
Account |
getAccountByUuid(java.lang.String id)
|
private AccountDAO |
getAccountDAO()
|
java.util.List<Account> |
getAccountList()
Returns a list of all Accounts excluding the rootAccount |
java.lang.String |
getAccountSeparator()
|
java.util.Set<CurrencyNode> |
getActiveCurrencies()
Returns an array of currencies being used in accounts |
java.util.List<Account> |
getBankAccountList()
Returns a list of all accounts excluding the rootAccount and IncomeAccounts and ExpenseAccounts |
(package private) CurrencyNode[] |
getBaseCurrencies(java.lang.String exchangeRateId)
|
private CommodityDAO |
getCommodityDAO()
|
private Config |
getConfig()
|
private ConfigDAO |
getConfigDAO()
|
static java.math.MathContext |
getContext()
|
java.util.List<CurrencyNode> |
getCurrencies()
|
CurrencyNode |
getCurrency(java.lang.String symbol)
Returns a CurrencyNode given the symbol. |
CurrencyNode |
getCurrency(java.lang.String symbol,
java.util.Locale locale)
Returns a CurrencyNode given the symbol and Locale. |
CurrencyNode |
getDefaultCurrency()
|
ExchangeRate |
getExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency)
|
java.util.List<Account> |
getExpenseAccountList()
Returns a list of ExpenseAccounts excluding the rootExpenseAccount |
java.util.List<Account> |
getIncomeAccountList()
Returns a list of IncomeAccounts excluding the rootIncomeAccount |
java.util.List<Account> |
getInvestmentAccountList()
Returns a list of all accounts excluding the rootAccount and IncomeAccounts and ExpenseAccounts |
java.util.Set<Account> |
getInvestmentAccountList(SecurityNode node)
Returns a list of investment accounts that use the given security node |
static java.math.BigDecimal |
getMarketPrice(java.util.Collection<Transaction> transactions,
SecurityNode node,
CurrencyNode baseCurrency,
java.util.Date date)
|
java.lang.String |
getName()
|
java.util.List<PendingReminder> |
getPendingReminders()
|
private RecurringDAO |
getReminderDAO()
|
java.util.List<Reminder> |
getReminders()
Returns a list of reminders |
RootAccount |
getRootAccount()
Return the root account |
static java.math.RoundingMode |
getRoundingMode()
|
java.util.List<SecurityNode> |
getSecurities()
|
SecurityNode |
getSecurity(java.lang.String symbol)
Find a SecurityNode given it's symbol |
java.util.List<SecurityHistoryNode> |
getSecurityHistory(SecurityNode node)
|
StoredObject |
getStoredObjectByUuid(java.lang.String id)
|
java.util.Collection<StoredObject> |
getStoredObjects()
Returns a Collection of all StoredObjects in a consistent order. |
private TransactionDAO |
getTransactionDAO()
|
java.util.List<java.lang.String> |
getTransactionNumberList()
|
java.util.List<Transaction> |
getTransactions()
Get all transactions |
private TrashDAO |
getTrashDAO()
|
java.lang.String |
getUuid()
Returns the unique identifier for this engine instance |
private void |
initialize()
Creates a RootAccount and default currency only if necessary |
private boolean |
isCommodityNodeUsed(CommodityNode node)
|
private boolean |
isCommodityNodeValid(CommodityNode node)
Validate a CommodityNode for correctness |
boolean |
isStored(StoredObject object)
Determine if a StoredObject is persisted in the database |
boolean |
isTransactionValid(Transaction transaction)
|
private void |
logInfo(java.lang.String message)
Log a informational message |
private void |
logSevere(java.lang.String message)
Log a severe message |
private void |
logWarning(java.lang.String message)
Log a warning message |
boolean |
modifyAccount(Account template,
Account account)
Modifies an existing account given an account as a template. |
boolean |
moveAccount(Account account,
Account newParent)
Move an account to a new parent account |
private void |
moveObjectToTrash(StoredObject object)
|
private void |
postTransactionAdd(Transaction transaction,
boolean result)
|
private void |
postTransactionRemove(Transaction transaction,
boolean result)
|
void |
refreshAccount(Account account)
|
void |
refreshCommodity(CommodityNode node)
|
void |
refreshExchangeRate(ExchangeRate rate)
|
void |
refreshReminder(Reminder reminder)
|
void |
refreshTransaction(Transaction transaction)
|
boolean |
removeAccount(Account account)
Removes an existing account given it's ID. |
private boolean |
removeAccountSecurity(Account account,
SecurityNode node)
Removes a SecurityNode from an InvestmentAccount |
boolean |
removeCommodity(CommodityNode node)
|
private void |
removeExchangeRate(ExchangeRate rate)
|
void |
removeExchangeRateHistory(ExchangeRate exchangeRate,
ExchangeRateHistoryNode history)
|
boolean |
removeReminder(Reminder reminder)
|
boolean |
removeSecurityHistory(SecurityNode node,
SecurityHistoryNode hNode)
|
boolean |
removeTransaction(Transaction transaction)
|
void |
setAccountNumber(Account account,
java.lang.String number)
Sets the account number of an account |
void |
setAccountSeparator(java.lang.String separator)
|
boolean |
setAmortizeObject(Account account,
AmortizeObject amortizeObject)
Sets the amortize object of an account |
void |
setDefaultCurrency(CurrencyNode defaultCurrency)
|
void |
setExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency,
java.math.BigDecimal rate)
|
void |
setExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency,
java.math.BigDecimal rate,
java.util.Date date)
|
void |
setTransactionNumberList(java.util.List<java.lang.String> list)
|
void |
setTransactionReconciled(Transaction transaction,
Account account,
ReconciledState state)
Changes the reconciled state of a transaction |
(package private) void |
shutdown()
|
boolean |
toggleAccountVisibility(Account account)
Toggles the visibility of an account given its ID. |
boolean |
updateAccountSecurities(Account acc,
java.util.Collection<SecurityNode> list)
Update an account's securities list. |
boolean |
updateCommodity(CommodityNode oldNode,
CommodityNode templateNode)
Modifies an existing currency node in place. |
void |
updateReminder(Reminder reminder)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float CURRENT_VERSION
private static final java.math.RoundingMode roundingMode
private static final java.math.MathContext mc
private final Resource rb
private final java.util.logging.Logger logger
private MessageBus messageBus
private Config config
private RootAccount rootAccount
private ExchangeRateDAO exchangeRateDAO
private final java.util.concurrent.locks.ReentrantReadWriteLock accountLock
private final java.util.concurrent.locks.ReentrantReadWriteLock commodityLock
private final java.util.concurrent.locks.ReentrantReadWriteLock configLock
private final java.util.concurrent.locks.ReentrantReadWriteLock engineLock
private EngineDAO eDAO
private java.lang.String accountSeparator
private java.util.concurrent.ScheduledExecutorService trashExecutor
private static final long MAXIMUM_TRASH_AGE
private final java.lang.String name
private final java.lang.String uuid
| Constructor Detail |
|---|
public Engine(EngineDAO eDAO,
java.lang.String name)
| Method Detail |
|---|
private void initialize()
private void checkAndCorrect()
private void clearObsoleteExchangeRates()
private void removeExchangeRate(ExchangeRate rate)
void shutdown()
public java.lang.String getName()
public static java.math.MathContext getContext()
public static java.math.RoundingMode getRoundingMode()
private AccountDAO getAccountDAO()
private CommodityDAO getCommodityDAO()
private ConfigDAO getConfigDAO()
private RecurringDAO getReminderDAO()
private TransactionDAO getTransactionDAO()
private TrashDAO getTrashDAO()
private void moveObjectToTrash(StoredObject object)
private void emptyTrash()
public boolean addReminder(Reminder reminder)
public boolean removeReminder(Reminder reminder)
public java.util.List<Reminder> getReminders()
public java.util.List<PendingReminder> getPendingReminders()
public StoredObject getStoredObjectByUuid(java.lang.String id)
public java.util.Collection<StoredObject> getStoredObjects()
Collection of all StoredObjects in a consistent order.
StoredObjects marked for removal are filtered from the collection.
Collection of StoredObjectsCollection,
StoredObjectComparatorprivate boolean isCommodityNodeValid(CommodityNode node)
node - CommodityNode to validate
public boolean addCommodity(CommodityNode node)
public boolean addSecurityHistory(SecurityNode node,
SecurityHistoryNode hNode)
node - SecurityNode to add tohNode - SecurityHistoryNode to add
public java.util.Set<Account> getInvestmentAccountList(SecurityNode node)
node - security node
public static java.math.BigDecimal getMarketPrice(java.util.Collection<Transaction> transactions,
SecurityNode node,
CurrencyNode baseCurrency,
java.util.Date date)
private void clearCachedAccountBalance(SecurityNode node)
node - SecurityNode that was changedprivate void clearCachedAccountBalance(Account account)
Accounts cached balance and recursively works up the tree to the root.
account - Account to clear
static java.lang.String buildExchangeRateId(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency)
CurrencyNode[] getBaseCurrencies(java.lang.String exchangeRateId)
public java.util.Set<CurrencyNode> getActiveCurrencies()
public CurrencyNode getCurrency(java.lang.String symbol,
java.util.Locale locale)
symbol - Currency symbollocale - Currency Locale
public CurrencyNode getCurrency(java.lang.String symbol)
getCurrencyNode(String symbol, Locale locale) is the preferred method of obtaining an established
currency
symbol - Currency symbol
public java.util.List<CurrencyNode> getCurrencies()
public java.util.List<SecurityHistoryNode> getSecurityHistory(SecurityNode node)
public ExchangeRate getExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency)
public java.util.List<SecurityNode> getSecurities()
public SecurityNode getSecurity(java.lang.String symbol)
symbol - symbol of security to find
private boolean isCommodityNodeUsed(CommodityNode node)
public boolean removeCommodity(CommodityNode node)
public boolean removeSecurityHistory(SecurityNode node,
SecurityHistoryNode hNode)
public void setDefaultCurrency(CurrencyNode defaultCurrency)
private Config getConfig()
public CurrencyNode getDefaultCurrency()
public void setExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency,
java.math.BigDecimal rate)
public void setExchangeRate(CurrencyNode baseCurrency,
CurrencyNode exchangeCurrency,
java.math.BigDecimal rate,
java.util.Date date)
public void removeExchangeRateHistory(ExchangeRate exchangeRate,
ExchangeRateHistoryNode history)
public boolean updateCommodity(CommodityNode oldNode,
CommodityNode templateNode)
oldNode - old CommodityNodetemplateNode - template CommodityNode
public void updateReminder(Reminder reminder)
private void logInfo(java.lang.String message)
message - message to displayprivate void logWarning(java.lang.String message)
message - message to displayprivate void logSevere(java.lang.String message)
message - message to displaypublic void setAccountSeparator(java.lang.String separator)
public java.lang.String getAccountSeparator()
public java.util.List<Account> getAccountList()
public Account getAccountByUuid(java.lang.String id)
public Account getAccountByName(java.lang.String accountName)
accountName - Account name to search for. Must not be null
null if not found.public java.util.List<Account> getIncomeAccountList()
public java.util.List<Account> getExpenseAccountList()
public java.util.List<Account> getBankAccountList()
public java.util.List<Account> getInvestmentAccountList()
public void refreshAccount(Account account)
public void refreshCommodity(CommodityNode node)
public void refreshExchangeRate(ExchangeRate rate)
public void refreshReminder(Reminder reminder)
public void refreshTransaction(Transaction transaction)
public boolean addAccount(Account parent,
Account child)
parent - The parent accountchild - A new Account object
public RootAccount getRootAccount()
public boolean moveAccount(Account account,
Account newParent)
account - account to movenewParent - the new parent account
public boolean modifyAccount(Account template,
Account account)
template - The Account object to use as a templateaccount - The existing account
public void setAccountNumber(Account account,
java.lang.String number)
account - account to changenumber - new account numberpublic boolean removeAccount(Account account)
account - The account to remove
public boolean setAmortizeObject(Account account,
AmortizeObject amortizeObject)
account - The Liability account to changeamortizeObject - the new AmortizeObject
public boolean toggleAccountVisibility(Account account)
account - The account to toggle visibility
private boolean addAccountSecurity(Account account,
SecurityNode node)
account - destination accountnode - SecurityNode to add
private boolean removeAccountSecurity(Account account,
SecurityNode node)
account - Account to remove SecurityNode fromnode - SecurityNode to remove
public boolean updateAccountSecurities(Account acc,
java.util.Collection<SecurityNode> list)
acc - Destination accountlist - Collection of SecurityNodes
public boolean isTransactionValid(Transaction transaction)
public boolean isStored(StoredObject object)
object - StoredObject to check
public boolean addTransaction(Transaction transaction)
public boolean removeTransaction(Transaction transaction)
public void setTransactionReconciled(Transaction transaction,
Account account,
ReconciledState state)
transaction - transaction to changeaccount - account to change state forstate - new reconciled statepublic java.util.List<java.lang.String> getTransactionNumberList()
public void setTransactionNumberList(java.util.List<java.lang.String> list)
public java.util.List<Transaction> getTransactions()
private void postTransactionAdd(Transaction transaction,
boolean result)
private void postTransactionRemove(Transaction transaction,
boolean result)
public java.lang.String getUuid()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||