Holger's Java API

## com.antelmann.db
Class ArchiveDBClassStore<T extends DBEntry>

    java.lang.Object
      com.antelmann.db.WrappedDBClassStore<T>
          com.antelmann.db.ArchiveDBClassStore<T>

All Implemented Interfaces:
  ArchivedStore<T>, DBClassStore<T>, ProcessedFilterOption<T>, TransactionRequired, ProcessorHook<T,DatabaseException>, Wrapped<DBClassStore<T>>

    @Warning(value="due to missing X/A support, updates of the archive may not be transactionally consistent")
    @Todo(value="support X/A via TransactionListener")
    public class ArchiveDBClassStore<T extends DBEntry>

extends WrappedDBClassStore<T>
implements ArchivedStore<T>

allows to add an archive store to any given store, which enables to extend the data set.

Since:
  01.09.2011, 09:48:43
Author:
  Holger Antelmann

Nested Class Summary

Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore
`DBClassStore.DBMethod`

Field Summary

Fields inherited from class com.antelmann.db.WrappedDBClassStore
`store`

Constructor Summary
`ArchiveDBClassStore(DBClassStore<T> store, DBClassStore<T> archive, boolean enableArchive)`

Method Summary
`boolean` `containsID(Object id)` determines whether the given ID is present in this store.
`int` `deleteEntries(Filter<? super T> filter)` deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted.
`boolean` `deleteEntry(Object id)` removes the entry with the given ID from this store in the database.
`DBEnumeration<T>` `fetch(Filter<? super T> filter)` allows to retrieve the entries of this storage via iteration.
`DBEnumeration<Stub<T>>` `fetchStubs(Filter<? super Stub<?>> filter)` allows to access objects from this store w/o having to instantiate the entire original objects, but instead use Stubs to be able to display the list properly for selection.
`T` `getEntry(Object id)` returns the DBEntry based on its ID.
`Stub<T>` `getStub(Object id)` returns a Stub representing the resource for the given ID or null.
`boolean` `isArchiveEnabled()` if true, each data access call also reaches through to the embedded archived store
`boolean` `isEnableArchiveEdit()`
`int` `moveToArchive(Filter<? super T> filter)` requires transactional context on both stores
`void` `setArchiveEnabled(boolean flag)` if set to true, each data access call also reaches through to the embedded archived store
`void` `setEnableArchiveEdit(boolean enableArchiveEdit)` if set to true, delete and update operations are propagated to the archive (insertions will always only affect the 'normal' store).
`int` `size(Filter<? super T> filter)` returns the total number of T elements in this store based on the given filter (which may be null)
`void` `update(T entry)` updates the given entry in the database.

Methods inherited from class com.antelmann.db.WrappedDBClassStore

`add, checkReadAccess, checkWriteAccess, deleteEntriesIndividually, exposesInterfaces, generateNewID, getAccessFilter, getAccessStubFilter, getDatabase, getEntryClass, getFetchProcessor, getPreStoreHandler, getStoreHandler, getStubProcessor, insert, insertAsNew, isApplyFilterProcessingRecursively, isDeleteEntriesIndividually, isEnsureTransactionsOnFetch, isProcessBeforeFiltering, queryForInterface, remove, setAccessFilter, setAccessStubFilter, setApplyFilterProcessingRecursively, setDeleteEntriesIndividually, setEnsureTransactionsOnFetch, setExposesInterfaces, setFetchProcessor, setPreStoreHandler, setProcessBeforeFiltering, setProcessBeforeFiltering, setStoreHandler, setStubProcessor, unwrap, wrapFilterForProcessing`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ArchiveDBClassStore

    public ArchiveDBClassStore(DBClassStore<T> store,
                               DBClassStore<T> archive,
                               boolean enableArchive)

Method Detail

### isArchiveEnabled

    public boolean isArchiveEnabled()

  Description copied from interface: `ArchivedStore`
  if true, each data access call also reaches through to the embedded archived store

  Specified by:
    `isArchiveEnabled` in interface `ArchivedStore<T extends DBEntry>`

### setArchiveEnabled

    public void setArchiveEnabled(boolean flag)

  Description copied from interface: `ArchivedStore`
  if set to true, each data access call also reaches through to the embedded archived store

  Specified by:
    `setArchiveEnabled` in interface `ArchivedStore<T extends DBEntry>`

### isEnableArchiveEdit

    public boolean isEnableArchiveEdit()

  Specified by:
    `isEnableArchiveEdit` in interface `ArchivedStore<T extends DBEntry>`
  See Also:
    `ArchivedStore.setEnableArchiveEdit(boolean)`

### setEnableArchiveEdit

    @Warning(value="if set to true, updates/deletes on the archive may commit even if the current transaction aborts in the current implementation")
    public void setEnableArchiveEdit(boolean enableArchiveEdit)

  Description copied from interface: `ArchivedStore`
  if set to true, delete and update operations are propagated to the archive (insertions will always only affect the 'normal' store). Read operations are dependent on `ArchivedStore.isArchiveEnabled()`.

  Specified by:
    `setEnableArchiveEdit` in interface `ArchivedStore<T extends DBEntry>`

### containsID

    public boolean containsID(Object id)
                       throws DatabaseException

  Description copied from interface: `DBClassStore`
  determines whether the given ID is present in this store.

  Specified by:
    `containsID` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `containsID` in class `WrappedDBClassStore<T extends DBEntry>`
  Throws:
    `DatabaseException`

### deleteEntry

    public boolean deleteEntry(Object id)
                        throws DatabaseException

  Description copied from interface: `DBClassStore`
  removes the entry with the given ID from this store in the database.

  Specified by:
    `deleteEntry` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `deleteEntry` in class `WrappedDBClassStore<T extends DBEntry>`
  Returns:
    true only if the DBEntry with the given ID was actually found and deleted.
  Throws:
    `DatabaseException`

