com.h3c.util.persistence.cassandra

## Class AbstractBaseDao<I extends Serializable,K extends Serializable & Comparable<K>,P extends Storable<I>,F,S>

- java.lang.Object
- - com.h3c.util.persistence.cassandra.AbstractBaseDao<I,K,P,F,S>

- Type Parameters:
    `I` - type of the persistent object and transport object id. This type should be immutable. It is critical this type implements equals() and hashCode() correctly.
    `K` - Type of Column Name.
    `P` - type of the persistent object.
    `F` - type of the associated filter.
    `S` - type of the associated sort specification type.
  All Implemented Interfaces:
    BaseDao<I,P,F,S,DataStoreContext>
  Direct Known Subclasses:
    CassAbstractDao

      public abstract class AbstractBaseDao<I extends Serializable,K extends Serializable & Comparable<K>,P extends Storable<I>,F,S>
      extends Object
      implements BaseDao<I,P,F,S,DataStoreContext>

  Abstract implementation of Base DAO. This implementation provides methods to read persistence data from the database.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Provider<ColumnDecoder<K,?>,ColumnName<K,?>>` | `columnDecoderProvider`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractBaseDao()` Construct the DAO and create column families in the persistent database.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract int` | `compareRows(P row1, P row2, SortSpecification.SortComponent<S> s)`
    `long` | `count(F filter, DataStoreContext context)` Gets the number of persisted objects based on a filter criteria.
    `protected Long` | `countByFilter(F filter, DataStoreContext context)` Given a filter, count the number of rows that match it.
    `List<P>` | `find(F filter, SortSpecification<S> sortSpecification, DataStoreContext context)` Get the list of persistent objects based on the given filter criteria.
    `MarkPage<P>` | `find(F filter, SortSpecification<S> sortSpecification, MarkPageRequest<?> request, DataStoreContext context)`
    `List<P>` | `findAll(SortSpecification<S> sortSpecification, DataStoreContext context)` Gets all the persistent objects.
    `protected abstract <M> MarkPage<I>` | `findPagedRows(F filter, SortSpecification<S> sortSpecification, MarkPageRequest<M> request, DataStoreContext context)`
    `protected abstract Collection<I>` | `findRows(F filter, DataStoreContext context)`
    `P` | `get(I id, DataStoreContext context)` Get the persistent object with the given id.
    `protected abstract ColumnDecoder<K,?>` | `getColumnDecoder(ColumnName<K,?> columnName)`
    `protected abstract Collection<ColumnFamilyDefinition<?,?>>` | `getColumnFamilyDefinitions()`
    `protected abstract ColumnFamilyDefinition<String,?>` | `getCountCf()`
    `protected abstract String` | `getCountRowKey()`
    `protected abstract ColumnFamilyDefinition<I,K>` | `getMainColumnFamily()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### columnDecoderProvider

          protected Provider<ColumnDecoder<K extends Serializable & Comparable<K>,?>,ColumnName<K extends Serializable & Comparable<K>,?>> columnDecoderProvider

  - ### Constructor Detail

    - #### AbstractBaseDao

          public AbstractBaseDao()
                          throws PersistenceConnException

      Construct the DAO and create column families in the persistent database.
      Throws:
        `PersistenceConnException` - Database connection failure exception.

  - ### Method Detail

    - #### get

          public P get(I id,
              DataStoreContext context)

      Description copied from interface: `BaseDao`
      Get the persistent object with the given id.
      Specified by:
        `get` in interface `BaseDao<I extends Serializable,P extends Storable<I>,F,S,DataStoreContext>`
      Parameters:
        `id` - persistent object's id.
        `context` - data store context.
      Returns:
        the persistent object.

    - #### find

          public List<P> find(F filter,
                     SortSpecification<S> sortSpecification,
                     DataStoreContext context)
                                           throws Exception

      Get the list of persistent objects based on the given filter criteria.
      Specified by:
        `find` in interface `BaseDao<I extends Serializable,P extends Storable<I>,F,S,DataStoreContext>`
      Parameters:
        `filter` - filter criteria to read data.
        `sortSpecification` - sort specification.
        `context` - data store context.
      Returns:
        A set of persisted object instances.
      Throws:
        `Exception` - error

    - #### findAll

          public List<P> findAll(SortSpecification<S> sortSpecification,
                        DataStoreContext context)
                                              throws Exception

      Description copied from interface: `BaseDao`
      Gets all the persistent objects.
      Specified by:
        `findAll` in interface `BaseDao<I extends Serializable,P extends Storable<I>,F,S,DataStoreContext>`
      Parameters:
        `sortSpecification` - sort specification.
        `context` - data store context.
      Returns:
        A set of persisted object instances.
      Throws:
        `Exception` - error

    - #### countByFilter

          protected Long countByFilter(F filter,
                           DataStoreContext context)
                                throws Exception

      Given a filter, count the number of rows that match it.
      Parameters:
        `filter` - Filter object to search the database
        `context` - Context to execute the query
      Returns:
        The number of rows that match the given filter
      Throws:
        `Exception` - General exception

    - #### count

          public long count(F filter,
                   DataStoreContext context)
                     throws PersistenceConnException

      Description copied from interface: `BaseDao`
      Gets the number of persisted objects based on a filter criteria.
      Specified by:
        `count` in interface `BaseDao<I extends Serializable,P extends Storable<I>,F,S,DataStoreContext>`
      Parameters:
        `filter` - filter.
        `context` - data store context.
      Returns:
        The instances count.
      Throws:
        `PersistenceConnException` - Database connection failure exception.

    - #### find

          public MarkPage<P> find(F filter,
                         SortSpecification<S> sortSpecification,
                         MarkPageRequest<?> request,
                         DataStoreContext context)
                                               throws Exception

      Specified by:
        `find` in interface `BaseDao<I extends Serializable,P extends Storable<I>,F,S,DataStoreContext>`
      Throws:
        `Exception`

    - #### findPagedRows

          protected abstract <M> MarkPage<I> findPagedRows(F filter,
                                      SortSpecification<S> sortSpecification,
                                      MarkPageRequest<M> request,
                                      DataStoreContext context)

    - #### getColumnDecoder

          protected abstract ColumnDecoder<K,?> getColumnDecoder(ColumnName<K,?> columnName)

    - #### getColumnFamilyDefinitions

          protected abstract Collection<ColumnFamilyDefinition<?,?>> getColumnFamilyDefinitions()

    - #### getMainColumnFamily

          protected abstract ColumnFamilyDefinition<I,K> getMainColumnFamily()

    - #### findRows

          protected abstract Collection<I> findRows(F filter,
                               DataStoreContext context)
                                                                  throws Exception

      Throws:
        `Exception`

    - #### getCountRowKey

          protected abstract String getCountRowKey()

    - #### getCountCf

          protected abstract ColumnFamilyDefinition<String,?> getCountCf()

    - #### compareRows

          protected abstract int compareRows(P row1,
                        P row2,
                        SortSpecification.SortComponent<S> s)

Copyright © 2014. All Rights Reserved.