Class AccountBook
java.lang.Object
com.infinitekind.moneydance.model.AccountBook
public class AccountBook
extends java.lang.Object
AccountBook is the overall container for a data file in Moneydance. It contains
references to all transactions, accounts, currencies, securities, budgets, etc.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DROPBOX_SYNC_UUID
-
Method Summary
Modifier and Type Method Description static AccountBook
accountBookForFolder(java.io.File folder)
void
addAccountListener(AccountListener listener)
add a listener to be notified when an account is modified.void
addFileListener(MDFileListener listener)
void
addListener(AccountBookListener listener)
void
cleanUp()
Avoid lapsed listener leaks when successively opening multiple files.void
cleanupDeletedAttachments()
protected boolean
createAccountBookStructure()
void
doInitialLoad(boolean isSyncMaster)
Load the set of accounts from storageboolean
equals(java.lang.Object obj)
static AccountBook
fakeAccountBook()
Account
getAccountByNum(int acctNum)
Account
getAccountByUUID(java.lang.String acctID)
Account
getAccountByUUIDOrLegacyNumber(java.lang.String acctID)
Lookup an account by either it's old account ID (if given a numeric value) or by it's UUID.AddressBook
getAddresses()
java.lang.String
getAttachmentsFolder()
static java.io.File
getBookFileForName(java.io.File containerFolder, java.lang.String bookName)
BudgetList
getBudgets()
java.util.List<java.io.File>
getCheckpointFiles()
java.io.File
getCheckpointsFolder()
CurrencyTable
getCurrencies()
Get the set of currencies associated with this fileCurrencyType
getCurrencyByUUID(java.lang.String currencyID)
java.io.File
getEncryptedTemporaryFolder()
java.lang.String
getFileUUID()
Get the unique ID for this data file.MoneydanceSyncableItem
getItemForID(java.lang.String itemID)
Returns the local item that has the given IDjava.util.List<com.infinitekind.tiksync.SyncableItem>
getItemsWithType(java.lang.String type)
long
getLastModified()
LocalStorage
getLocalStorage()
Returns an object that can be used to save information locally, such as preferences, network/syncing settings, and passwords (if the data file is encrypted).ReportSpecManager
getMemorizedItems()
java.lang.String
getName()
OnlineInfo
getOnlineInfo()
StreamTable
getPublicMetaData()
Return public metadata about this set of accounts.boolean
getRecalcBalances()
ReminderSet
getReminders()
Account
getRootAccount()
java.lang.String
getRootAccountFile()
java.io.File
getRootFolder()
com.infinitekind.tiksync.Syncer
getSyncer()
Get the syncer associated with this data set, if any.java.io.File
getTemporaryFolder()
TransactionSet
getTransactionSet()
Get the set of all transactions.UndoManagerInterface
getUndoManager()
Get the undo manager that is associated with the UI for this data file.static java.io.File
getUnusedFileNameWithBase(java.io.File containerFolder, java.lang.String baseName)
Return a unique internal account book file folder with a name based on the given base file namestatic java.io.File
getUnusedFriendlyFileInBase(java.io.File baseFolder)
boolean
hasCompletedInitialSync()
boolean
hasLoggedChanges()
void
initializeAccounts(Account rootAccount)
void
initializeNewEmptyAccounts(java.lang.String defaultCurrencyID)
boolean
isValid()
static boolean
isValid(AccountBook book)
static boolean
isValidBookFile(java.lang.String filename)
static boolean
isValidBookName(java.io.File baseFolder, java.lang.String bookName)
boolean
logModifiedItem(MoneydanceSyncableItem modifiedItem)
Record that the given item was changed, so that the change can be saved and synced.boolean
logModifiedItems(java.util.List<MoneydanceSyncableItem> modifiedItems)
Record that the given items were changed, so that the changes can be saved and synced.boolean
logRemovedItem(MoneydanceSyncableItem removedItem)
Record that the given item was removed, so that the removal of the item can be synced.boolean
logRemovedItems(java.util.List<MoneydanceSyncableItem> itemsToRemove)
void
moveToFolder(java.io.File newFolder)
Move this account book to the given base folder.void
notifyAccountModified(Account acct)
notify all listeners that the specified account has been modified.void
pauseSyncing()
void
performPostLoadVerification()
boolean
refreshAccountBalances()
This will update the accounts balance from the "working" value and notify listeners if the balance has changed.void
refreshAccountBalancesAsync()
void
registerAttachmentForDeletion(java.lang.String attachmentPath)
void
registerNewItemWithoutSyncing(com.infinitekind.tiksync.SyncableItem newItem)
Call this to add an item to the data set that is not yet synced.void
removeAccountListener(AccountListener listener)
remove the specified object so that it doesn't get any more notifications when an account is modified.void
removeFileListener(MDFileListener listener)
void
removeListener(AccountBookListener listener)
void
resetLoggedChanges()
void
resumeSyncing()
boolean
save()
Save any pending queued changes, returning false if we couldn't save somethingvoid
saveTrunkFile()
Saves a snapshot of the current data set in a "trunk" data file.void
scheduleQueuePurgeInMillisecondsFromNow(long inXMilliseconds)
void
setFinishedInitialLoad(boolean b)
void
setLocalStorage(LocalStorage newStorage)
Sets an object that can be used to save information locally, such as preferences, network/syncing settings, and passwords (if the data file is encrypted).void
setPublicMetaData(StreamTable newMetaInfo)
Set the public meta data that applies to this set of accounts.void
setRecalcBalances(boolean doRecalcs)
Tells the model whether or not all account balances should be recalculated whenever a transaction is modified.void
setUndoManager(UndoManagerInterface undoManager)
Set the undo manager that is associated with the UI for this data file.void
startSyncing(com.infinitekind.tiksync.SyncFolder syncFolder, com.infinitekind.tiksync.SyncDelegate callback, boolean isMasterSyncer)
If the syncing process hasn't already been established then this synchronously downloads the initial data set.void
stopSyncing()
static java.lang.String
stripNonFilenameSafeCharacters(java.lang.String filename)
Strip all characters that should not appear in a filename (including path characters)java.lang.String
toString()
void
unregisterAttachmentForDeletion(java.lang.String attachmentPath)
-
Field Details
-
DROPBOX_SYNC_UUID
public static final java.lang.String DROPBOX_SYNC_UUID- See Also:
- Constant Field Values
-
-
Method Details
-
getLocalStorage
Returns an object that can be used to save information locally, such as preferences, network/syncing settings, and passwords (if the data file is encrypted). Note: data put into the local storage is not synced. -
setLocalStorage
Sets an object that can be used to save information locally, such as preferences, network/syncing settings, and passwords (if the data file is encrypted). This should be set only by the application if it wants to override how data is stored. Note: data put into the local storage is not synced. -
getFileUUID
public final java.lang.String getFileUUID()Get the unique ID for this data file. If there are any data files with the same ID then some not-great things may happen with syncing, so be careful when restoring backups and un-archiving files. -
doInitialLoad
public void doInitialLoad(boolean isSyncMaster) throws java.lang.ExceptionLoad the set of accounts from storage- Throws:
java.lang.Exception
-
saveTrunkFile
public void saveTrunkFile() throws java.lang.ExceptionSaves a snapshot of the current data set in a "trunk" data file. If the resetTxnQueue parameter is true then any incremental transaction logs since the last save are wiped out. Therefore, the parameter should only be true if we're the master syncing node AND ve created a new data file for the first time or we want to reset the transaction queue for some other reason.- Throws:
java.lang.Exception
-
hasCompletedInitialSync
public boolean hasCompletedInitialSync() -
startSyncing
public void startSyncing(com.infinitekind.tiksync.SyncFolder syncFolder, com.infinitekind.tiksync.SyncDelegate callback, boolean isMasterSyncer) throws java.lang.ExceptionIf the syncing process hasn't already been established then this synchronously downloads the initial data set. It then kicks off a background thread to continuously sync this data file. If syncing has already started this does nothing.- Parameters:
syncFolder
- The online "folder" in which sync files are storedisMasterSyncer
- true if this data set is a master copy; that is, it's not a mobile device or secondary desktop copy- Throws:
java.lang.Exception
- whenever it feels the urge
-
stopSyncing
public void stopSyncing() -
pauseSyncing
public void pauseSyncing() -
resumeSyncing
public void resumeSyncing() -
getCurrencyByUUID
-
getAccountByUUID
-
getAccountByNum
-
getAccountByUUIDOrLegacyNumber
Lookup an account by either it's old account ID (if given a numeric value) or by it's UUID.- Since:
- build 1204
-
getSyncer
public com.infinitekind.tiksync.Syncer getSyncer()Get the syncer associated with this data set, if any.- Returns:
- the syncer if this account book has started syncing, or null if not
-
initializeNewEmptyAccounts
public void initializeNewEmptyAccounts(java.lang.String defaultCurrencyID) throws java.lang.Exception- Throws:
java.lang.Exception
-
initializeAccounts
-
getName
public java.lang.String getName() -
getRootAccountFile
public java.lang.String getRootAccountFile() -
getAttachmentsFolder
public java.lang.String getAttachmentsFolder() -
getCheckpointsFolder
public java.io.File getCheckpointsFolder() -
getLastModified
public long getLastModified() -
getCheckpointFiles
public java.util.List<java.io.File> getCheckpointFiles() -
getRootFolder
public java.io.File getRootFolder() -
getTemporaryFolder
public java.io.File getTemporaryFolder() -
getEncryptedTemporaryFolder
public java.io.File getEncryptedTemporaryFolder() -
getUndoManager
Get the undo manager that is associated with the UI for this data file. Returns null if the UI hasn't set an undo manager.- Since:
- Moneydance 2017.3 build 1605
-
setUndoManager
Set the undo manager that is associated with the UI for this data file.- Since:
- Moneydance 2017.3 build 1605
-
getRootAccount
-
getTransactionSet
Get the set of all transactions. -
getCurrencies
Get the set of currencies associated with this file -
getReminders
-
getBudgets
-
getAddresses
-
getOnlineInfo
-
getMemorizedItems
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
createAccountBookStructure
protected boolean createAccountBookStructure() -
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
isValid
public boolean isValid() -
isValid
-
accountBookForFolder
-
isValidBookName
public static boolean isValidBookName(java.io.File baseFolder, java.lang.String bookName) -
isValidBookFile
public static boolean isValidBookFile(java.lang.String filename) -
setPublicMetaData
Set the public meta data that applies to this set of accounts. This should only be called by the objects that read the data from an input stream. -
getPublicMetaData
Return public metadata about this set of accounts. This should include any information that is not in the encrypted part of the file. This will most likely only contain the encryption hint. -
cleanUp
public void cleanUp()Avoid lapsed listener leaks when successively opening multiple files. Clean up all fields that have back references to this object, and remove any listeners that were not already removed. -
registerAttachmentForDeletion
public void registerAttachmentForDeletion(java.lang.String attachmentPath) -
unregisterAttachmentForDeletion
public void unregisterAttachmentForDeletion(java.lang.String attachmentPath) -
cleanupDeletedAttachments
public void cleanupDeletedAttachments() -
addListener
-
removeListener
-
addFileListener
-
removeFileListener
-
addAccountListener
add a listener to be notified when an account is modified. -
removeAccountListener
remove the specified object so that it doesn't get any more notifications when an account is modified. -
notifyAccountModified
notify all listeners that the specified account has been modified. -
refreshAccountBalances
public boolean refreshAccountBalances()This will update the accounts balance from the "working" value and notify listeners if the balance has changed. Returns true if any of the balances have changed. -
refreshAccountBalancesAsync
public void refreshAccountBalancesAsync() -
setRecalcBalances
public void setRecalcBalances(boolean doRecalcs)Tells the model whether or not all account balances should be recalculated whenever a transaction is modified. For performance reasons this should be set to false before adding/modifying/deleting a bunch of transactions and then set to true afterwards. DON'T FORGET TO SET TO TRUE WHEN DONE WITH THE OPERATION!!!! -
getRecalcBalances
public boolean getRecalcBalances() -
logRemovedItems
-
logRemovedItem
Record that the given item was removed, so that the removal of the item can be synced. -
registerNewItemWithoutSyncing
public void registerNewItemWithoutSyncing(com.infinitekind.tiksync.SyncableItem newItem)Call this to add an item to the data set that is not yet synced. This should only be called when loading data in bulk. After this is called you should push a new trunk data set to the syncing system so that this item is not lost! This is useful when loading data from an older moneydance data file when you want the data loaded, but don't want it (yet) synced via an incremental update. Note: This must ensure that the item's UUID is not a duplicate of anything that is already in the data set. -
logModifiedItem
Record that the given item was changed, so that the change can be saved and synced. -
logModifiedItems
Record that the given items were changed, so that the changes can be saved and synced. -
save
public boolean save()Save any pending queued changes, returning false if we couldn't save something -
performPostLoadVerification
public void performPostLoadVerification() -
setFinishedInitialLoad
public void setFinishedInitialLoad(boolean b) -
moveToFolder
public void moveToFolder(java.io.File newFolder) throws java.io.IOExceptionMove this account book to the given base folder. This is used for internal functions such as moving a provisional set of data from a temporary folder into it's permanent location.- Throws:
java.io.IOException
- Since:
- Moneydance build 1525
-
scheduleQueuePurgeInMillisecondsFromNow
public void scheduleQueuePurgeInMillisecondsFromNow(long inXMilliseconds) -
hasLoggedChanges
public boolean hasLoggedChanges() -
resetLoggedChanges
public final void resetLoggedChanges() -
getItemForID
Returns the local item that has the given ID -
getItemsWithType
public java.util.List<com.infinitekind.tiksync.SyncableItem> getItemsWithType(java.lang.String type) -
fakeAccountBook
-
getUnusedFriendlyFileInBase
public static java.io.File getUnusedFriendlyFileInBase(java.io.File baseFolder) -
getUnusedFileNameWithBase
public static java.io.File getUnusedFileNameWithBase(java.io.File containerFolder, java.lang.String baseName)Return a unique internal account book file folder with a name based on the given base file name -
getBookFileForName
public static java.io.File getBookFileForName(java.io.File containerFolder, java.lang.String bookName) -
stripNonFilenameSafeCharacters
public static java.lang.String stripNonFilenameSafeCharacters(java.lang.String filename)Strip all characters that should not appear in a filename (including path characters)
-