Class 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.

    Furthermore, any document returned from the WritableDatabaseImplementation must have had its database set (using 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.

    If the implementation is network-based, and it supports login/logout, note the following things:

    • 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.