### deleteEntries

    public int deleteEntries(Filter<? super T> filter)
                      throws DatabaseException

  Description copied from interface: `DBClassStore`
  deletes all DBEntry objects that match the given filter; if the filter is null, all resources are deleted. Calling this method does not necessarily entail that `DBClassStore.deleteEntry(Object)` is called for each entry passing the filter (although stores may choose to do so)! Consequently, if a store's implementation does not call `DBClassStore.deleteEntry(Object)` on each instance, calling this method may result in changes that are hard to monitor for versioning purposes.

  Specified by:
    `deleteEntries` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `deleteEntries` in class `WrappedDBClassStore<T extends DBEntry>`
  Returns:
    the number of objects that were deleted
  Throws:
    `DatabaseException`
  See Also:
    `WrappedDBClassStore.setProcessBeforeFiltering(boolean)`

### update

    public void update(T entry)
                throws DatabaseException

  Description copied from interface: `DBClassStore`
  updates the given entry in the database.

  Specified by:
    `update` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `update` in class `WrappedDBClassStore<T extends DBEntry>`
  Throws:
    `DatabaseException` - if the database was not able to perform the update or it the entry didn't exist in the database before calling this method

### fetch

    public DBEnumeration<T> fetch(Filter<? super T> filter)
                                           throws DatabaseException

  Description copied from interface: `DBClassStore`
  allows to retrieve the entries of this storage via iteration. Note that the order of the entries is undefined, unless a specially designed filter hints a sorting order to an implementing class that additionally supports sorting.

  As all relevant entries may not completely fit into memory, an Enumeration is returned instead of a list. To directly get all entries as a list (and thus avoid concurrency problems), consider using methods from AbstractIterator to quickly retrieve all resources before processing them.

  Be aware that the result of the enumeration may become undefined if data is inserted/deleted/updated while the elements are accessed. To guarantee consistency, all access to the returned Enumeration must be externally synchronized by holding the monitor of the database transaction throughout maintaining the Enumeration.

  Note that you may have IterationExceptions being thrown on calling methods on the returned Enumeration, which are caused by either DatabaseExceptions or InstantiationExceptions on trying to fetch the next element, as not all possible errors may be caught on calling this method (as it possibly cannot instantiate all entries in advance).

  All access to the returned Enumeration must be made within an active transaction.

  As the returned Enumeration may hold resources to the database while iterating, the caller must ensure that these resources can be properly release. This is usually achieved by simply completely iterating through the return value, in which case the DBEnumeration is expected to properly clean up automatically. But in cases where the caller doesn't intend to go all the way through the Enumeration, the caller has to clean up explicitly, which can be done by calling the close() method on the returned DBEnumeration.

  Specified by:
    `fetch` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `fetch` in class `WrappedDBClassStore<T extends DBEntry>`
  Parameters:
    `filter` - may be null, in which case all entries from are returned.
  Throws:
    `DatabaseException`
  See Also:
    `WrappedDBClassStore.setProcessBeforeFiltering(boolean)`

### fetchStubs

    public DBEnumeration<Stub<T>> fetchStubs(Filter<? super Stub<?>> filter)
                                                      throws DatabaseException

  Description copied from interface: `DBClassStore`
  allows to access objects from this store w/o having to instantiate the entire original objects, but instead use Stubs to be able to display the list properly for selection. The given filter may be null. Other than that, the same transactional implications apply as for `fetch(Filter<T>)`.

  Specified by:
    `fetchStubs` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `fetchStubs` in class `WrappedDBClassStore<T extends DBEntry>`
  Throws:
    `DatabaseException`
  See Also:
    `WrappedDBClassStore.setProcessBeforeFiltering(boolean)`

### getEntry

    public T getEntry(Object id)
                               throws DatabaseException

  Description copied from interface: `DBClassStore`
  returns the DBEntry based on its ID.

  Specified by:
    `getEntry` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `getEntry` in class `WrappedDBClassStore<T extends DBEntry>`
  Parameters:
    `id` - the ID that is retrieved from `Resource.getID()`
  Returns:
    the associated DBEntry or null if the id is unknown
  Throws:
    `DatabaseException`
  See Also:
    `DBEntry.getID()`

### getStub

    public Stub<T> getStub(Object id)
                                    throws DatabaseException

  Description copied from interface: `DBClassStore`
  returns a Stub representing the resource for the given ID or null. This method allows to display the object w/o having to retrieve the full DBEntry.

  Specified by:
    `getStub` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `getStub` in class `WrappedDBClassStore<T extends DBEntry>`
  Throws:
    `DatabaseException`

### size

    public int size(Filter<? super T> filter)
             throws DatabaseException

  Description copied from interface: `DBClassStore`
  returns the total number of T elements in this store based on the given filter (which may be null)

  Specified by:
    `size` in interface `DBClassStore<T extends DBEntry>`
  Overrides:
    `size` in class `WrappedDBClassStore<T extends DBEntry>`
  Parameters:
    `filter` - if non-null, only those elements will be counted that are applicable to the filter
  Throws:
    `DatabaseException`
  See Also:
    `WrappedDBClassStore.setProcessBeforeFiltering(boolean)`

### moveToArchive

    public int moveToArchive(Filter<? super T> filter)
                      throws DatabaseException

  Description copied from interface: `ArchivedStore`
  requires transactional context on both stores

  Specified by:
    `moveToArchive` in interface `ArchivedStore<T extends DBEntry>`
  Throws:
    `DatabaseException`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads