Class WritableDatabaseService
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.GeneiousService
-
- com.biomatters.geneious.publicapi.databaseservice.DatabaseService
-
- com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService
-
- Direct Known Subclasses:
WritableDatabaseService.DummyService
public abstract class WritableDatabaseService extends DatabaseService
Provides a DatabaseService that supports writing documents to it as well as providing a hierarchical folder representation of the database. Arbitrary XML can also be stored in the database. The Geneious local database and shared databases are WritableDatabaseServices. A WritableDatabaseService accepts and only generates AnnotatedPluginDocuments rather than PluginDocuments. Notes for implementing a WritableDatabaseService:
Any implementation will need to make use of the following methods to handle serializing documents to their constituent AnnotatedPluginDocument and PluginDocuments and recreating documents.-
AnnotatedPluginDocument.toXMLExcludingInternalPluginDocument()
-
AnnotatedPluginDocument.getDocumentOrNull()
.toXML()
-
DocumentUtilities.createAnnotatedPluginDocument(Element, ElementProvider, URN)
AnnotatedPluginDocument.setDatabase(DatabaseService)
before exposing that document to any external code. This includes adding documents, removing documents, loading documents, moving documents, and loading/setting folder view documents. An implementation also needs to handle referenced documents:- When adding documents it should look at documents referenced
of the newly added document using
AnnotatedPluginDocument.getReferencedDocuments()
. For each of the referenced documents already in the database hierarchy, it should increment a reference count to those documents. For reference documents not already in this database, it should add a copy of the reference document to an invisible region of the database. - When removing a document, if that document is referenced by other documents, instead of being removed, it should be moved to an invisible region of the database and should remain there until it is no longer referenced, at which point it should be permanently deleted.
- AnnotatedPluginDocument belonging to any sub-folder within the network-backed database will remain in memory during a logout event until they are garbage collected. Do not attempt to manually unload them.
-
The same database instance must be returned for each new login session as long as it represents the same folder on
remote. Documents in memory may still be using the
database
from the last session, and there must only be one database instance to represent each folder at all times.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WritableDatabaseService.DocumentsToAdd
Holds information required for adding one or more documents to a database, potentially to different sub-folders.static class
WritableDatabaseService.DocumentToAdd
Holds information required for adding a single document to a database viaaddDocumentCopies(DocumentsToAdd, ProgressListener)
and for databases implementing this viaaddDocumentsImplementation(List, ProgressListener)
.static class
WritableDatabaseService.DummyService
A dummy implementation of WritableDatabaseService that provides no functionality apart from a name and iconsstatic interface
WritableDatabaseService.SearchResultPropertiesAdjuster
-
Nested classes/interfaces inherited from class com.biomatters.geneious.publicapi.databaseservice.DatabaseService
DatabaseService.SequenceSearchQueryType
-
Nested classes/interfaces inherited from class com.biomatters.geneious.publicapi.plugin.GeneiousService
GeneiousService.ServiceStatus
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_PROCESS_SPECIAL_QUERY_SYMBOLS
Specifies howdocument retrieval
from thisWritableDatabaseService
should interpret theQuery
search text if it contains characters (symbols) that are semantically meaningful to the underlying retrieval system implementation.static java.lang.String
KEY_SEARCH_INDEX_CORRUPT_OR_MISSING_FAIL_WITH_EXCEPTION
Specifies the document retrieval behaviour if the search index is corrupted or missing.static java.lang.String
KEY_SEARCH_SUBFOLDERS
All WritableDatabaseServices return aCheckboxSearchOption
with thiscode
fromgetExtendedSearchOptions()
static java.lang.String
KEY_SEARCH_TYPE
All WritableDatabaseServices return aTextOrSimilaritySearchOption
with thiscode
fromgetExtendedSearchOptions(false)
static java.lang.String
KEY_WHOLE_WORDS_ONLY
Values returned from getExtendedSearchOptions which provide a boolean option for whether to search for whole words vs partial words, should use this as theirExtendedSearchOption.getCode()
.-
Fields inherited from class com.biomatters.geneious.publicapi.plugin.GeneiousService
SERVICE_TREE_LABEL_FAINTER_END, SERVICE_TREE_LABEL_FAINTER_START
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WritableDatabaseService()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected abstract AnnotatedPluginDocument
_addDocumentCopy(AnnotatedPluginDocument annotatedDocument, jebl.util.ProgressListener progress)
Implementaion method foraddDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement.protected AnnotatedPluginDocument
_addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties)
protected AnnotatedPluginDocument
_addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties, URN urnToUseForAddedDocument)
protected abstract AnnotatedPluginDocument
_addReferencedOnlyDocumentCopy(AnnotatedPluginDocument annotatedDocument, jebl.util.ProgressListener progress)
protected boolean
_canRemoveChildFolder(java.lang.String name)
Sub-classes may override this method to makecanRemoveChildFolder(String)
prevent folders from being removed.protected java.util.List<GeneiousAction>
_getActionsEnabledWhenServiceSelected()
Sub-classes should override this to provide actions as defined byGeneiousService.getActionsEnabledWhenServiceSelected()
.static ExtendedSearchOption[]
_getExtendedSearchOptions(boolean isAdvancedSearch)
Get the extended options that most WritableDatabaseServices return fromgetExtendedSearchOptions(boolean)
.protected AnnotatedPluginDocument
_getFolderViewDocument()
The implementation method forgetFolderViewDocument()
.protected abstract java.lang.String
_getHelp()
Sub-classes should override this to provide help as defined byGeneiousService.getHelp()
Ths results of this method are combined with any additional help provided toaddAdditionalHelp(String)
to create the results forgetHelp()
.protected abstract WritableDatabaseService
_getHiddenFolder(java.lang.String folderName, boolean isPerUserFolder)
The implementation method forgetHiddenFolder(String, boolean)
protected abstract Icons
_getIcons()
Sub-classes should override this to provide icons as defined byGeneiousService.getIcons()
.protected abstract boolean
_moveDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress)
Implementation method formoveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement.protected abstract void
_removeDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress)
Implementation method forremoveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement.protected void
_removeDocuments(java.util.List<AnnotatedPluginDocument> documentsToRemove, jebl.util.ProgressListener progress)
Implementation method forremoveDocuments(List, ProgressListener)
that subclasses should implement for batch document removal.protected abstract void
_retrieve(Query query, RetrieveCallback callback, URN[] urnsToNotRetrieve)
Implementaion method forretrieve(com.biomatters.geneious.publicapi.databaseservice.Query, com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback, com.biomatters.geneious.publicapi.documents.URN[])
that subclasses should implement.protected void
_retrieve(AnnotatedPluginDocument[] summaryDocuments, RetrieveCallback callback, URN[] urnsToNotRetrieve)
Implementaion method forretrieve(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback, com.biomatters.geneious.publicapi.documents.URN[])
that subclasses should implement.protected abstract void
_retrieve(URN[] urnsToRetrieve, RetrieveCallback callback)
Implementaion method forretrieve(com.biomatters.geneious.publicapi.documents.URN[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback)
that subclasses should implement.protected boolean
_saveDocumentsAnywhereWithinDatabase(java.util.List<AnnotatedPluginDocument> documentsToSave, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progressListener)
void
addAdditionalAction(GeneiousAction action)
Adds an additional action that this service will provide viagetActionsEnabledWhenServiceSelected()
void
addAdditionalHelp(java.lang.String additionalHelpText)
Add some additional help to append to the end of the standard help this folder returned fromgetHelp()
void
addDatabaseServiceListener(DatabaseServiceListener listener)
A sub-class must not override this, but should instead usegetDatabaseServiceListeners()
as this class relies ongetDatabaseServiceListeners()
.java.util.List<AnnotatedPluginDocument>
addDocumentCopies(WritableDatabaseService.DocumentsToAdd documentsToAdd, jebl.util.ProgressListener progressListener)
Adds copies of one or more documents to this database.java.util.List<AnnotatedPluginDocument>
addDocumentCopies(java.util.List<AnnotatedPluginDocument> documents, jebl.util.ProgressListener progressListener)
Adds copies of one or more documents to this database folder.AnnotatedPluginDocument
addDocumentCopy(AnnotatedPluginDocument document, jebl.util.ProgressListener progress)
Add a copy of this document to this database.AnnotatedPluginDocument
addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties)
AnnotatedPluginDocument
addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties, URN urnToUseForAddedDocument)
Add a copy of this document to this database with additional properties that will show up as associated with this document on any future queries while the document resides in this folder.protected void
addDocumentsImplementation(java.util.List<WritableDatabaseService.DocumentToAdd> documents, jebl.util.ProgressListener progressListener)
Only the implementation ofaddDocumentCopies(List, ProgressListener)
should call this method.abstract void
addHiddenElement(java.lang.String name, org.jdom.Element newElement, jebl.util.ProgressListener progress)
Adds a new hidden element to this database using the given name.abstract java.lang.String
addHiddenElement(org.jdom.Element newElement, jebl.util.ProgressListener progress)
Adds a new hidden element to this database and generates a new unique name which is returned.java.util.Map<org.jdom.Element,java.lang.String>
addHiddenElements(java.util.Collection<org.jdom.Element> newElements, jebl.util.ProgressListener progress)
Adds multiple hidden elements to this database and generates a unique name for each new element.void
addHiddenElements(java.util.Map<java.lang.String,org.jdom.Element> newElementsByName, jebl.util.ProgressListener progress)
Adds multiple named hidden elements to this database.void
addOverlayIcons(Icons icons)
add an icon which will be drawn on top of the standard database iconvoid
addSearchResultPropertiesAdjuster(WritableDatabaseService.SearchResultPropertiesAdjuster propertiesAdjuster)
Add a SearchResultPropertiesAdjuster to this database service.protected boolean
allowChangingFolderProperties()
Are the properties of this folder allowed to be changed ( moving, renaming, deleting)void
cachePluginDocumentXmlAndAdditionalXmlLocally(java.util.List<AnnotatedPluginDocument> documents, jebl.util.ProgressListener progressListener)
For a local database, this method does nothing.static void
cachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(java.util.List<AnnotatedPluginDocument> documentsToCache, jebl.util.ProgressListener progressListener)
If any of thedocumentsToCache
are in a network database, their PluginDocument XML and additional XML may be preloaded by that database.boolean
canBeRenamed()
Returns whether or not this service can be renamed usingrenameFolder(String)
This method is offered because some services can be read only with regards to documents, but allow the folder itself to be renamed.boolean
canEditDocuments()
Returns true if documents in this database can be edited.boolean
canModifySubFolders()
Returns whether or not this service allows modifications of its subfolders.abstract boolean
canMoveTo(WritableDatabaseService destination)
Checks whether the service can be moved to a new destination.boolean
canRemoveChildFolder(java.lang.String name)
Can the child folder with this name be removed.abstract boolean
containsDocumentAnywhereWithinDatabase(URN documentURN)
Determine if this database (including any other folders and any user invisible folders) contains a document with this URN This method should return the same information no matter where in the DatabaseService tree it is called.boolean
containsDocumentInThisFolder(URN documentURN)
Returns true if this folder contains a document with this URN.abstract WritableDatabaseService
createChildFolder(java.lang.String name)
Creates a child DatabaseService.java.util.List<WritableDatabaseService>
createChildFolders(java.util.List<java.lang.String> folderNames, jebl.util.ProgressListener progressListener)
Creates one or more child folders.WritableDatabaseService
createFolderViewFolder(java.lang.String folderName, AnnotatedPluginDocument folderViewDocument)
Creates a new child folder that contains a document that may be displayed for representing an entire view of the folder.URN
createUrnForDocumentSoonToBeAdded()
Returns a URN which can be specified as used for document later added to this database usingaddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
.protected URN
createUrnForThisDatabase()
Returns a URN which can be specified as used for document later added to this database usingaddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
.protected AnnotatedPluginDocument
duplicateDocumentAndDealWithReferencedDocuments(AnnotatedPluginDocument document, ElementProvider pluginDocumentElementProvider, java.util.concurrent.atomic.AtomicReference<org.jdom.Element> returnedPluginDocumentElement)
Deprecated.use #duplicateDocumentAndDealWithReferencedDocumentsprotected AnnotatedPluginDocument
duplicateDocumentAndDealWithReferencedDocuments(AnnotatedPluginDocument document, ElementProvider pluginDocumentElementProvider, java.util.concurrent.atomic.AtomicReference<org.jdom.Element> returnedPluginDocumentElement, URN urnOfNewDocument)
This as a helper method to facilitate implementing_addDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
.java.util.List<GeneiousAction>
getActionsEnabledWhenServiceSelected()
WritableDatabaseService implements this as a final method to add any additional actions supplied toaddAdditionalAction(com.biomatters.geneious.publicapi.plugin.GeneiousAction)
combined with the actions provided by sub-classes in_getActionsEnabledWhenServiceSelected()
.java.util.Map<java.lang.String,ElementProvider>
getAdditionalPerDocumentXml(AnnotatedPluginDocument document, boolean isPerUser, jebl.util.ProgressListener progressListener)
Gets all additional XML for a single document.org.jdom.Element
getAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.lang.String key, boolean isPerUser, jebl.util.ProgressListener progressListener)
Get some additional XML associated with a particular document that has been saved usingsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
.java.util.Map<java.lang.String,ElementProvider>
getAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.util.List<java.lang.String> keys, boolean isPerUser, jebl.util.ProgressListener progressListener)
Get some additional XML associated with a particular document that has been saved usingsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
orsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, Map, ProgressListener)
java.util.List<java.lang.String>
getAdditionalPerDocumentXmlKeys(boolean isPerUser, jebl.util.ProgressListener progressListener)
Get a list of all keys that additional XML has been stored under on any document.protected java.lang.String
getAssignerForCreatingUrn()
WritableDatabaseService
getChildService(java.lang.String name)
Gets a child service whosegetFolderName()
==name
.java.awt.Color
getColor(boolean loadNow)
Gets the text/icon color for this folder.WritableDatabaseService
getDatabaseRoot()
Get the root folder of this database folder hierarchy.protected java.util.List<DatabaseServiceListener>
getDatabaseServiceListeners()
Get all DatabaseServiceListeners added usingaddDatabaseServiceListener(com.biomatters.geneious.publicapi.databaseservice.DatabaseServiceListener)
.AnnotatedPluginDocument
getDocument(URN urn)
Get a document that exists anywhere within this database (including other folders) with a particular URN.abstract int
getDocumentCount(boolean includeSubFolders)
Get the number of documents in this folder.abstract WritableDatabaseService
getDocumentLocation(URN documentURN)
If this database contains this document in any user visible folder returns the WritableDatabaseService representing the folder that contains it.java.util.List<AnnotatedPluginDocument>
getDocuments(java.util.List<URN> documentUrnsToRetrieve)
Gets multiple documents that exists anywhere within this database (including other folders) identified by their URNs.java.util.List<URN>
getDocumentURNsOfDocumentsContainedAnywhereWithinDatabase(java.util.Collection<URN> urns, jebl.util.ProgressListener progressListener)
Identifies which of the given URNs are for documents which are in this database.ExtendedSearchOption[]
getExtendedSearchOptions(boolean isAdvancedSearch)
Provide a list of extended options to be displayed the in the search panel.abstract java.lang.String
getFolderName()
Get the name of this DatabaseService folder displayed to the user.AnnotatedPluginDocument
getFolderViewDocument()
If this folder represents the results of a search, it must provide a FolderViewDocument which stores all properties of that search.java.lang.String
getHelp()
WritableDatabaseService implements this as a final method to add any additional help supplied toaddAdditionalHelp(String)
combined with the help provided by sub-classes in_getHelp()
abstract org.jdom.Element
getHiddenElement(java.lang.String elementName, jebl.util.ProgressListener progress)
Get(load) a special hidden element.abstract java.lang.String[]
getHiddenElementNames()
Lists the hidden elements stored in this database.java.util.Map<java.lang.String,org.jdom.Element>
getHiddenElements(java.util.Collection<java.lang.String> elementNames, jebl.util.ProgressListener progress)
Retrieves a number of hidden elements from this database.java.util.Map<java.lang.String,org.jdom.Element>
getHiddenElements(jebl.util.ProgressListener progress)
Retrieves all the hidden elements from this database.WritableDatabaseService
getHiddenFolder(java.lang.String folderName, boolean isPerUserFolder)
Gets an existing or creates a new hidden folder as an immediate child of the root service of this database.abstract java.lang.String[]
getHiddenFolderNames()
Get a list of hidden folders that can be used as parameters to the getHiddenFolder() method.Icons
getIcons()
WritableDatabaseService implements this as a final method to add any additional icons supplied toaddOverlayIcons(com.biomatters.geneious.publicapi.plugin.Icons)
combined with the icons provided by sub-classes in_getIcons()
java.lang.Object
getLock()
An object used as a lock by this database while it modifies the in memory contents of documents.java.lang.String
getNameForSorting()
WritableDatabaseService
getPrimaryDatabaseRoot()
Returns the database root (seegetDatabaseRoot()
) for the primary database in this collection.protected java.lang.String
getReasonCantMoveTo(WritableDatabaseService destination)
Returns the reason why we can not move this folder to destination, or null if we can move.protected abstract java.lang.String
getRootUniqueId()
Get the unique ID for the root folder of this database.java.util.Set<java.lang.String>
getSpecialQuerySymbols()
Returns a set of query text symbols that are considered reserved characters (symbols) fordocument retrieval
system implementation.java.lang.String
getUniqueID()
Get a unique ID for this database service.boolean
implementsEfficientBatchMethods()
Indicates that this database has implementations of methods for efficiently working with batches of documents.protected void
initialize(GeneiousServiceListener listener)
Constructor method - initializes the service.boolean
isDeleted()
Get whether this database folder is deleted.boolean
isHidden()
This method returns true if this service is created fromgetHiddenFolder(String, boolean)
.boolean
isHiddenPerUser()
If this service ishidden
, this method determines if this service is a per-user hidden folder.boolean
isLocal()
Is this a local database rather than a shared Database.boolean
isReadOnly()
Returns whether or not documents in this folder are read only and whether or not documents can be added and removed from this folder.boolean
isSameRootService(WritableDatabaseService anotherService)
Determines whether the root of this service (or this service itself if it is the root) is equal to the root of another service.boolean
isSearchIndexingComplete()
Some implementations ofWritableDatabaseService
may require documents to be indexed before document retrieval returns the full set of results.boolean
isShared()
Returns whether or not this service is accessible by other computers e.g.boolean
moveDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress)
Move a document that currently reside elsewhere in this database to this folder.abstract void
moveTo(WritableDatabaseService destination)
Move this entire database folder to a new location.void
recreateSearchIndex()
Requests the database service to completely recreate the search index.void
removeAdditionalAction(GeneiousAction action)
Removes an additional action (added previously usingaddAdditionalAction(com.biomatters.geneious.publicapi.plugin.GeneiousAction)
) that this service provides.void
removeAdditionalHelp(java.lang.String additionalHelpText)
Removed some additional help added usingaddAdditionalHelp(String)
abstract void
removeChildFolder(java.lang.String folderName)
Removes a child folder with this folder name.void
removeChildFolder(java.lang.String folderName, jebl.util.ProgressListener progressListener)
Removes a child folder with this folder name.void
removeDatabaseServiceListener(DatabaseServiceListener listener)
A sub-class must not override this, but should instead usegetDatabaseServiceListeners()
as this class relies ongetDatabaseServiceListeners()
.void
removeDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress)
Remove a document from this database.void
removeDocuments(java.util.List<AnnotatedPluginDocument> documentsToRemove, jebl.util.ProgressListener progressListener)
Removes one or more documents from this database.abstract void
removeHiddenElement(java.lang.String name)
Removes a hidden element from this database.void
removeHiddenElements(java.util.Collection<java.lang.String> namesToRemove, jebl.util.ProgressListener progress)
Removes multiple hidden elements by name.void
removeOverlayIcons(Icons icons)
remove an icon added usingaddOverlayIcons(com.biomatters.geneious.publicapi.plugin.Icons)
void
removeSearchResultPropertiesAdjuster(WritableDatabaseService.SearchResultPropertiesAdjuster propertiesAdjuster)
Removed a SearchResultPropertiesAdjuster added viaaddSearchResultPropertiesAdjuster(com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService.SearchResultPropertiesAdjuster)
.abstract void
renameFolder(java.lang.String newName)
Rename this folder.void
retrieve(Query query, RetrieveCallback callback, URN[] urnsToNotRetrieve)
Get documents by searching a database.void
retrieve(AnnotatedPluginDocument[] documents, RetrieveCallback callback, URN[] urnsToNotRetrieve)
Retrieves full documents corresponding to the given summary documents from the database.void
retrieve(URN[] urnsToRetrieve, RetrieveCallback callback)
Retrieve documents with the specified URNs.void
saveAdditionalPerDocumentXml(AnnotatedPluginDocument document, boolean isPerUser, java.util.Map<java.lang.String,ElementProvider> elementProviders, jebl.util.ProgressListener progressListener)
Save some additional XML associated with a particular document.void
saveAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.lang.String key, boolean isPerUser, org.jdom.Element element, jebl.util.ProgressListener progressListener)
Save some additional XML associated with a particular document.abstract boolean
saveDocument(AnnotatedPluginDocument document, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progress)
A document that is already in this database has been modified in memory and should now be saved to permanent storage.boolean
saveDocumentsAnywhereWithinDatabase(java.util.List<AnnotatedPluginDocument> documentsToSave, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progressListener)
Request to save multiple documents that already belong to any service beneath thisdatabase root
.void
setAllowChangingFolderProperties(boolean allow)
Prevent this folder from being moved, renamed or removed.void
setColor(java.awt.Color newColor)
Sets the text/icon color for this foldervoid
setFolderViewDocument(AnnotatedPluginDocument folderViewDocument, jebl.util.ProgressListener progressListener)
Sets the folder view document on this folder.void
setFolderViewDocuments(java.util.Map<WritableDatabaseService,AnnotatedPluginDocument> folderViewDocuments, jebl.util.ProgressListener progressListener)
Sets folder view documents on multiple folders.boolean
supportsReferencesBetweenDocuments()
Returns true if this database supports documents that store references to other documents in the same database.void
uncachePluginDocumentXmlAndAdditionalXmlLocally(java.util.List<AnnotatedPluginDocument> documents)
Indicates that the documents previously cached usingcachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
may be removed from the cache when there is insufficient free space in the cache.static void
uncachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(java.util.List<AnnotatedPluginDocument> documents)
Indicates that documents previously cached usingcachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List, ProgressListener)
may be removed from the cache when it is short on space.abstract void
updateHiddenElement(java.lang.String name, org.jdom.Element newElement, jebl.util.ProgressListener progress)
Updates the contents of a hidden element.void
updateHiddenElements(java.util.Map<java.lang.String,org.jdom.Element> elementsToUpdate, jebl.util.ProgressListener progress)
Updates the contents of multiple hidden elements.void
waitForSearchIndexingToComplete()
Equivalent towaitForSearchIndexingToComplete(false)
void
waitForSearchIndexingToComplete(boolean forDocumentTypeFieldQuery)
It is permissible for a database to not return documents from a search that have been recently added to the database due to it still indexing those documents for search purposes.-
Methods inherited from class com.biomatters.geneious.publicapi.databaseservice.DatabaseService
addWeakDatabaseServiceListener, batchSequenceSearch, getDocumentTypesForSequenceSearch, getSearchFields, getSequenceSearchOptions, getSequenceSearchPrograms, isBrowsable, isDocumentUnreadStatusEnabled, locateSummaryDocument, resumeSearch, retrieve, retrieve, retrieve, sequenceSearch, showAdvancedSearchByDefault
-
Methods inherited from class com.biomatters.geneious.publicapi.plugin.GeneiousService
_shutdown, addGeneiousServiceListener, addWeakGeneiousServiceListener, canShutdown, getActionsAlwaysEnabled, getChildServices, getDescription, getFullPath, getGeneiousServiceListener, getName, getParentService, getPreferences, getServiceTreeLabel, getStatus, hasShutdownOrStartedShuttingDown, initializeService, isProOnly, removeGeneiousServiceListener, showInServiceTree, shutdown, toString
-
-
-
-
Field Detail
-
KEY_SEARCH_TYPE
public static final java.lang.String KEY_SEARCH_TYPE
All WritableDatabaseServices return aTextOrSimilaritySearchOption
with thiscode
fromgetExtendedSearchOptions(false)
In the absence of a value for this option key, the caller should useTextOrSimilaritySearchOption.TEXT_SEARCH_TYPE
as the default value.- See Also:
- Constant Field Values
-
KEY_SEARCH_SUBFOLDERS
public static final java.lang.String KEY_SEARCH_SUBFOLDERS
All WritableDatabaseServices return aCheckboxSearchOption
with thiscode
fromgetExtendedSearchOptions()
This value will never be set for a browse query, and can be assumed to be false in that case.
For a search query, if this key is absent, then the caller should assume true.- See Also:
- Constant Field Values
-
KEY_WHOLE_WORDS_ONLY
public static final java.lang.String KEY_WHOLE_WORDS_ONLY
Values returned from getExtendedSearchOptions which provide a boolean option for whether to search for whole words vs partial words, should use this as theirExtendedSearchOption.getCode()
. In which case this may be provided as a key to theextendedOptions
map parameter inQuery.Factory.createExtendedQuery(String, Map)
with a Boolean value. In the absence of a value for this option key, the caller should assume true by default.- Since:
- API 4.202020 (Geneious 2020.2.0)
- See Also:
- Constant Field Values
-
KEY_SEARCH_INDEX_CORRUPT_OR_MISSING_FAIL_WITH_EXCEPTION
public static final java.lang.String KEY_SEARCH_INDEX_CORRUPT_OR_MISSING_FAIL_WITH_EXCEPTION
Specifies the document retrieval behaviour if the search index is corrupted or missing. If unset, the default behaviour is to display a dialog prompting the user to re-create the search index. Otherwise, if the value istrue
, aSearchIndexCorruptOrMissingException
will be thrown instead. This may be provided as a key to theextendedOptions
map parameter inQuery.Factory.createExtendedQuery(String, Map)
with a Boolean value.- Since:
- API 4.202020 (Geneious 2020.2.0)
- See Also:
- Constant Field Values
-
KEY_PROCESS_SPECIAL_QUERY_SYMBOLS
public static final java.lang.String KEY_PROCESS_SPECIAL_QUERY_SYMBOLS
Specifies howdocument retrieval
from thisWritableDatabaseService
should interpret theQuery
search text if it contains characters (symbols) that are semantically meaningful to the underlying retrieval system implementation. If true, the query may be changed to an alternative that is functionally similar, but does not contain special symbols used by the document retrieval system. The value is false by default. This may be provided as a key to theextendedOptions
map parameter inQuery.Factory.createExtendedQuery(String, Map)
with a Boolean value.- Since:
- API 4.202021 (Geneious 2020.2.1)
- See Also:
- Constant Field Values
-
-
Method Detail
-
addDocumentCopy
@MayReturnSlowly public final AnnotatedPluginDocument addDocumentCopy(AnnotatedPluginDocument document, jebl.util.ProgressListener progress) throws DatabaseServiceException
Add a copy of this document to this database. Any documents referenced by this document that are not already in the database will be added to a user invisible area of the database.Any documents strongly referenced (
AnnotatedPluginDocument.getStronglyReferencedDocuments()
) should the reference counted so that if the reference documents are removed they remain in the database but remain hidden from the user until they are no longer referenced.- Parameters:
document
- the document to add a copy ofprogress
- reports progress- Returns:
- the newly added document.
- Throws:
DatabaseServiceException
-
_addDocumentCopy
@MayReturnSlowly protected abstract AnnotatedPluginDocument _addDocumentCopy(AnnotatedPluginDocument annotatedDocument, jebl.util.ProgressListener progress) throws DatabaseServiceException
Implementaion method foraddDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement. The implementation must create a copy of the given annotatedDocument that has a different URN from the given annotatedDocument. This could be done like this:
Element annotatedDocumentXML= annotatedDocument.toXMLExcludingInternalPluginDocument(); AnnotatedPluginDocument annotatedDocumentCopy= DocumentUtilities.createAnnotatedPluginDocument(annotatedDocumentXML,pluginDocumentElementProvider,true);
but that doesn't deal with the complexities of referenced documents. Instead, the helper methodduplicateDocumentAndDealWithReferencedDocuments(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, ElementProvider, java.util.concurrent.atomic.AtomicReference, com.biomatters.geneious.publicapi.documents.URN)
should be used.- Throws:
DatabaseServiceException
-
getAssignerForCreatingUrn
@MustReturnPromptly protected java.lang.String getAssignerForCreatingUrn()
- Returns:
- a string that will be unique for a user accessing this database. A local database may return an empty string since only a single Geneious instance can access it at any given time.
The default implementation returns System.getProperty("user.name") or "unknown" if no such property is defined. The returned value will be
used as the
URN.assigner
field for newly created documents in this database. - Since:
- API 4.14 (Geneious 5.1)
-
getPrimaryDatabaseRoot
@MustReturnPromptly public WritableDatabaseService getPrimaryDatabaseRoot()
Returns the database root (seegetDatabaseRoot()
) for the primary database in this collection. For example when this is called on the local "Search Results" (which is a database root), it will return the root "Local Documents" folder. There should be a single primary database root for all databases that share documents (i.e. all the database folders for whichcontainsDocumentAnywhereWithinDatabase(com.biomatters.geneious.publicapi.documents.URN)
) returns true for a given URN) The default implementation returnsgetDatabaseRoot()
which is correct for any database which has only a single database root.- Returns:
- returns the database root (see
getDatabaseRoot()
for the primary database in this collection. - Since:
- API 4.63 (Geneious 5.6.3)
- See Also:
getDatabaseRoot()
-
createUrnForDocumentSoonToBeAdded
@MustReturnPromptly public URN createUrnForDocumentSoonToBeAdded()
Returns a URN which can be specified as used for document later added to this database usingaddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
. This is used for example when adding 2 documents to a database that store weak references (seeURN.toXMLAsWeakReference(String)
to each other. In order for them to reference each other correctly, they each need to know the URN the other document will have after it is added to the database.- Returns:
- a URN which can be specified as used for document later added to this database using
addDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
- Since:
- API 4.60 (Geneious 5.6.0)
-
createUrnForThisDatabase
@MustReturnPromptly protected URN createUrnForThisDatabase()
Returns a URN which can be specified as used for document later added to this database usingaddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
. This is used for example when adding 2 documents to a database that store weak references (seeURN.toXMLAsWeakReference(String)
to each other. In order for them to reference each other correctly, they each need to know the URN the other document will have after it is added to the database.Implementations should override this method if they need to provide their own URN scheme. If this method isn't overridden, then a URN will be created using
URN.generateUniqueLocalURN(String)
withgetAssignerForCreatingUrn()
- Returns:
- a URN which can be specified as used for document later added to this database using
addDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
- Since:
- API 4.201900 (Geneious 2019.0.0)
-
duplicateDocumentAndDealWithReferencedDocuments
@Deprecated @MayReturnSlowly protected final AnnotatedPluginDocument duplicateDocumentAndDealWithReferencedDocuments(AnnotatedPluginDocument document, ElementProvider pluginDocumentElementProvider, java.util.concurrent.atomic.AtomicReference<org.jdom.Element> returnedPluginDocumentElement) throws DatabaseServiceException
Deprecated.use #duplicateDocumentAndDealWithReferencedDocuments- Throws:
DatabaseServiceException
-
duplicateDocumentAndDealWithReferencedDocuments
@MayReturnSlowly protected final AnnotatedPluginDocument duplicateDocumentAndDealWithReferencedDocuments(AnnotatedPluginDocument document, ElementProvider pluginDocumentElementProvider, java.util.concurrent.atomic.AtomicReference<org.jdom.Element> returnedPluginDocumentElement, URN urnOfNewDocument) throws DatabaseServiceException
This as a helper method to facilitate implementing_addDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
. Duplicates the given document, automatically dealing with referenced documents by ignoring referenced documents that already exist within this database hierarchy somewhere and calling_addReferencedOnlyDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
on documents that are not currently within this database hierarchy. The returned document is a newly generated copy ofannotatedDocument
.returnedPluginDocumentElement
is used to return the modified internal PluginDocument (it may have been modified from the original document to handle changed references).pluginDocumentElementProvider.getElement()
will not be called by during this method, but may be called after the caller has returned from_addDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
. Immediately after calling this method, the caller should savereturnedPluginDocumentElement
to persistent storage.pluginDocumentElementProvider
should retrieve this value from persistent storage. It is still up to the caller of this method to reference count documents. Immediately after calling this method, the caller should useAnnotatedPluginDocument.getStronglyReferencedDocuments()
on the result and increment the reference count on each of those documents. For information on how decrementing reference counts should be handled, see_removeDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
. The caller of this method must also set the database on the returned document usingAnnotatedPluginDocument.setDatabase(DatabaseService)
. This method will not transfer any additional per-document XML onto the duplicated document, the caller must handle that separately.- Parameters:
document
- the document to be duplicatedpluginDocumentElementProvider
- used after returning from this method for retrieving the internal PluginDocumentreturnedPluginDocumentElement
- this is used for returning the internal PluginDocument to the caller.urnOfNewDocument
- the URN of the newly added document (which must have been returned from a previous call tocreateUrnForDocumentSoonToBeAdded()
, or null to automatically create one.- Returns:
- a duplicated version of
document
- Throws:
DatabaseServiceException
- if the internal PluginDocument ofdocument
cannot be loaded or if any of the other methods called by this method throw this exception.- Since:
- API 4.60 (Geneious 5.6.0)
-
addDocumentCopies
@MayReturnSlowly public final java.util.List<AnnotatedPluginDocument> addDocumentCopies(java.util.List<AnnotatedPluginDocument> documents, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Adds copies of one or more documents to this database folder. The documents may be in different folders within this database hierarchy. Equivalent to multiple calls toaddDocumentCopy(AnnotatedPluginDocument, ProgressListener)
but also provides support so that documents which reference each other (either strongly (AnnotatedPluginDocument.getStronglyReferencedDocuments()
) or weakly (AnnotatedPluginDocument.getWeaklyReferencedDocuments()
)) will correctly reference each other via the new URNs assigned to them for their new copies in the database. Use of this method over multiple calls to addDocumentCopy improves performance in databases with network latency (e.g. cloud, shared). If there is a error part way through executing this method, the database may choose to keep or remove any documents that have already been added. Any documents that remain added are made visible to the user. Any documents strongly referenced by these documents which are not already present in this database are also added in a hidden folder in the database. Note: to set a FolderViewDocumentsFolderViewDocuments
, first add it to a hidden folder usingaddDocumentCopies(DocumentsToAdd, ProgressListener)
and then callsetFolderViewDocument(AnnotatedPluginDocument, ProgressListener)
orsetFolderViewDocuments(Map, ProgressListener)
.- Parameters:
documents
- the documents to addprogressListener
- for reporting progress and canceling the request before it has completed- Returns:
- a list equal in size to the
documents
parameter, where each element is the result of adding a copy of the corresponding document from the documents parameter - Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
cachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase
@MayReturnSlowly public static void cachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(java.util.List<AnnotatedPluginDocument> documentsToCache, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
If any of thedocumentsToCache
are in a network database, their PluginDocument XML and additional XML may be preloaded by that database.This is achieved by delegating to
cachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
for all documents from each database root.If this method returns successfully you may assume that those documents' PluginDocument and additional XML will be cached until
uncachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List)
is called for those documents, even if there is an update to that document.
If this method throws an exception then none of the documents are considered cached and you do not have to calluncachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List)
- Parameters:
documentsToCache
- all the documents to cache. These may be in a mixture of databasesprogressListener
- for reporting progress and canceling the request before it has completed- Throws:
DatabaseServiceException
- if there is a problem caching data (due to a network connection or a document being deleted, or permission accessing data)- Since:
- API 4.202210 (Geneious 2022.1.0)
- See Also:
cachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
-
uncachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase
@MustReturnPromptly public static void uncachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(java.util.List<AnnotatedPluginDocument> documents)
Indicates that documents previously cached usingcachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List, ProgressListener)
may be removed from the cache when it is short on space. The implementation should only remove documents from the cache if an equal number of calls to cachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase and uncachePluginDocumentXmlAndAdditionalXmlLocally have been made for that document.- Parameters:
documents
- the documents for which XML caching is no longer required- Since:
- API 4.202210 (Geneious 2022.1.0)
-
addDocumentCopies
@MayReturnSlowly public final java.util.List<AnnotatedPluginDocument> addDocumentCopies(WritableDatabaseService.DocumentsToAdd documentsToAdd, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Adds copies of one or more documents to this database. Each document may be added to a different folder within this database hierarchy. Use this method rather thanaddDocumentCopies(List, ProgressListener)
either when adding documents to different folders within this database hierarchy, or when customizing the name of the document copies. If there is a error part way through executing this method, the database may choose to keep or remove any documents that have already been added. Any documents that remain added are made visible to the user. Any documents strongly referenced by these documents which are not already present in this database are also added in a hidden folder in the database. Note: to set a FolderViewDocumentsFolderViewDocuments
, first add it to a hidden folder usingaddDocumentCopies(DocumentsToAdd, ProgressListener)
and then callsetFolderViewDocument(AnnotatedPluginDocument, ProgressListener)
orsetFolderViewDocuments(Map, ProgressListener)
.- Parameters:
documentsToAdd
- the documents to add. The destination databases for each document must all be in the same database hierarchy as each other.progressListener
- for reporting progress and canceling the request before it has completed- Returns:
- a list equal in size to documentsToAdd, where each element is the result of adding a copy of the corresponding document from documentsToAdd
- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
implementsEfficientBatchMethods
public boolean implementsEfficientBatchMethods()
Indicates that this database has implementations of methods for efficiently working with batches of documents. This is important for databases with latency (cloud, shared). A database which returns true from this method must implement: And is strongly recommend (but not strictly required) to override the following methods with efficient implementationsgetDocumentURNsOfDocumentsContainedAnywhereWithinDatabase(Collection, ProgressListener)
(the default implementations delegates to multiple calls tocontainsDocumentAnywhereWithinDatabase(URN)
so is inefficient)cachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
(the default implementation does nothing)_removeDocuments(List, ProgressListener)
createChildFolders(List, ProgressListener)
setFolderViewDocuments(Map, ProgressListener)
getAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, ProgressListener)
_saveDocumentsAnywhereWithinDatabase(List, boolean, ProgressListener)
addHiddenElements(Collection, ProgressListener)
addHiddenElements(Map, ProgressListener)
getHiddenElements(Collection, ProgressListener)
updateHiddenElements(Map, ProgressListener)
removeHiddenElements(Collection, ProgressListener)
- Returns:
- true if this database has implementations of methods for efficiently working with batches of documents
- Since:
- API 4.202210 (Geneious 2022.1.0)
-
addDocumentsImplementation
@MayReturnSlowly protected void addDocumentsImplementation(java.util.List<WritableDatabaseService.DocumentToAdd> documents, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Only the implementation ofaddDocumentCopies(List, ProgressListener)
should call this method. AWritableDatabaseService
which returns true fromimplementsEfficientBatchMethods()
must implement this method. The implementation is responsible for reference counting allAnnotatedPluginDocument.getStronglyReferencedDocuments()
(seeaddDocumentCopy(AnnotatedPluginDocument, ProgressListener)
) and creating an ElementProvider which will load this document's PluginDocument XML and for returning this document from future calls togetDocument(URN)
FolderView documents may be provided to this method, but these should not be set as an active FolderView document untilsetFolderViewDocument(AnnotatedPluginDocument, ProgressListener)
(orsetFolderViewDocuments(Map, ProgressListener)
) is called later. It does not matter which WritableDatabaseService folder in the database hierarchy that setFolderViewDocuments is called on. Only the WritableDatabaseService folders specified in the folderViewDocuments are used. The implementation is also required to save all additional XMLAnnotatedPluginDocument.getAdditionalXml(boolean, ProgressListener)
present on each document to the database. Finally, on each document the implementation must callAnnotatedPluginDocument.setPluginDocumentElementProvider(elementProvider, true)
to provide an ElementProvider which can later load the PluginDocument's XMLAnnotatedPluginDocument.clearInternalDocumentCache()
AnnotatedPluginDocument.setDatabase(DatabaseService)
setDatabase(documentToAdd.getDestination()==null ? getDatabaseRoot() : newDocument.getDestination())
- Parameters:
documents
- the documents to add. The documents will be sorted so that no document appears before other documents which it strongly references.progressListener
- for reporting progress and canceling the request before it has completed- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
getDocumentURNsOfDocumentsContainedAnywhereWithinDatabase
@MayReturnSlowly public java.util.List<URN> getDocumentURNsOfDocumentsContainedAnywhereWithinDatabase(java.util.Collection<URN> urns, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Identifies which of the given URNs are for documents which are in this database. Equivalent to multiple calls tocontainsDocumentAnywhereWithinDatabase(URN)
. Use of this method over multiple calls to containsDocumentAnywhereWithinDatabase improves performance in databases with network latency (e.g. cloud, shared) It does not matter which WritableDatabaseService folder in the database hierarchy that getDocumentURNsOfDocumentsContainedAnywhereWithinDatabase is called on.- Parameters:
urns
- the URNs of documents to test whether or not they are in this databaseprogressListener
- for reporting progress and canceling the request before it has completed- Returns:
- the URNs which are present in this database. The elements in this list will be a subset of the urns parameter
- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
_addReferencedOnlyDocumentCopy
@MayReturnSlowly protected abstract AnnotatedPluginDocument _addReferencedOnlyDocumentCopy(AnnotatedPluginDocument annotatedDocument, jebl.util.ProgressListener progress) throws DatabaseServiceException
This method is only called from the helper methodduplicateDocumentAndDealWithReferencedDocuments(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, ElementProvider, java.util.concurrent.atomic.AtomicReference, com.biomatters.geneious.publicapi.documents.URN)
. It should add copy of the given document to an invisible folder independent area of the database. Implementations can do mostly the same as they do for_addDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
except the document is added to an invisible folder independent area of the database rather than a standard folder. Note: Any implementation must also callcopyAdditionalXmlToNewDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument)
. An easy way to ensure this is to calladdDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
oraddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map)
because they will callcopyAdditionalXmlToNewDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument)
as part of their implementation.- Parameters:
annotatedDocument
- the document to copied and addedprogress
- reports progress- Returns:
- the newly added document.
- Throws:
DatabaseServiceException
-
removeDocument
@MayReturnSlowly public final void removeDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress) throws DatabaseServiceException
Remove a document from this database. The document to be removed may be a document that resides anywhere in this database hierarchy, not necessarily directly in this WritableDatabaseService (i.e any child ofgetDatabaseRoot()
) or a hidden folder in that database) The database implementation of removeDocument must callAnnotatedPluginDocument.setDatabase(null)
on the document if it is successfully removed.If there are multiple documents to be removed then consider using
removeDocuments(List, ProgressListener)
instead for better performance.- Parameters:
document
- a document previously returned from eitheraddDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
orgetDocument(com.biomatters.geneious.publicapi.documents.URN)
or one of the retrieve methods viaRetrieveCallback.add(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, java.util.Map)
.progress
- to report progress if removing the document takes time.- Throws:
DatabaseServiceException
- See Also:
removeDocuments(List, ProgressListener)
-
removeDocuments
@MayReturnSlowly public final void removeDocuments(java.util.List<AnnotatedPluginDocument> documentsToRemove, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Removes one or more documents from this database. Equivalent to multiple calls toremoveDocument(AnnotatedPluginDocument, ProgressListener)
If this call fails the caller may not assume that any changes have or have not happened, and the implementation may roll back or leave any documents in their deleted state. Use of this method over multiple calls to removeDocument improves performance in databases with network latency (e.g. cloud, shared) If there is an error part way through executing this method, the database may choose to leave or restore any documents that have already been deleted.
If there is no error then all the documents passed in can be assumed to have been successfully deleted.- Parameters:
documentsToRemove
- all the documents to be removed. These documents may reside anywhere in this database hierarchy, not necessarily directly in this WritableDatabaseServiceprogressListener
- for reporting progress and canceling the request before it has completed- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
- See Also:
removeDocument(AnnotatedPluginDocument, ProgressListener)
-
_removeDocument
@MayReturnSlowly protected abstract void _removeDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress) throws DatabaseServiceException
Implementation method forremoveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement. The implementation must ensure that it deals with referenced documents correctly. (seeduplicateDocumentAndDealWithReferencedDocuments(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, ElementProvider, java.util.concurrent.atomic.AtomicReference, com.biomatters.geneious.publicapi.documents.URN)
).- If a document is removed that has a reference count > 0, it should instead be moved to a "hidden referenced only documents" folder.
- If a document is really being removed instead of being moved to the referenced only documents folder, then the reference count of each document referenced by that document should be decremented.
- If the reference count of any document reaches 0 and it is in the "hidden referenced only documents" then it should be removed (and step 2 applied to it)
- Note that documents can also be moved out of the "hidden referenced only documents folder" by clients of the WritableDatabaseService using
moveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
- Documents really removed from the database must have
setDatabase(null)
called on them before returning from this method. Documents moved to the hidden referenced only documents must have their database set to the root database.
- Throws:
DatabaseServiceException
-
_removeDocuments
@MayReturnSlowly protected void _removeDocuments(java.util.List<AnnotatedPluginDocument> documentsToRemove, jebl.util.ProgressListener progress) throws DatabaseServiceException
Implementation method forremoveDocuments(List, ProgressListener)
that subclasses should implement for batch document removal.- If a document is removed that has a reference count > 0, it should instead be moved to a "hidden referenced only documents" folder.
- If a document is being deleted instead of being moved to the referenced only documents folder, then the reference count of each document referenced by that document should be decremented.
- If the reference count of any document reaches 0 and it is in the "hidden referenced only documents" then it should be removed (and step 2 applied to it)
- Note that documents can also be moved out of the "hidden referenced only documents folder" by clients of the
WritableDatabaseService using
moveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
- Documents really removed from the database must have
setDatabase(null)
called on them before returning from this method. Documents moved to the hidden referenced only documents must have their database set to the root database.
Deletion constraints
When Geneious is informed about a document deletion it may immediately try to change and save other document that refer to it, due to this the implementation must ensure that whenAnnotatedPluginDocument.setDatabase(DatabaseService)
is called, all the referenced documents either: (a) are deleted and have had their database set to null; or (b) a future call toAnnotatedPluginDocument.save()
on that referenced document will succeed.To assist with this, Geneious will order the documentsToRemove so that no document appears before other documents which it strongly references.
For Example:
In all of these examples (and documentation) removed and permanently deleted have different meanings. Removed means the document is referenced, but not in a visible folders. Permanently deleted means the data has been erased.Assume there is a set of documents A, B, C and Result, where Result strongly references all of A, B and C.
IfremoveDocuments(List, ProgressListener)
was called withA, Result, C, B
, then this method will be called with the documentsToRemove being similar toA, C, B, Result
.
From here there are multiple options for implementing the deletion, depending on the tools available to it:-
Remove the documents one-by-one, in any order, notifying Geneious after each removal. For example:
- The referenced document (A) is removed first. It becomes a referenced only document and so should have it's database set to the root service.
- A is removed:
A.setDatabase(rootService)
-
Result is permanently deleted, causing A to become permanently deleted:
A.setDatabase(null)
Result.setDatabase(null)
- B is permanently deleted:
B.setDatabase(null)
- C is permanently deleted:
C.setDatabase(null)
-
Remove all of the documents in a single transaction, then notify geneious in the same order the
documents were passed in
- The ordering of the documents passed in will ensure the constraints (a) for permanent deletion or (b) for documents that are not permanently deleted are held as appropriate
-
Documents A, B, C and Result are permanently deleted.
A.setDatabase(null)
B.setDatabase(null)
C.setDatabase(null)
Result.setDatabase(null)
-
Remove the documents in batches or groups
- This is a combination of the above two options. The implementation must inform Geneious of the final state of all all documents after each batch is completed
- Parameters:
documentsToRemove
- The documents to be removed, they are ordered so that no document appears before any document that it strongly references.- Throws:
DatabaseServiceException
- Since:
- API 4.202230 (Geneious 2022.3.0)
-
moveDocument
@MayReturnSlowly public final boolean moveDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress) throws DatabaseServiceException
Move a document that currently reside elsewhere in this database to this folder.- Parameters:
document
- the document to be moved. This may be a document that is in an invisible region of the database (i.e. only referenced by other documents), in which case it is being moved to a user visible region of the database.progress
- reports progress- Returns:
- true if the document was moved, false if the document is already in this database folder.
- Throws:
DatabaseServiceException
-
_moveDocument
@MayReturnSlowly protected abstract boolean _moveDocument(AnnotatedPluginDocument document, jebl.util.ProgressListener progress) throws DatabaseServiceException
Implementation method formoveDocument(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
that subclasses should implement.- Throws:
DatabaseServiceException
-
saveDocument
@MayReturnSlowly public abstract boolean saveDocument(AnnotatedPluginDocument document, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progress) throws DatabaseServiceException
A document that is already in this database has been modified in memory and should now be saved to permanent storage. Only internal Geneious code should call this method as is it is called automatically as a result of calls to AnnotatedPluginDocument.save(), AnnotatedPluginDocument.saveDocument() or AnnotatedPluginDocument.batchSave(Collection, boolean, ProgressListener). Use those methods as entry points instead of this one.Note: the document passed to this method may not be a direct child of this database service. The implementation must support the ability to save a document from any child service.
- Parameters:
document
- the document that has changed. This is the same AnnotatedPluginDocument instance returned from eitheraddDocumentCopy(AnnotatedPluginDocument, ProgressListener)
orgetDocument(URN)
or one of the retrieve methods via RetrieveCallback.add(AnnotatedPluginDocument, Map).onlyAnnotatedDocumentHasChanged
- Sometimes only the AnnotatedPluginDocument rather than the internal PluginDocument has changed. In this case this parameter is true and the database can perform more efficient storage if it stores the AnnotatedPluginDocument separately from the PluginDocument. If this parameter is false, both the AnnotatedPluginDocument and the internal PluginDocument should be saved.progress
- to report progress if saving the document takes time. The progress listener may also request the save be cancelled. In this case the DatabaseService should either revert the stored version of the document to its previous state and return false or continue with saving and return true, whichever is faster. It is not acceptable to leave the stored document in a partially saved state when cancelling.- Returns:
- true if the document was successfully saved. false if the ProgressListener cancelled the save. If the save fails for any other reason a DatabaseServiceException should be thrown.
- Throws:
DatabaseServiceException
- if the document cannot be saved for any reason.
-
saveDocumentsAnywhereWithinDatabase
@MayReturnSlowly public final boolean saveDocumentsAnywhereWithinDatabase(java.util.List<AnnotatedPluginDocument> documentsToSave, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Request to save multiple documents that already belong to any service beneath thisdatabase root
. This method does not guarantee that all the requested documents are successfully saved, though it makes a best attempt to do so. Only internal Geneious code should call this method as is it is called automatically as a result of calls to AnnotatedPluginDocument.save(), AnnotatedPluginDocument.saveDocument() or AnnotatedPluginDocument.batchSave(Collection, boolean, ProgressListener). Use those methods as entry points instead of this one. ADatabaseServiceException
is thrown if at least one document could not be saved (or could not be known to have saved successfully depending on implementation detail). The default implementation simply callssaveDocument(AnnotatedPluginDocument, boolean, ProgressListener)
iteratively on the supplied documents. Subclasses are strongly encouraged to provide their own implementation if batch saving documents can be performance-optimized. It is not required thatimplementsEfficientBatchMethods()
returns true in order to override this method, but is strongly encouraged to do so if the database supports other batch operations as well.- Parameters:
documentsToSave
- List of documents to be saved. These documents must all belong to the same root service as this service itself.onlyAnnotatedDocumentHasChanged
- Sometimes only the AnnotatedPluginDocument rather than the internal PluginDocument has changed. In this case this parameter is true and the database can perform more efficient storage if it stores the AnnotatedPluginDocument separately from the PluginDocument. If this parameter is false, both the AnnotatedPluginDocument and the internal PluginDocument should be saved.progressListener
- to report progress if saving the document takes time. The progress listener may also request the save be cancelled. In this case this method will return false and may do one of the following, whichever is convenient:- Revert the stored version of the documents to their previous state
- Skip saving remaining documents but preserve the saved contents on existing documents
- Ignore the cancellation request and continue with saving anyway (not recommended, but tolerable if implementing cancellation is difficult)
- Returns:
true
if all documents have been saved successfully,false
if the action is cancelled through itsprogressListener
.- Throws:
DatabaseServiceException
- If at least one document could not be saved, or could not be known to have saved successfully for any reason other than progress cancellation. If this service uses a network-backed storage, the exception will indicate whether the problem stems from network issues by using DatabaseServiceException.isNetworkConnectionError().- Since:
- Geneious 4.202230 (Geneious 2022.3.0)
-
_saveDocumentsAnywhereWithinDatabase
protected boolean _saveDocumentsAnywhereWithinDatabase(java.util.List<AnnotatedPluginDocument> documentsToSave, boolean onlyAnnotatedDocumentHasChanged, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
SeesaveDocumentsAnywhereWithinDatabase(List, boolean, ProgressListener)
. Implementations that support efficient handling of document saving in bulk should override this method.- Throws:
DatabaseServiceException
- Since:
- Geneious 4.202230 (Geneious 2022.3.0)
-
saveAdditionalPerDocumentXml
@MayReturnSlowly public void saveAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.lang.String key, boolean isPerUser, org.jdom.Element element, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Save some additional XML associated with a particular document. This is saved separately to the document itself to avoid impacting performance. The XML is recovered usinggetAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, ProgressListener)
IMPORTANT: When a document is deleted the associated additional XML should be deleted too.- Parameters:
document
- the document this XML is associated withkey
- a unique key that the XML should be stored under (unique to this document but the same key will likely occur on many documents)*isPerUser
- If true then the XML should only be saved for the current user. If false then the XML should be stored globally (accessible by all users). This parameter should be ignored by databases that don't allow multiple simultaneous users.element
- the XML data to save. This may be null to delete the existing additional XML associated with the given key.progressListener
- for progress reporting and canceling. Never null (useProgressListener.EMPTY
instead).- Throws:
DatabaseServiceException
- if the XML couldn't be saved for any reason- See Also:
saveAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, Map, ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, List, boolean, ProgressListener)
-
saveAdditionalPerDocumentXml
@MayReturnSlowly public void saveAdditionalPerDocumentXml(AnnotatedPluginDocument document, boolean isPerUser, java.util.Map<java.lang.String,ElementProvider> elementProviders, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Save some additional XML associated with a particular document. This method is similar tosaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
except that this method allows storing multiple additional XML entries with a single method invocation, potentially allowing the database to handle it more efficiently than multiple calls tosaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
- Parameters:
document
- the document this XML is associated withisPerUser
- If true then the XML should only be saved for the current user. If false then the XML should be stored globally (accessible by all users). This paramater should be ignored by databases that don't allow multiple simultaneous users.elementProviders
- A mapping from a unique key to store the data under to anElementProvider
that can be used to retrieve the XML element to store. If a null value is specified in the map then the element corresponding to the specified key will be deleted from the database.progressListener
- for progress reporting and canceling. Progress must include retrieving the elements from the givenElementProvider
s as well as saving to the database. Never null (useProgressListener.EMPTY
instead).- Throws:
DatabaseServiceException
- if the XML couldn't be saved for any reason- Since:
- API 4.60 (Geneious 5.6.0)
- See Also:
saveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, java.util.List, boolean, ProgressListener)
-
getAdditionalPerDocumentXml
@MayReturnSlowly public org.jdom.Element getAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.lang.String key, boolean isPerUser, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Get some additional XML associated with a particular document that has been saved usingsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
.- Parameters:
document
- the document this XML is associated withkey
- the unique key that the XML is stored under (unique to this document but the same key will likely occur on many documents)isPerUser
- If true then only return XML which has been stored by passing in true for isPerUser onsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
. If false then only return XML which has been stored by passing in false to the save method. This parameter should be ignored by databases that don't allow multiple simultaneous users.progressListener
- for progress reporting and canceling. Never null (useProgressListener.EMPTY
instead).- Returns:
- the XML associated with the given document and key or null if none
- Throws:
DatabaseServiceException
- if the XML couldn't be loaded for any reason- See Also:
saveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
,saveAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, Map, ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, List, boolean, ProgressListener)
-
getAdditionalPerDocumentXml
@MayReturnSlowly public java.util.Map<java.lang.String,ElementProvider> getAdditionalPerDocumentXml(AnnotatedPluginDocument document, java.util.List<java.lang.String> keys, boolean isPerUser, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Get some additional XML associated with a particular document that has been saved usingsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, ProgressListener)
orsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, Map, ProgressListener)
This method is similar togetAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, ProgressListener)
except that this method allows retrieving multiple additional XML entries with a single method invocation, potentially allowing the database to handle it more efficiently than multiple calls to this method.- Parameters:
document
- the document this XML is associated withkeys
- a list of unique keys that the XML has been stored under (unique to this document but the same key will likely occur on many documents)isPerUser
- If true then only return XML which has been stored by passing in true for isPerUser onsaveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, jebl.util.ProgressListener)
. If false then only return XML which has been stored by passing in false to the save method. This paramater should be ignored by databases that don't allow multiple simultaneous users.progressListener
- for progress reporting and canceling. Never null (useProgressListener.EMPTY
instead).- Returns:
- A mapping from unique key to an
ElementProvider
that can be used to retrieve the XML data associated with this document for any elements that were found in the database. If there was no element associated with a key in the provided list, then there will be no entry in the resulting map. The returned map must not strongly reference any Elements. Instead each ElementProvider should load the Element into memory from local disk storage. Network databases should download Elements to temporary local storage before returning from getAdditionalPerDocumentXml - Throws:
DatabaseServiceException
- if providers for the XML couldn't be retrieved for any reason- Since:
- API 4.60 (Geneious 5.6.0)
- See Also:
saveAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, Element, jebl.util.ProgressListener)
,saveAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, java.util.Map, jebl.util.ProgressListener)
,getAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, jebl.util.ProgressListener)
-
getAdditionalPerDocumentXml
@MayReturnSlowly public java.util.Map<java.lang.String,ElementProvider> getAdditionalPerDocumentXml(AnnotatedPluginDocument document, boolean isPerUser, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Gets all additional XML for a single document. SeegetAdditionalPerDocumentXml(AnnotatedPluginDocument, List, boolean, ProgressListener)
for a detailed description of the meaning of this and all parameters.- Parameters:
document
- the document to get XML forisPerUser
- if the XML is specific to this database user rather than shared between all usersprogressListener
- for progress reporting and canceling. Never null (useProgressListener.EMPTY
instead).- Returns:
- A mapping from unique key to an
ElementProvider
that can be used to retrieve the XML data associated with this document for any elements that were found in the database. If there was no element associated with a key in the provided list, then there will be no entry in the resulting map. The returned map must not strongly reference any Elements. Instead each ElementProvider should load the Element into memory from local disk storage. Network databases should download Elements to temporary local storage before returning from getAdditionalPerDocumentXml - Throws:
DatabaseServiceException
- if providers for the XML couldn't be retrieved for any reason- Since:
- API 4.202210 (Geneious 2022.1.0)
- See Also:
cachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
-
getAdditionalPerDocumentXmlKeys
@MayReturnSlowly public java.util.List<java.lang.String> getAdditionalPerDocumentXmlKeys(boolean isPerUser, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Get a list of all keys that additional XML has been stored under on any document.- Parameters:
isPerUser
- If true return a list of keys for additional XML that has been stored by passing in true for isPerUser onsaveAdditionalPerDocumentXml(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, String, boolean, Element, jebl.util.ProgressListener)
. If false then only return keys which have been stored by passing in false to the save method. This paramater should be ignored by databases that don't allow multiple simultaneous users.progressListener
- for progress reporting and canceling. Never null (useProgressListener.EMPTY
instead).- Returns:
- a list of all keys that additional XML has been stored under on any document. Never null.
- Throws:
DatabaseServiceException
- If the operation could not be completed for any reason.
-
createChildFolder
@MayReturnSlowly public abstract WritableDatabaseService createChildFolder(java.lang.String name) throws DatabaseServiceException
Creates a child DatabaseService. For example, with a LocalDatabaseService creates a sub folder. IfgetChildService(name)
already exists, then this method returns it. Implementations must check if a folder is created within a deleted folder and throwDatabaseServiceException
.- Parameters:
name
- the name of the child DatabaseService to create- Returns:
- the newly created child DatabaseService
- Throws:
DatabaseServiceException
- if the folder can't be created.
-
canMoveTo
@MustReturnPromptly public abstract boolean canMoveTo(WritableDatabaseService destination)
Checks whether the service can be moved to a new destination. The default implementation always returns false. Implementations of this method should usegetReasonCantMoveTo(WritableDatabaseService)
in addition to any other checks they need to perform. For example, they probably also only allow moving to a service of the same root database. When the user drags a service into another, if this method returns false, the drop action will copy the service and its descendants instead. This functionality is handled internally.- Parameters:
destination
- the destination to put this folder inside.- Returns:
- true if it can be moved
- See Also:
moveTo(WritableDatabaseService)
-
moveTo
@MayReturnSlowly public abstract void moveTo(WritableDatabaseService destination) throws DatabaseServiceException
Move this entire database folder to a new location. If successful, this instance of the service is no longer valid and the new service can be obtained by callingdestination.getChildService(folderName)
. Implementations of this method should usegetReasonCantMoveTo(WritableDatabaseService)
in addition to any other checks they need to perform to confirm the destination is valid. For example, they probably also only allow moving to a service of the same root database.- Parameters:
destination
- the destination to put this folder inside.- Throws:
DatabaseServiceException
- See Also:
canMoveTo(WritableDatabaseService)
-
getReasonCantMoveTo
@MustReturnPromptly protected java.lang.String getReasonCantMoveTo(WritableDatabaseService destination)
Returns the reason why we can not move this folder to destination, or null if we can move. This is a helper method that implementations ofmoveTo(WritableDatabaseService)
andcanMoveTo(WritableDatabaseService)
should use.- Parameters:
destination
- the folder to move to- Returns:
- the reason why we can not move this folder to destination, or null if we can move
- Since:
- API 4.1100 (Geneious 11.0.0)
-
containsDocumentAnywhereWithinDatabase
@MayReturnSlowly public abstract boolean containsDocumentAnywhereWithinDatabase(URN documentURN) throws DatabaseServiceException
Determine if this database (including any other folders and any user invisible folders) contains a document with this URN This method should return the same information no matter where in the DatabaseService tree it is called. SeegetDocumentURNsOfDocumentsContainedAnywhereWithinDatabase(Collection, ProgressListener)
for a more efficient way of batch calling this method.- Parameters:
documentURN
- the URN of the document- Returns:
- true if this database (including any other folders and any user invisible folders) contains a document with this URN
- Throws:
DatabaseServiceException
- See Also:
containsDocumentInThisFolder(URN)
,getDocumentURNsOfDocumentsContainedAnywhereWithinDatabase(Collection, ProgressListener)
-
containsDocumentInThisFolder
@MayReturnSlowly public boolean containsDocumentInThisFolder(URN documentURN) throws DatabaseServiceException
Returns true if this folder contains a document with this URN. If the document is in a sub-folder, returns false. Note: The default implementation retrieves the document and checks thatAnnotatedPluginDocument.getDatabase()
is this. This does not work for hidden folders (seegetHiddenFolder
), so any database implementation that supports hidden folders must override the implementation of this method. This method should return true if the document is in the hidden folder even thoughAnnotatedPluginDocument.getDatabase()
will be returning the root database.- Parameters:
documentURN
- the URN of the document- Returns:
- true if this folder contains a document with this URN
- Throws:
DatabaseServiceException
- Since:
- API 4.1101 (Geneious 11.0.1)
- See Also:
containsDocumentAnywhereWithinDatabase(URN)
-
getDocumentLocation
@MayReturnSlowly public abstract WritableDatabaseService getDocumentLocation(URN documentURN) throws DatabaseServiceException
If this database contains this document in any user visible folder returns the WritableDatabaseService representing the folder that contains it. This method should return the same information no matter where in the DatabaseService tree it is called.- Parameters:
documentURN
- the URN of the document- Returns:
- the WritableDatabaseService representing the folder that contains this document or null if the database does not contain it or if it is in a user invisible region of the database.
- Throws:
DatabaseServiceException
-
getChildService
@MustReturnPromptly public final WritableDatabaseService getChildService(java.lang.String name)
Gets a child service whosegetFolderName()
==name
. This method is case insensitive. WritableDatabaseServices may not have 2 folders with identical names apart from case (even in operating systems that support it because we want Geneious folder structures to be portable to another OS. For example exporting and importing entire databases. However, old databases from earlier versions of Geneious may contain folders with identical names apart from case.- Parameters:
name
- the name of the child service. This may include children of the child by separating names with '/' characters. e.g.childFolderName/grandChildFolderName
- Returns:
- a child service whose
getFolderName()
isname
or null if one is not found.
-
getUniqueID
@MustReturnPromptly public final java.lang.String getUniqueID()
Get a unique ID for this database service. This will be of the formgetRootUniqueId()
[/FolderName[/FolderName[...]]]- Specified by:
getUniqueID
in classGeneiousService
- Returns:
- a unique ID for this database service.
-
getFolderName
@MustReturnPromptly public abstract java.lang.String getFolderName()
Get the name of this DatabaseService folder displayed to the user. For non-root folders, this name is used to construct thegetUniqueID()
, for this folder. SeeGeneiousService.getName()
for a discussion of the differences between this method and it.- Returns:
- the name of this DatabaseService folder. It must not contain a '/' character
-
getRootUniqueId
@MustReturnPromptly protected abstract java.lang.String getRootUniqueId()
Get the unique ID for the root folder of this database.- Returns:
- the unique ID for the root folder of this database.
-
getDocument
@MayReturnSlowly public final AnnotatedPluginDocument getDocument(URN urn) throws DatabaseServiceException
Get a document that exists anywhere within this database (including other folders) with a particular URN. This method is a convenience method that is implemented by callingretrieve(com.biomatters.geneious.publicapi.documents.URN[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback)
- Parameters:
urn
- the urn of the document to retrieve- Returns:
- the document or null if this database does not contain a document with this URN.
- Throws:
DatabaseServiceException
- if an error occurs while accessing the database.
-
getDocuments
@MayReturnSlowly public final java.util.List<AnnotatedPluginDocument> getDocuments(java.util.List<URN> documentUrnsToRetrieve) throws DatabaseServiceException
Gets multiple documents that exists anywhere within this database (including other folders) identified by their URNs. This method is a convenience method that is implemented by callingretrieve(com.biomatters.geneious.publicapi.documents.URN[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback)
- Parameters:
documentUrnsToRetrieve
- The URN of the documents to retrieve- Returns:
- List of available documents retrieved by their URN. The size of this list may differ from the list of URNs if at least one document cannot be found.
- Throws:
DatabaseServiceException
- If an error occurs while accessing the database.- Since:
- Geneious 4.202210 (Geneious 2022.1.0)
-
setAllowChangingFolderProperties
@MustReturnPromptly public final void setAllowChangingFolderProperties(boolean allow)
Prevent this folder from being moved, renamed or removed. By default all folders are allowed to have their properties changed, except the root folder.- Parameters:
allow
- false to prevent this folder from being moved, renamed or removed.
-
allowChangingFolderProperties
@MustReturnPromptly protected final boolean allowChangingFolderProperties()
Are the properties of this folder allowed to be changed ( moving, renaming, deleting)- Returns:
- true if the properties of this folder allowed to be changed
-
canRemoveChildFolder
@MustReturnPromptly public final boolean canRemoveChildFolder(java.lang.String name)
Can the child folder with this name be removed.- Parameters:
name
- the name of the child folder to be removed.- Returns:
- true if the child folder with this name be removed.
-
_canRemoveChildFolder
@MustReturnPromptly protected boolean _canRemoveChildFolder(java.lang.String name)
Sub-classes may override this method to makecanRemoveChildFolder(String)
prevent folders from being removed. For example, if the child service has its own write permissions that could stop it being deletable, even if its parentcanModifySubFolders()
, make that check in this method. The default implementation returns true.- Parameters:
name
- the name of the child folder to be removed.- Returns:
- true if the child folder with this name be removed.
-
getDatabaseRoot
@MustReturnPromptly public final WritableDatabaseService getDatabaseRoot()
Get the root folder of this database folder hierarchy. For example, "Local Documents" and "Searches" are database roots for the local database. "Shared Databases" is NOT a database root. Each of the child folders of "Shared Databases" are database roots.- Returns:
- the root folder of this database folder hierarchy.
- See Also:
getPrimaryDatabaseRoot()
-
isDeleted
@MustReturnPromptly public boolean isDeleted()
Get whether this database folder is deleted. A database folder is defined to be deleted if it is not a descendant of a writable database service root.- Returns:
- whether this folder is deleted
- Since:
- API 4.700 (Geneious 7.0.0)
- See Also:
PluginUtilities.getWritableDatabaseServiceRoots()
-
removeChildFolder
@MayReturnSlowly public abstract void removeChildFolder(java.lang.String folderName) throws DatabaseServiceException
Removes a child folder with this folder name. This method only removes non-hidden folders.- Parameters:
folderName
- the name of the child folder to be removed. SeegetFolderName()
- Throws:
DatabaseServiceException
- if the folder is unable to be removed for any reason.
-
removeChildFolder
@MayReturnSlowly public void removeChildFolder(java.lang.String folderName, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Removes a child folder with this folder name. This method only removes non-hidden folders.- Parameters:
folderName
- the name of the child folder to be removed. SeegetFolderName()
progressListener
- for reporting progress and cancelling- Throws:
DatabaseServiceException
- if the folder is unable to be removed for any reason.- Since:
- API 4.14 (Geneious 5.1)
-
renameFolder
@MayReturnSlowly public abstract void renameFolder(java.lang.String newName) throws DatabaseServiceException
Rename this folder. If successful, this instance of the service may no longer be valid and the new service can be obtained by callingparent.getChildService(folderName)
. The newly renamed folder may not be available immediately due to delayed firing of listeners. To get the new folder after calling this method, the calling code should wait (in a non-swing thread) untilparent.getChildService(folderName)
returns non-null. UsecanBeRenamed()
to determine whether this folder may be renamed.- Parameters:
newName
- the new name of this folder- Throws:
DatabaseServiceException
- if the folder is unable to be renamed for any reason.- See Also:
canBeRenamed()
-
addAdditionalAction
@MustReturnPromptly public final void addAdditionalAction(GeneiousAction action)
Adds an additional action that this service will provide viagetActionsEnabledWhenServiceSelected()
- Parameters:
action
- the action to be added
-
removeAdditionalAction
@MustReturnPromptly public final void removeAdditionalAction(GeneiousAction action)
Removes an additional action (added previously usingaddAdditionalAction(com.biomatters.geneious.publicapi.plugin.GeneiousAction)
) that this service provides. Note: Currently only works with pop-up menus due to firing of menus changing for menu bars not being implemented.- Parameters:
action
- the action to be removed
-
getActionsEnabledWhenServiceSelected
@MustReturnPromptly public final java.util.List<GeneiousAction> getActionsEnabledWhenServiceSelected()
WritableDatabaseService implements this as a final method to add any additional actions supplied toaddAdditionalAction(com.biomatters.geneious.publicapi.plugin.GeneiousAction)
combined with the actions provided by sub-classes in_getActionsEnabledWhenServiceSelected()
. Furthermore this method includes a standard set of actions that are available on every WritableDatabaseService. These actions are: "New folder", "Delete folder", "Rename folder", "Move folder", "Export folder"- Overrides:
getActionsEnabledWhenServiceSelected
in classGeneiousService
- Returns:
- list of actions that should be enabled when this service is selected.
-
_getActionsEnabledWhenServiceSelected
@MustReturnPromptly protected java.util.List<GeneiousAction> _getActionsEnabledWhenServiceSelected()
Sub-classes should override this to provide actions as defined byGeneiousService.getActionsEnabledWhenServiceSelected()
. Ths results of this method are combined with any additional actions provided toaddAdditionalAction(com.biomatters.geneious.publicapi.plugin.GeneiousAction)
to create the results forgetActionsEnabledWhenServiceSelected()
. The default implementation returns an empty list.- Returns:
- list of actions that should be enabled when this service is selected.
-
_getIcons
@MustReturnPromptly protected abstract Icons _getIcons()
Sub-classes should override this to provide icons as defined byGeneiousService.getIcons()
. Ths results of this method are combined with any additional overlay icons provided toaddOverlayIcons(com.biomatters.geneious.publicapi.plugin.Icons)
to create the results forgetIcons()
.- Returns:
- icons for this service
-
getIcons
@MustReturnPromptly public final Icons getIcons()
WritableDatabaseService implements this as a final method to add any additional icons supplied toaddOverlayIcons(com.biomatters.geneious.publicapi.plugin.Icons)
combined with the icons provided by sub-classes in_getIcons()
- Specified by:
getIcons
in classGeneiousService
- Returns:
- icons for this service
-
addOverlayIcons
@MustReturnPromptly public final void addOverlayIcons(Icons icons)
add an icon which will be drawn on top of the standard database icon
-
removeOverlayIcons
@MustReturnPromptly public final void removeOverlayIcons(Icons icons)
remove an icon added usingaddOverlayIcons(com.biomatters.geneious.publicapi.plugin.Icons)
-
addAdditionalHelp
@MustReturnPromptly public final void addAdditionalHelp(java.lang.String additionalHelpText)
Add some additional help to append to the end of the standard help this folder returned fromgetHelp()
- Parameters:
additionalHelpText
- text which can include HTML tags
-
removeAdditionalHelp
@MustReturnPromptly public final void removeAdditionalHelp(java.lang.String additionalHelpText)
Removed some additional help added usingaddAdditionalHelp(String)
- Parameters:
additionalHelpText
- the text added usingaddAdditionalHelp(String)
-
getHelp
@MustReturnPromptly public final java.lang.String getHelp()
WritableDatabaseService implements this as a final method to add any additional help supplied toaddAdditionalHelp(String)
combined with the help provided by sub-classes in_getHelp()
- Specified by:
getHelp
in classGeneiousService
- Returns:
- help describing this service.
-
_getHelp
@MustReturnPromptly protected abstract java.lang.String _getHelp()
Sub-classes should override this to provide help as defined byGeneiousService.getHelp()
Ths results of this method are combined with any additional help provided toaddAdditionalHelp(String)
to create the results forgetHelp()
.- Returns:
- help describing this service.
-
addDatabaseServiceListener
@MustReturnPromptly public final void addDatabaseServiceListener(DatabaseServiceListener listener)
A sub-class must not override this, but should instead usegetDatabaseServiceListeners()
as this class relies ongetDatabaseServiceListeners()
.- Overrides:
addDatabaseServiceListener
in classDatabaseService
- Parameters:
listener
- a listener
-
removeDatabaseServiceListener
@MustReturnPromptly public final void removeDatabaseServiceListener(DatabaseServiceListener listener)
A sub-class must not override this, but should instead usegetDatabaseServiceListeners()
as this class relies ongetDatabaseServiceListeners()
.- Overrides:
removeDatabaseServiceListener
in classDatabaseService
- Parameters:
listener
- a listener
-
getDatabaseServiceListeners
@MustReturnPromptly protected final java.util.List<DatabaseServiceListener> getDatabaseServiceListeners()
Get all DatabaseServiceListeners added usingaddDatabaseServiceListener(com.biomatters.geneious.publicapi.databaseservice.DatabaseServiceListener)
.- Overrides:
getDatabaseServiceListeners
in classDatabaseService
- Returns:
- a list of all any DatabaseServiceListeners added using
addDatabaseServiceListener(com.biomatters.geneious.publicapi.databaseservice.DatabaseServiceListener)
.
-
addSearchResultPropertiesAdjuster
@MustReturnPromptly public final void addSearchResultPropertiesAdjuster(WritableDatabaseService.SearchResultPropertiesAdjuster propertiesAdjuster)
Add a SearchResultPropertiesAdjuster to this database service.- Parameters:
propertiesAdjuster
- the SearchResultPropertiesAdjuster to be added
-
removeSearchResultPropertiesAdjuster
@MustReturnPromptly public final void removeSearchResultPropertiesAdjuster(WritableDatabaseService.SearchResultPropertiesAdjuster propertiesAdjuster)
Removed a SearchResultPropertiesAdjuster added viaaddSearchResultPropertiesAdjuster(com.biomatters.geneious.publicapi.databaseservice.WritableDatabaseService.SearchResultPropertiesAdjuster)
.- Parameters:
propertiesAdjuster
- the SearchResultPropertiesAdjuster to be removed
-
_retrieve
@MayReturnSlowly protected void _retrieve(AnnotatedPluginDocument[] summaryDocuments, RetrieveCallback callback, URN[] urnsToNotRetrieve) throws DatabaseServiceException
Implementaion method forretrieve(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback, com.biomatters.geneious.publicapi.documents.URN[])
that subclasses should implement. The default implementation just calls super.retrieve(summaryDocuments, callback, urnsToNotRetrieve).- Throws:
DatabaseServiceException
-
_retrieve
@MayReturnSlowly protected abstract void _retrieve(URN[] urnsToRetrieve, RetrieveCallback callback) throws DatabaseServiceException
Implementaion method forretrieve(com.biomatters.geneious.publicapi.documents.URN[], com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback)
that subclasses should implement. Unlike the parent case, implementations of this should return documents if they exist anywhere within the database folder hierarchy.- Throws:
DatabaseServiceException
-
_retrieve
@MayReturnSlowly protected abstract void _retrieve(Query query, RetrieveCallback callback, URN[] urnsToNotRetrieve) throws DatabaseServiceException
Implementaion method forretrieve(com.biomatters.geneious.publicapi.databaseservice.Query, com.biomatters.geneious.publicapi.databaseservice.RetrieveCallback, com.biomatters.geneious.publicapi.documents.URN[])
that subclasses should implement.- Throws:
DatabaseServiceException
-
retrieve
@MayReturnSlowly public final void retrieve(AnnotatedPluginDocument[] documents, RetrieveCallback callback, URN[] urnsToNotRetrieve) throws DatabaseServiceException
Description copied from class:DatabaseService
Retrieves full documents corresponding to the given summary documents from the database. If this DatabaseService returnsSummaryDocument
s then this method must be implemented to allow the full documents to be downloaded.- Overrides:
retrieve
in classDatabaseService
- Parameters:
documents
- A list of summary documents.callback
- Full documents should be passed on to this callback's add method as they are being retrieved from the database. It is an error to call any methods on the callback after retrieve() has returned, or after callback.setFinalStatus() has been called.urnsToNotRetrieve
- a set of document URN's to ignore. Documents matching one of these URNs must not be passed to the callback, and to save bandwidth, the DatabaseService should not download them from the database.- Throws:
DatabaseServiceException
- if retrieval fails for any reason. May also throw this if the callback requests the retrieve to be cancelled.
-
retrieve
@MayReturnSlowly public final void retrieve(URN[] urnsToRetrieve, RetrieveCallback callback) throws DatabaseServiceException
Description copied from class:DatabaseService
Retrieve documents with the specified URNs. A DatabaseService only needs to implement this function if it generates AnnotatedPluginDocuments that reference other documents. Geneious will then use this function to obtain those referenced documents. If a document with any of these URNs is not in this database, this method should return without throwing an exception.- Overrides:
retrieve
in classDatabaseService
- Parameters:
urnsToRetrieve
- URNs which must be the URNS of documents referenced by a previous document returned from this DatabaseServicecallback
- Used to notify when a document has been retrieved.- Throws:
DatabaseServiceException
- if retrieval fails due to a problem with connecting to the database. May also throw this if the callback requests the retrieve to be cancelled.
-
retrieve
@MayReturnSlowly public final void retrieve(Query query, RetrieveCallback callback, URN[] urnsToNotRetrieve) throws DatabaseServiceException
Description copied from class:DatabaseService
Get documents by searching a database. The database should not return from this function until it has called callback.addDocument() for all results. None of the arguments may be null, but it is not guaranteed that a NullPointerException will be thrown if a client violates this requirement.- Specified by:
retrieve
in classDatabaseService
- Parameters:
query
- the query specifying what we are searching this DatabaseService for; must not be null.callback
- The RetrieveCallback to which to report search results (documents and progress reports); must not be null.urnsToNotRetrieve
- a set of document URN's to ignore. retrievers can save bandwidth/disk access by not downloading documents with the same URN. Must not be null. Most implementations can ignore this method.- Throws:
DatabaseServiceException
- if retrieval fails for any reason. May also throw this if the callback requests the retrieve to be cancelled.
-
isSameRootService
@MustReturnPromptly public boolean isSameRootService(WritableDatabaseService anotherService)
Determines whether the root of this service (or this service itself if it is the root) is equal to the root of another service. For service implementations that do not override this method, the default behaviour returns true as long as both services are descendants or the top level service itself. For shared database services, this returns true if the underlying connected service is identical, ignoring the credentials used to connect to the service.- Parameters:
anotherService
- The other service to compare with- Returns:
- true if the two services are considered the same
- Since:
- API 4.202021 (Geneious 2020.2.1)
-
canEditDocuments
@MustReturnPromptly public boolean canEditDocuments()
Returns true if documents in this database can be edited. Even if documents cannot be edited, they may still be created and deleted ifisReadOnly()
returns false. The default implementation returns !isReadOnly()
.- Returns:
- true if documents in this database can be edited.
- Since:
- API 4.1100 (Geneious 11.0.0)
-
isReadOnly
@MustReturnPromptly public boolean isReadOnly()
Returns whether or not documents in this folder are read only and whether or not documents can be added and removed from this folder. The default implementation returns false; the readOnly attribute can be further modified by specifyingcanModifySubFolders()
. Note: If a WritableDatabaseService changes its read only status after being created, it must callGeneiousService.getGeneiousServiceListener()
.iconsChanged()
- Returns:
- true if documents in this folder are read only and documents can't be added or removed.
-
canModifySubFolders
@MustReturnPromptly public boolean canModifySubFolders()
Returns whether or not this service allows modifications of its subfolders. This method does not look recursively through the service's subfolders.
Folder modifications include, but are not limited to:- Adding subfolders
- Removing subfolders
isReadOnly()
and this method both return true, the service will be read only as far as documents are concerned but will be writable with respect to folder modifications (such as those above).
The default implementation returns the opposite ofisReadOnly()
.- Returns:
- true if this service allows modifications of folders.
- Since:
- API 4.1020 (Geneious 10.2.0)
-
canBeRenamed
@MustReturnPromptly public boolean canBeRenamed()
Returns whether or not this service can be renamed usingrenameFolder(String)
This method is offered because some services can be read only with regards to documents, but allow the folder itself to be renamed. The default implementation returns the opposite ofisReadOnly()
.- Returns:
- true if this service can be renamed
- Since:
- API 4.1101 (Geneious 11.0.1)
- See Also:
renameFolder(String)
,isReadOnly()
-
isShared
@MustReturnPromptly public boolean isShared()
Returns whether or not this service is accessible by other computers e.g. shared database folder Note: If a WritableDatabaseService changes its shared status after being created, it must callGeneiousService.getGeneiousServiceListener()
.iconsChanged()
- Since:
- API 4.1020 (Geneious 10.2.0)
-
getDocumentCount
@MustReturnPromptly public abstract int getDocumentCount(boolean includeSubFolders)
Get the number of documents in this folder. A service which has not yet finished initializing may return 0 from this method, even if it does contain documents.- Parameters:
includeSubFolders
- if true, the returned value should include in the total the number of documents in all sub-folders recursively- Returns:
- the number of documents in this folder (and all subfolders if includeSubFolders is true)
-
getSpecialQuerySymbols
@MustReturnPromptly public java.util.Set<java.lang.String> getSpecialQuerySymbols()
Returns a set of query text symbols that are considered reserved characters (symbols) fordocument retrieval
system implementation. These symbols may not be correctly or accurately processed. Implementations ofWritableDatabaseService
are encouraged to list these symbols so other modules are aware of the query input constraints when submitting search queries.- Since:
- API 4.202021 (Geneious 2020.2.1)
-
_getExtendedSearchOptions
@MustReturnPromptly public static ExtendedSearchOption[] _getExtendedSearchOptions(boolean isAdvancedSearch)
Get the extended options that most WritableDatabaseServices return fromgetExtendedSearchOptions(boolean)
.- Parameters:
isAdvancedSearch
- whether to get the options for advanced or basic searches as specified ingetExtendedSearchOptions(boolean)
.- Returns:
- the extended options that most WritableDatabaseServices return from
getExtendedSearchOptions(boolean)
-
getExtendedSearchOptions
@MustReturnPromptly public ExtendedSearchOption[] getExtendedSearchOptions(boolean isAdvancedSearch)
Provide a list of extended options to be displayed the in the search panel. WritableDatabaseServices have a default implementation of this method that returns_getExtendedSearchOptions(boolean)
Most implementations should not override this, but if they do, they should be aware that collaboration won't provide this alternative search options.- Overrides:
getExtendedSearchOptions
in classDatabaseService
- Parameters:
isAdvancedSearch
- specifies if the options returned are going be attached to the advanced or basic search panel. This method will be called twice with true and false. Disregard this if the extended options are to be on both basic and advanced.- Returns:
- array of options or empty array if none. Cannot be null.
-
isLocal
@MustReturnPromptly public boolean isLocal()
Is this a local database rather than a shared Database. This affects the status messages returned while searching and in some cases prompts the user about whether to apply potentially time consuming actions to the entire database.- Returns:
- true if this is a local database
-
_getHiddenFolder
@MayReturnSlowly protected abstract WritableDatabaseService _getHiddenFolder(java.lang.String folderName, boolean isPerUserFolder) throws DatabaseServiceException
The implementation method forgetHiddenFolder(String, boolean)
Note - implementations that support hidden folders must also implementcontainsDocumentInThisFolder(URN)
- Parameters:
folderName
-isPerUserFolder
-- Returns:
- a WritableDatabaseService used for storing arbitrary XML elements
- Throws:
DatabaseServiceException
-
getHiddenFolder
@MayReturnSlowly public final WritableDatabaseService getHiddenFolder(java.lang.String folderName, boolean isPerUserFolder) throws DatabaseServiceException
Gets an existing or creates a new hidden folder as an immediate child of the root service of this database. All hidden folders are writable. A hidden folder is used for storage of arbitrary XML elements or documents that are invisible to the user. A hidden folder can not have child folders and the API does not support removing them once created.
Note: Using the same folder name for both a per-user folder and a shared hidden folder is not supported and may result in strange behaviour.- Parameters:
folderName
- a unique identifier for this hidden folder. This must consist of only the following characters: "[a-z][A-Z][0-9] _."isPerUserFolder
- If this database has multiple users accessing the same database simultaneiously and if this parameter is true then the folder returned is unique for the current user rather than shared. This is used for example to store agents or collaboration share status for the current user where each user should have their own independant data.- Returns:
- a WritableDatabaseService used for storing arbitrary XML elements
- Throws:
DatabaseServiceException
-
isHidden
public final boolean isHidden()
This method returns true if this service is created fromgetHiddenFolder(String, boolean)
. A hidden service is not visible in the sources panel.- Returns:
true
if this service is a hidden folder.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
getHiddenFolder(String, boolean)
-
isHiddenPerUser
public final boolean isHiddenPerUser()
If this service ishidden
, this method determines if this service is a per-user hidden folder. This is the same value asisPerUserFolder
parameter ingetHiddenFolder(String, boolean)
. If this service is not hidden, its return value is meaningless.- Returns:
- Whether this service represents a per-user hidden folder if
isHidden()
returns true, otherwise value is meaningless. - Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
getHiddenFolder(String, boolean)
-
getHiddenFolderNames
@MayReturnSlowly public abstract java.lang.String[] getHiddenFolderNames() throws DatabaseServiceException
Get a list of hidden folders that can be used as parameters to the getHiddenFolder() method.- Returns:
- a list of hidden folders that can be used as parameters to the getHiddenFolder() method
- Throws:
DatabaseServiceException
-
addHiddenElement
@MayReturnSlowly public abstract java.lang.String addHiddenElement(org.jdom.Element newElement, jebl.util.ProgressListener progress) throws DatabaseServiceException
Adds a new hidden element to this database and generates a new unique name which is returned. This method may be called on either standard or hidden folders. If adding multiple hidden elements, it is recommended to calladdHiddenElements(Collection, ProgressListener)
because database implementations may provide a performant implementation for batch additions.- Parameters:
newElement
- New element to be added.progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY.- Returns:
- the name of the newly added element, must not be null.
- Throws:
DatabaseServiceException
- If an issue occurred performing this action.- See Also:
addHiddenElements(Collection, ProgressListener)
-
addHiddenElements
@MayReturnSlowly public java.util.Map<org.jdom.Element,java.lang.String> addHiddenElements(java.util.Collection<org.jdom.Element> newElements, jebl.util.ProgressListener progress) throws DatabaseServiceException
Adds multiple hidden elements to this database and generates a unique name for each new element. This method may be called on either standard or hidden folders, and is the preferred alternative toaddHiddenElement(Element, ProgressListener)
when adding multiple hidden elements. The name can be used to retrieve the element at a later date viagetHiddenElement(String, ProgressListener)
.- Parameters:
newElements
- Collection of new elements to be addedprogress
- For progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method throws aDatabaseServiceException
and may (but not required to) remove any elements added so far.- Returns:
- A map of all the elements added to the database, mapped to the unique name assigned to it. If this method
completes, all the new elements will have been added successfully.
- Throws:
DatabaseServiceException
- If an issue occurred which prevents at least one of the new elements from being added to this database, or the operation was cancelled.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
implementsEfficientBatchMethods()
-
addHiddenElement
@MayReturnSlowly public abstract void addHiddenElement(java.lang.String name, org.jdom.Element newElement, jebl.util.ProgressListener progress) throws DatabaseServiceException
Adds a new hidden element to this database using the given name. If a hidden element with this name already exists, the existing element will be updated to the new element. If adding multiple hidden elements, it is recommended to calladdHiddenElements(Map, ProgressListener)
because database implementations may provide a performant implementation for batch additions.- Parameters:
name
- A unique identifier for this element. This must consist of only the following characters: "[a-z][A-Z][0-9] _."newElement
- Element to be addedprogress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY.- Throws:
DatabaseServiceException
- If an issue occurred performing this action.- See Also:
addHiddenElements(Map, ProgressListener)
-
addHiddenElements
@MayReturnSlowly public void addHiddenElements(java.util.Map<java.lang.String,org.jdom.Element> newElementsByName, jebl.util.ProgressListener progress) throws DatabaseServiceException
Adds multiple named hidden elements to this database. This method may be called on either standard or hidden folders, and is the preferred alternative toaddHiddenElement(String, Element, ProgressListener)
when adding multiple hidden elements. If a hidden element with the name already exists, the existing element will be updated to the new element.- Parameters:
newElementsByName
- A map of new named elements to be added to this databaseprogress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method throws aDatabaseServiceException
and may (but not required to) remove the new elements added thus far. Also, this method also guarantees next time a call to add new hidden elements by the same name succeeds.- Throws:
DatabaseServiceException
- If an issue occurred performing this action, or the operation was cancelled.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
implementsEfficientBatchMethods()
-
getHiddenElement
@MayReturnSlowly public abstract org.jdom.Element getHiddenElement(java.lang.String elementName, jebl.util.ProgressListener progress) throws DatabaseServiceException
Get(load) a special hidden element. If retrieving multiple hidden elements, it is recommended to callgetHiddenElements(Collection, ProgressListener)
because database implementations may provide a performant implementation for batch retrieval.- Parameters:
elementName
- the value returned from a previous call to addHiddenElement(Element) or the name specified as a parameter to a previous call to addHiddenElement(String, Element) or getHiddenElementNames()- Returns:
- the element. Will not be null. If the element doesn't exist, a DatabaseServiceException will be thrown.
- Throws:
DatabaseServiceException
- if there is no hidden element with this name or if an I/O error occurs.- See Also:
getHiddenElements(Collection, ProgressListener)
-
getHiddenElements
@MayReturnSlowly public java.util.Map<java.lang.String,org.jdom.Element> getHiddenElements(jebl.util.ProgressListener progress) throws DatabaseServiceException
Retrieves all the hidden elements from this database. This method is the preferred alternative to callinggetHiddenElementNames()
followed bygetHiddenElements(Collection, ProgressListener)
when retrieving all or most of the hidden elements.- Parameters:
progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method will throw aDatabaseServiceException
.- Returns:
- Map of retrieved elements keyed by its name.
- Throws:
DatabaseServiceException
- If an issue occurred performing this action or operation is cancelled.- Since:
- API 4.202401 (Geneious 2024.0.1)
- See Also:
implementsEfficientBatchMethods()
-
getHiddenElements
@MayReturnSlowly public java.util.Map<java.lang.String,org.jdom.Element> getHiddenElements(java.util.Collection<java.lang.String> elementNames, jebl.util.ProgressListener progress) throws DatabaseServiceException
Retrieves a number of hidden elements from this database. This method is the preferred alternative togetHiddenElement(String, ProgressListener)
when retrieving multiple hidden elements.- Parameters:
elementNames
- Collection of element names to retrieve.progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method will throw aDatabaseServiceException
.- Returns:
- Map of retrieved elements keyed by its name.
- Throws:
DatabaseServiceException
- If an issue occurred performing this action or operation is cancelled.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
implementsEfficientBatchMethods()
-
getHiddenElementNames
@MayReturnSlowly public abstract java.lang.String[] getHiddenElementNames() throws DatabaseServiceException
Lists the hidden elements stored in this database.- Returns:
- a list of names.
- Throws:
DatabaseServiceException
- If an issue occurred performing this action.
-
updateHiddenElement
@MayReturnSlowly public abstract void updateHiddenElement(java.lang.String name, org.jdom.Element newElement, jebl.util.ProgressListener progress) throws DatabaseServiceException
Updates the contents of a hidden element. If performing updates on multiple hidden elements, it is recommended to callupdateHiddenElements(Map, ProgressListener)
instead because database implementations may provide a performant implementation for batch updates.- Parameters:
name
- the name returned from a previous call to addHiddenElement(Element) or the name specified as a parameter to a previous call to addHiddenElement(String, Element)newElement
- the new element to be saved.progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY.- Throws:
DatabaseServiceException
- If an issue occurred performing this action.- See Also:
updateHiddenElements(Map, ProgressListener)
-
updateHiddenElements
@MayReturnSlowly public void updateHiddenElements(java.util.Map<java.lang.String,org.jdom.Element> elementsToUpdate, jebl.util.ProgressListener progress) throws DatabaseServiceException
Updates the contents of multiple hidden elements. This method is the preferred alternative toupdateHiddenElement(String, Element, ProgressListener)
when updating multiple hidden elements.- Parameters:
elementsToUpdate
- Map of all named elements to be updated, where the name is the String returned from a previous call toaddHiddenElement(Element, ProgressListener)
or the name specified as a parameter to a previous call toaddHiddenElement(String, Element, ProgressListener)
.progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method throws aDatabaseServiceException
and may (but not required to) roll back any changes made to some elements in this operation.- Throws:
DatabaseServiceException
- If an issue occurred performing this action, or the operation is cancelled.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
implementsEfficientBatchMethods()
-
removeHiddenElement
@MayReturnSlowly public abstract void removeHiddenElement(java.lang.String name) throws DatabaseServiceException
Removes a hidden element from this database. If removing multiple hidden elements, it is recommended to callremoveHiddenElements(Collection, ProgressListener)
.- Parameters:
name
- the name returned from a previous call to addHiddenElement(Element) or the name specified as a parameter to a previous call to addHiddenElement(String, Element). If a hidden element with this name doesn't exist, this method does nothing,- Throws:
DatabaseServiceException
- If an issue occurred performing this action.
-
removeHiddenElements
@MayReturnSlowly public void removeHiddenElements(java.util.Collection<java.lang.String> namesToRemove, jebl.util.ProgressListener progress) throws DatabaseServiceException
Removes multiple hidden elements by name. This method is the preferred alternative toremoveHiddenElement(String)
when removing many elements.- Parameters:
namesToRemove
- Element names to be removed. This is the name returned from a previous call toaddHiddenElement(Element, ProgressListener)
or the name specified as a parameter to a previous call toaddHiddenElement(String, Element, ProgressListener)
. If a hidden element with this name doesn't exist, it will be skipped.progress
- Progress reporting and cancellation. If not applicable, use ProgressListener.EMPTY. If cancelled, this method throws aDatabaseServiceException
and may (but not required to) roll back the changes in this operation.- Throws:
DatabaseServiceException
- If an issue occurred performing this action, or operation is cancelled.- Since:
- API 4.202230 (Geneious 2022.3.0)
- See Also:
implementsEfficientBatchMethods()
-
createFolderViewFolder
@MayReturnSlowly public WritableDatabaseService createFolderViewFolder(java.lang.String folderName, AnnotatedPluginDocument folderViewDocument) throws DatabaseServiceException
Creates a new child folder that contains a document that may be displayed for representing an entire view of the folder. If (folderViewDocument.getDocument() instanceof FolderViewDocument), then all future browses or searches on this folder will refer to the FolderViewDocument to obtain additional properties to display for the returned documents. The folderViewDocument document itself should not show up in response to any browses or searches on the folder itself. It is only obtainable viagetFolderViewDocument()
. The database implementation is responsible for updating the folderViewDocument to record changes made usingaddDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
which must include callingFolderView.addDocumentProperties(com.biomatters.geneious.publicapi.documents.URN, java.util.Map)
for every document, even if they don't have properties.- Parameters:
folderName
- the new name for the folder. If there is already a folder with this name, this method throws a DatabaseServiceException.folderViewDocument
- the document to be displayed when this folder is selected.- Returns:
- the newly added folder.
- Throws:
DatabaseServiceException
- if a folder named this already exists or if the folder cannot be created.
-
setFolderViewDocument
@MayReturnSlowly public void setFolderViewDocument(AnnotatedPluginDocument folderViewDocument, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Sets the folder view document on this folder. This replaces any existing folder view document on this folder. seecreateFolderViewFolder(String, com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument)
for more information on folder view documents. Passing in null removes the folder view from the folder and deletes the folder view document if nothing else references it. This method doesn't save the folder view document if it already exists in the database. CallAnnotatedPluginDocument.saveDocument()
first in this case.- Parameters:
folderViewDocument
- the new folder view document for this folder or null to remove any folder view document. If this document is already present as a stand-alone document in the database, then folder view will point to this existing document. Otherwise, a copy of the provided document will be added to the database.progressListener
- progress listener for recording progress and handling cancel.- Throws:
DatabaseServiceException
- if the document cannot be saved.
-
getFolderViewDocument
@MayReturnSlowly public final AnnotatedPluginDocument getFolderViewDocument() throws DatabaseServiceException
If this folder represents the results of a search, it must provide a FolderViewDocument which stores all properties of that search. Services that wish to implement this method should instead implement_getFolderViewDocument()
- Returns:
- a AnnotatedPluginDocument whose internal document is a FolderViewDocument which stores all properties of a search or null if this folder does not have a folder view document
- Throws:
DatabaseServiceException
- See Also:
_getFolderViewDocument()
-
_getFolderViewDocument
@MayReturnSlowly protected AnnotatedPluginDocument _getFolderViewDocument() throws DatabaseServiceException
The implementation method forgetFolderViewDocument()
. Services should override this method to provide their folder view document.- Throws:
DatabaseServiceException
-
addDocumentCopyWithProperties
@MayReturnSlowly public final AnnotatedPluginDocument addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties) throws DatabaseServiceException
- Throws:
DatabaseServiceException
-
addDocumentCopyWithProperties
@MayReturnSlowly public final AnnotatedPluginDocument addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties, URN urnToUseForAddedDocument) throws DatabaseServiceException
Add a copy of this document to this database with additional properties that will show up as associated with this document on any future queries while the document resides in this folder. This method may only be called if this database has had a FolderViewDocument set on it. SeecreateFolderViewFolder(String,AnnotatedPluginDocument)
. The implementation of addDocumentCopyWithProperties is responsible for recording these properties in the FolderViewDocument. SeeaddDocumentCopy(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener)
for other information about adding documents to databases.- Parameters:
document
- the document to add a copy ofprogress
- reports progressproperties
- properties for the document. May be null.urnToUseForAddedDocument
- the urn to use for the newly added copy. This may be null, in which case a URN will be generated. If this is not null, it must be a URN returned from a previous call tocreateUrnForDocumentSoonToBeAdded()
- Returns:
- the newly added document.
- Throws:
DatabaseServiceException
- if the document fails to be added.- Since:
- API 4.60 (Geneious 5.6.0)
-
_addDocumentCopyWithProperties
@Deprecated @MayReturnSlowly protected AnnotatedPluginDocument _addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties) throws DatabaseServiceException
- Throws:
DatabaseServiceException
-
_addDocumentCopyWithProperties
@MayReturnSlowly protected AnnotatedPluginDocument _addDocumentCopyWithProperties(AnnotatedPluginDocument document, jebl.util.ProgressListener progress, java.util.Map<java.lang.String,java.lang.Object> properties, URN urnToUseForAddedDocument) throws DatabaseServiceException
Implementation method foraddDocumentCopyWithProperties(com.biomatters.geneious.publicapi.documents.AnnotatedPluginDocument, jebl.util.ProgressListener, java.util.Map, com.biomatters.geneious.publicapi.documents.URN)
. Subclasses implement this instead of addDocumentCopyWithProperties.- Throws:
DatabaseServiceException
- Since:
- API 4.60 (Geneious 5.6.0)
-
isSearchIndexingComplete
@MayReturnSlowly public boolean isSearchIndexingComplete()
Some implementations ofWritableDatabaseService
may require documents to be indexed before document retrieval returns the full set of results. This method returns the status of the document search index. If true, the service is considered fully searchable. If an implementation is temporarily unable to evaluate the indexing status (e.g. an IOException when connecting to a shared database) it should returnfalse
.- Returns:
- true if the search index is complete for this service, and that there are no unindexed documents.
- Since:
- API 4.202021 (Geneious 2020.2.1)
-
waitForSearchIndexingToComplete
@MayReturnSlowly public void waitForSearchIndexingToComplete(boolean forDocumentTypeFieldQuery)
It is permissible for a database to not return documents from a search that have been recently added to the database due to it still indexing those documents for search purposes. This method waits until all documents in the database have been indexed before returning.
NOTE: This method is not implemented for Shared Databases, it returns immediately without doing anything even if indexing is still in progress- Parameters:
forDocumentTypeFieldQuery
- true if it is only necessary to wait until a query searching only for results that match aDocumentType.DOCUMENT_TYPE_FIELD
would successfully find all results. For document type field search in a local database, it can find all results even if some documents are unindexed- Since:
- API 4.1000 (Geneious 10.0.0)
-
waitForSearchIndexingToComplete
@MayReturnSlowly public void waitForSearchIndexingToComplete()
Equivalent towaitForSearchIndexingToComplete(false)
-
recreateSearchIndex
@MustReturnPromptly public void recreateSearchIndex()
Requests the database service to completely recreate the search index.
NOTE: This method is not implemented for Shared Databases.- Since:
- API 4.202020 (Geneious 2020.2.0)
- See Also:
SearchIndexCorruptOrMissingException
-
getLock
@MustReturnPromptly public java.lang.Object getLock()
An object used as a lock by this database while it modifies the in memory contents of documents. This object is intended for use by external methods as a parameter to a synchronized block to prevent the database from modifying a document while the external code reads or updates the document. The returned lock may be shared by all databases in a single database hierarchy. The default implementation returnsthis
- Returns:
- a lock used by this database while it modifies the in memory contents of documents.
-
getColor
public java.awt.Color getColor(boolean loadNow)
Gets the text/icon color for this folder. This methodMustReturnPromptly
ifloadNow==false
, andMayReturnSlowly
ifloadNow==true
- Parameters:
loadNow
- true to force load the color from disk now. False to use the in memory cache. Usually this parameter should be false unless some external code has manually copied hiddenFolder elements (which store the color) from elsewhere.- Returns:
- the text color for this folder or null to use the default color.
- Since:
- API 4.40 (Geneious 5.4.0)
-
setColor
@MayReturnSlowly public void setColor(java.awt.Color newColor)
Sets the text/icon color for this folder- Parameters:
newColor
- the new text color for this folder or null to use the default color- Since:
- API 4.40 (Geneious 5.4.0)
-
initialize
@MayReturnSlowly protected void initialize(GeneiousServiceListener listener)
Description copied from class:GeneiousService
Constructor method - initializes the service. Any service that needs to create child services, or change its status from ServiceStatus.AVAILABLE, or change its name or icon needs to override this method, and call appropriate methods on the listener parameter. If this is not aWritableDatabaseService
this method is called first thing after creating the service using a parameterless constructor. If this is aWritableDatabaseService
, methods that deal with hidden folders and hidden elements may be called before initialize. These includegetHiddenElementNames()
,getHiddenFolder(String, boolean)
andgetHiddenElement(String, jebl.util.ProgressListener)
. External classes should not call this method. They should instead useGeneiousService.initializeService(GeneiousServiceListener)
which sets up internal handlers and calls this method. Even then, generally only the Geneious application itself should be callingGeneiousService.initializeService(GeneiousServiceListener)
.- Overrides:
initialize
in classGeneiousService
- Parameters:
listener
- a listener for reporting changes to the service, such as status changes or new child services.
-
supportsReferencesBetweenDocuments
@MustReturnPromptly public boolean supportsReferencesBetweenDocuments()
Returns true if this database supports documents that store references to other documents in the same database. If it does not support references, then when a document is added to this database that references other documents, the database should store that document along with all references (and references of those) as a single entity in the database, probably by exporting it to .geneious format. If an operation's destination returns false from this method, no OperationRecordDocument or lineage will be tracked for that operation. The default implementation returns true.- Returns:
- true if this database supports documents that store references to other documents in the same database. If it does not support references, then when a document is added to this database that references other documents, the database should store that document along with all references (and references of those) as a single entity in the database.
- Since:
- API 4.1100 (Geneious 11.0.0)
-
getNameForSorting
@MustReturnPromptly public java.lang.String getNameForSorting()
- Overrides:
getNameForSorting
in classGeneiousService
- Returns:
- a name for this folder that can be used for a String comparison for sorting folders. The default implementation returns
getFolderName()
. For example, the local database returns adjusted folder names to make the "Deleted Items" and "Reference Features" appear below other folders. - Since:
- API 4.202010 (Geneious 2020.1.0)
-
cachePluginDocumentXmlAndAdditionalXmlLocally
@MayReturnSlowly public void cachePluginDocumentXmlAndAdditionalXmlLocally(java.util.List<AnnotatedPluginDocument> documents, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
For a local database, this method does nothing.For non-local databases (those with latency between the client and storage such as a cloud or shared database), instructs this database to prefetch data by downloading and locally caching on disk the PluginDocument XML and additional XML for all of these documents so that future calls to
AnnotatedPluginDocument.getPluginDocumentXml(ProgressListener)
(which ultimately callsElementProvider.getElement(ProgressListener)
on the ElementProvider provided toDocumentUtilities.createAnnotatedPluginDocument(Element, ElementProvider,URN)
) and calls togetAdditionalPerDocumentXml(AnnotatedPluginDocument, String, boolean, ProgressListener)
may return promptly without needing to perform network IO.If the database is going to apply an update to a document that is currently cached it must first cache the new PluginDocument XML, so that any caller of this method can rely on
AnnotatedPluginDocument.getPluginDocumentXml(ProgressListener)
andgetAdditionalPerDocumentXml(AnnotatedPluginDocument, boolean, ProgressListener)
returning promptly; failure to do so may result in UI hangs.The database implementation should cache this information at least until this database is shutdown or until a matching call to
uncachePluginDocumentXmlAndAdditionalXmlLocally(List)
is made, but ideally longer if sufficient disk space is available, including keeping the cache between instances of Geneious. The XML must be cached on disk. It must not be strongly cached in memory but may be weakly or softly cached in memory. If this method throws an exception then any documents that have already been cached or counted from the same call should not be considered cached, as there will not be a matching call to uncachePluginDocumentXmlAndAdditionalXmlLocally(List).The default implementation of this method does nothing. A client can assume that a network database which returns true from
implementsEfficientBatchMethods()
will implement this method.
Implementation Requirements
- Prefetch the PluginDocument XML and additional XML so that future calls may return promptly
- The same document may be passed to this method multiple times, in the same or separate calls
-
The document will be considered cached until it is passed to
uncachePluginDocumentXmlAndAdditionalXmlLocally(List)
the same number of times that it has been passed to this method - If Geneious is shutdown or restarted all documents are considered uncached
- If there is an error when attempting to cache any of the documents, then none of the documents should be considered cached
- The data must be cached to some form of local storage
- You must not hold a strong reference to the cached data in memory as the sum of cached data may not fit in memory
- If the document is updated for any reason while it is cached, the database must ensure it caches the new XML before updating the document
- Data may be cached on disk for longer than requested, however once a document becomes cached again it must fulfill the above requirements
Usage Notes
Most usages of this method should instead consider callingcachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List, ProgressListener)
which delegates to this method for each database root.If this method throws an exception then any documents that have already been cached or counted from the same call should not be considered cached, as there will not be a matching call to uncachePluginDocumentXmlAndAdditionalXmlLocally(List).
- Parameters:
documents
- the documents to locally cache XML for. These must be documents already present somewhere in this database, but not necessarily in this folder.- Throws:
DatabaseServiceException
- if there is a problem caching data (due to a network connection or a document being deleted, or permission accessing data)- Since:
- API 4.202210 (Geneious 2022.1.0)
- See Also:
uncachePluginDocumentXmlAndAdditionalXmlLocally(List)
,cachePluginDocumentXmlAndAdditionalXmlLocallyForDocumentsInAnyDatabase(List, ProgressListener)
-
uncachePluginDocumentXmlAndAdditionalXmlLocally
@MustReturnPromptly public void uncachePluginDocumentXmlAndAdditionalXmlLocally(java.util.List<AnnotatedPluginDocument> documents)
Indicates that the documents previously cached usingcachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
may be removed from the cache when there is insufficient free space in the cache. The implementation should only remove documents from the cache if an equal number of calls to cachePluginDocumentXmlAndAdditionalXmlLocally and uncachePluginDocumentXmlAndAdditionalXmlLocally have been made for that document.- Parameters:
documents
- the documents for which XML caching is no longer required- Since:
- API 4.202210 (Geneious 2022.1.0)
- See Also:
cachePluginDocumentXmlAndAdditionalXmlLocally(List, ProgressListener)
-
createChildFolders
@MayReturnSlowly public java.util.List<WritableDatabaseService> createChildFolders(java.util.List<java.lang.String> folderNames, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Creates one or more child folders. Equivalent to multiple calls tocreateChildFolder(String)
on both this folder and child folders. If this call fails the caller may not assume that any of the folders were or were not created and the implementation may preserve or roll back any changes that have happened. Use of this method over multiple calls to createChildFolder improves performance in databases with network latency (e.g. cloud, shared) If there is an error part way through execution of this method, the database may choose to keep some or all of the child folders that have already been created. If the folder structureX/Y/Z
is to be created in this service, thefolderNames
list may either contain 3 entries:X X/Y X/Y/Z
or 1 entry:X/Y/Z
In the first case, the expected result is a list of size 3 -- aWritableDatabaseService
representing X, Y and Z, exactly in that order. In the second case, the expected result is a list of size 1 -- representing Z, the last folder in the path. X and Y will also be created if it doesn't exist already. If any folder names already exist, ensure all its descendants are created as well.- Parameters:
folderNames
- names of all child folders to create. Names may contain / to separate child folders. e.g. "Folder/SubFolder" will create both a child folder called Folder and a child folder of that called SubFolder. Each path may contain folder names that already exist, these folders should be reused (returned in the result), and any non-existent child folders should be created.progressListener
- for reporting progress and canceling the request before it has completed- Returns:
- a list equal in size to folderNames with the corresponding folder which has been created for each folder name.
- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
setFolderViewDocuments
@MayReturnSlowly public void setFolderViewDocuments(java.util.Map<WritableDatabaseService,AnnotatedPluginDocument> folderViewDocuments, jebl.util.ProgressListener progressListener) throws DatabaseServiceException
Sets folder view documents on multiple folders. Equivalent to multiple calls tosetFolderViewDocument(AnnotatedPluginDocument, ProgressListener)
. If this call fails, the caller may not assume that any of the folder view documents were set, and the implementation may preserve or roll back any changes that have happened. Use of this method over multiple calls to setFolderViewDocument improves performance in databases with network latency (e.g. cloud, shared) It does not matter which WritableDatabaseService folder in the database hierarchy that setFolderViewDocuments is called on. Only the WritableDatabaseService folders specified in the folderViewDocuments are used. If there is an error part way through processing the folder view documents, the database may undo or keep any progress that has already been made processing those documents.- Parameters:
folderViewDocuments
- a map from a service to the folder view document to assign to that service.progressListener
- for reporting progress and canceling the request before it has completed- Throws:
DatabaseServiceException
- if the request can't be processed for any reason, or if the progressListener cancels the request before it has completed.- Since:
- API 4.202210 (Geneious 2022.1.0)
-
-