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.StringDROPBOX_SYNC_UUID -
Method Summary
Modifier and Type Method Description static AccountBookaccountBookForFolder(java.io.File folder)voidaddAccountListener(AccountListener listener)add a listener to be notified when an account is modified.voidaddFileListener(MDFileListener listener)voidaddListener(AccountBookListener listener)voidcleanUp()Avoid lapsed listener leaks when successively opening multiple files.voidcleanupDeletedAttachments()protected booleancreateAccountBookStructure()voiddoInitialLoad(boolean isSyncMaster)Load the set of accounts from storagebooleanequals(java.lang.Object obj)static AccountBookfakeAccountBook()AccountgetAccountByNum(int acctNum)AccountgetAccountByUUID(java.lang.String acctID)AccountgetAccountByUUIDOrLegacyNumber(java.lang.String acctID)Lookup an account by either it's old account ID (if given a numeric value) or by it's UUID.AddressBookgetAddresses()java.lang.StringgetAttachmentsFolder()static java.io.FilegetBookFileForName(java.io.File containerFolder, java.lang.String bookName)BudgetListgetBudgets()java.util.List<java.io.File>getCheckpointFiles()java.io.FilegetCheckpointsFolder()CurrencyTablegetCurrencies()Get the set of currencies associated with this fileCurrencyTypegetCurrencyByUUID(java.lang.String currencyID)java.io.FilegetEncryptedTemporaryFolder()java.lang.StringgetFileUUID()Get the unique ID for this data file.MoneydanceSyncableItemgetItemForID(java.lang.String itemID)Returns the local item that has the given IDjava.util.List<com.infinitekind.tiksync.SyncableItem>getItemsWithType(java.lang.String type)longgetLastModified()LocalStoragegetLocalStorage()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).ReportSpecManagergetMemorizedItems()java.lang.StringgetName()OnlineInfogetOnlineInfo()StreamTablegetPublicMetaData()Return public metadata about this set of accounts.booleangetRecalcBalances()ReminderSetgetReminders()AccountgetRootAccount()java.lang.StringgetRootAccountFile()java.io.FilegetRootFolder()com.infinitekind.tiksync.SyncergetSyncer()Get the syncer associated with this data set, if any.java.io.FilegetTemporaryFolder()TransactionSetgetTransactionSet()Get the set of all transactions.UndoManagerInterfacegetUndoManager()Get the undo manager that is associated with the UI for this data file.static java.io.FilegetUnusedFileNameWithBase(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.FilegetUnusedFriendlyFileInBase(java.io.File baseFolder)booleanhasCompletedInitialSync()booleanhasLoggedChanges()voidinitializeAccounts(Account rootAccount)voidinitializeNewEmptyAccounts(java.lang.String defaultCurrencyID)booleanisValid()static booleanisValid(AccountBook book)static booleanisValidBookFile(java.lang.String filename)static booleanisValidBookName(java.io.File baseFolder, java.lang.String bookName)booleanlogModifiedItem(MoneydanceSyncableItem modifiedItem)Record that the given item was changed, so that the change can be saved and synced.booleanlogModifiedItems(java.util.List<MoneydanceSyncableItem> modifiedItems)Record that the given items were changed, so that the changes can be saved and synced.booleanlogRemovedItem(MoneydanceSyncableItem removedItem)Record that the given item was removed, so that the removal of the item can be synced.booleanlogRemovedItems(java.util.List<MoneydanceSyncableItem> itemsToRemove)voidmoveToFolder(java.io.File newFolder)Move this account book to the given base folder.voidnotifyAccountModified(Account acct)notify all listeners that the specified account has been modified.voidpauseSyncing()voidperformPostLoadVerification()booleanrefreshAccountBalances()This will update the accounts balance from the "working" value and notify listeners if the balance has changed.voidrefreshAccountBalancesAsync()voidregisterAttachmentForDeletion(java.lang.String attachmentPath)voidregisterNewItemWithoutSyncing(com.infinitekind.tiksync.SyncableItem newItem)Call this to add an item to the data set that is not yet synced.voidremoveAccountListener(AccountListener listener)remove the specified object so that it doesn't get any more notifications when an account is modified.voidremoveFileListener(MDFileListener listener)voidremoveListener(AccountBookListener listener)voidresetLoggedChanges()voidresumeSyncing()booleansave()Save any pending queued changes, returning false if we couldn't save somethingvoidsaveTrunkFile()Saves a snapshot of the current data set in a "trunk" data file.voidscheduleQueuePurgeInMillisecondsFromNow(long inXMilliseconds)voidsetFinishedInitialLoad(boolean b)voidsetLocalStorage(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).voidsetPublicMetaData(StreamTable newMetaInfo)Set the public meta data that applies to this set of accounts.voidsetRecalcBalances(boolean doRecalcs)Tells the model whether or not all account balances should be recalculated whenever a transaction is modified.voidsetUndoManager(UndoManagerInterface undoManager)Set the undo manager that is associated with the UI for this data file.voidstartSyncing(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.voidstopSyncing()static java.lang.StringstripNonFilenameSafeCharacters(java.lang.String filename)Strip all characters that should not appear in a filename (including path characters)java.lang.StringtoString()voidunregisterAttachmentForDeletion(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:
equalsin classjava.lang.Object
-
createAccountBookStructure
protected boolean createAccountBookStructure() -
toString
public java.lang.String toString()- Overrides:
toStringin 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)
-