java.lang.Object
com.erudika.para.core.persistence.MockDAO
All Implemented Interfaces:
DAO

@Singleton public class MockDAO extends Object implements DAO
Fake DAO for in-memory persistence. Used for testing and development without a database.
Author:
Alex Bogdanovski [[email protected]]
  • Constructor Details

    • MockDAO

      public MockDAO()
  • Method Details

    • create

      public <P extends ParaObject> String create(String appid, P so)
      Description copied from interface: DAO
      Persists an object to the data store.
      Specified by:
      create in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      so - the domain object
      Returns:
      the object's id or null if not created.
    • read

      public <P extends ParaObject> P read(String appid, String key)
      Description copied from interface: DAO
      Retrieves an object from the data store.
      Specified by:
      read in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      key - an object id
      Returns:
      the object or null if not found
    • update

      public <P extends ParaObject> void update(String appid, P so)
      Description copied from interface: DAO
      Updates an object permanently.
      Specified by:
      update in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      so - the domain object
    • delete

      public <P extends ParaObject> void delete(String appid, P so)
      Description copied from interface: DAO
      Deletes an object permanently.
      Specified by:
      delete in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      so - the domain object
    • createAll

      public <P extends ParaObject> void createAll(String appid, List<P> objects)
      Description copied from interface: DAO
      Saves multiple objects to the data store.
      Specified by:
      createAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      objects - the list of objects to save
    • readAll

      public <P extends ParaObject> Map<String,P> readAll(String appid, List<String> keys, boolean getAllColumns)
      Description copied from interface: DAO
      Retrieves multiple objects from the data store.
      Specified by:
      readAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      keys - a list of object ids
      getAllColumns - true if all columns must be retrieved. used to save bandwidth.
      Returns:
      a map of ids to objects
    • readPage

      public <P extends ParaObject> List<P> readPage(String appid, Pager pager)
      Description copied from interface: DAO
      Reads a fixed number of objects. Used for scanning a data store page by page. Calling this method would bypass the read cache and will hit the DB.
      Specified by:
      readPage in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      pager - a Pager
      Returns:
      a list of objects
    • updateAll

      public <P extends ParaObject> void updateAll(String appid, List<P> objects)
      Description copied from interface: DAO
      Updates multiple objects.
      Specified by:
      updateAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      objects - a list of objects to update
    • deleteAll

      public <P extends ParaObject> void deleteAll(String appid, List<P> objects)
      Description copied from interface: DAO
      Deletes multiple objects.
      Specified by:
      deleteAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      appid - name of the App
      objects - a list of objects to delete
    • create

      public <P extends ParaObject> String create(P so)
      Description copied from interface: DAO
      Persists an object to the data store.
      Specified by:
      create in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      so - the domain object
      Returns:
      the object's id or null if not created.
    • read

      public <P extends ParaObject> P read(String key)
      Description copied from interface: DAO
      Retrieves an object from the data store.
      Specified by:
      read in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      key - an object id
      Returns:
      the object or null if not found
    • update

      public <P extends ParaObject> void update(P so)
      Description copied from interface: DAO
      Updates an object permanently.
      Specified by:
      update in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      so - the domain object
    • delete

      public <P extends ParaObject> void delete(P so)
      Description copied from interface: DAO
      Deletes an object permanently.
      Specified by:
      delete in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      so - the domain object
    • createAll

      public <P extends ParaObject> void createAll(List<P> objects)
      Description copied from interface: DAO
      Saves multiple objects to the data store.
      Specified by:
      createAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      objects - the list of objects to save
    • readAll

      public <P extends ParaObject> Map<String,P> readAll(List<String> keys, boolean getAllColumns)
      Description copied from interface: DAO
      Retrieves multiple objects from the data store.
      Specified by:
      readAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      keys - a list of object ids
      getAllColumns - true if all columns must be retrieved. used to save bandwidth.
      Returns:
      a map of ids to objects
    • readPage

      public <P extends ParaObject> List<P> readPage(Pager pager)
      Description copied from interface: DAO
      Reads a fixed number of objects. Used for scanning a data store page by page. Calling this method would bypass the read cache and will hit the DB.
      Specified by:
      readPage in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      pager - a Pager
      Returns:
      a list of objects
    • updateAll

      public <P extends ParaObject> void updateAll(List<P> objects)
      Description copied from interface: DAO
      Updates multiple objects.
      Specified by:
      updateAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      objects - a list of objects to update
    • deleteAll

      public <P extends ParaObject> void deleteAll(List<P> objects)
      Description copied from interface: DAO
      Deletes multiple objects.
      Specified by:
      deleteAll in interface DAO
      Type Parameters:
      P - the type of object
      Parameters:
      objects - a list of objects to delete