Class ExcelPersistenceHandler

  • All Implemented Interfaces:
    org.datanucleus.store.StorePersistenceHandler

    public class ExcelPersistenceHandler
    extends org.datanucleus.store.AbstractPersistenceHandler
    Persistence Handler for Excel datastores. Handles the insert/update/delete/fetch/locate operations by using Apache POI. Some notes about Apache POI utilisation :-
    • We have a Workbook, composed of a set of named Sheet objects.
    • Each class is persisted to its own sheet.
    • Insert of an object requires creation of a Row. Unless we are on the last row in the sheet in which case we have a row and just need to add cells. See "delete"
    • Delete of an object will involve removal of the row, EXCEPT in the case of the final row in the sheet in which case we have to delete all cells since Apache POI doesn't seem to allow removal of the last row.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.datanucleus.store.StorePersistenceHandler

        org.datanucleus.store.StorePersistenceHandler.PersistenceBatchType
    • Field Summary

      • Fields inherited from class org.datanucleus.store.AbstractPersistenceHandler

        storeMgr
    • Constructor Summary

      Constructors 
      Constructor Description
      ExcelPersistenceHandler​(org.datanucleus.store.StoreManager storeMgr)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void deleteObject​(org.datanucleus.state.ObjectProvider op)
      Deletes a persistent object from the database.
      void fetchObject​(org.datanucleus.state.ObjectProvider op, int[] fieldNumbers)
      Fetches fields of a persistent object from the database.
      Object findObject​(org.datanucleus.ExecutionContext ec, Object id)
      Accessor for the object with the specified identity (if present).
      void insertObject​(org.datanucleus.state.ObjectProvider op)
      Method to insert the object into the datastore.
      void locateObject​(org.datanucleus.state.ObjectProvider op)
      Method to locate if an object exists in the datastore.
      void updateObject​(org.datanucleus.state.ObjectProvider op, int[] fieldNumbers)
      Method to handle the update of fields of an object in the datastore.
      • Methods inherited from class org.datanucleus.store.AbstractPersistenceHandler

        assertReadOnlyForUpdateOfObject, findObjectForUnique
      • Methods inherited from interface org.datanucleus.store.StorePersistenceHandler

        batchEnd, batchStart, deleteObjects, fetchObjects, findObjects, insertObjects, locateObjects
    • Constructor Detail

      • ExcelPersistenceHandler

        public ExcelPersistenceHandler​(org.datanucleus.store.StoreManager storeMgr)
        Constructor.
        Parameters:
        storeMgr - Manager for the datastore
    • Method Detail

      • close

        public void close()
      • insertObject

        public void insertObject​(org.datanucleus.state.ObjectProvider op)
        Method to insert the object into the datastore.
        Parameters:
        op - ObjectProvider of the object
      • updateObject

        public void updateObject​(org.datanucleus.state.ObjectProvider op,
                                 int[] fieldNumbers)
        Method to handle the update of fields of an object in the datastore.
        Parameters:
        op - Object Provider for the object
        fieldNumbers - Absolute numbers of fields to be updated
      • deleteObject

        public void deleteObject​(org.datanucleus.state.ObjectProvider op)
        Deletes a persistent object from the database.
        Parameters:
        op - The Object Provider of the object to be deleted.
        Throws:
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
        org.datanucleus.exceptions.NucleusOptimisticException - thrown if version checking fails on an optimistic transaction for this object
      • fetchObject

        public void fetchObject​(org.datanucleus.state.ObjectProvider op,
                                int[] fieldNumbers)
        Fetches fields of a persistent object from the database.
        Parameters:
        op - The ObjectProvider of the object to be fetched.
        fieldNumbers - The numbers of the fields to be fetched.
        Throws:
        org.datanucleus.exceptions.NucleusDataStoreException - when an error occurs in the datastore communication
      • findObject

        public Object findObject​(org.datanucleus.ExecutionContext ec,
                                 Object id)
        Accessor for the object with the specified identity (if present). Since we don't manage the memory instantiation of objects this just returns null.
        Parameters:
        ec - execution context
        id - Identity of the object
        Returns:
        The object
      • locateObject

        public void locateObject​(org.datanucleus.state.ObjectProvider op)
        Method to locate if an object exists in the datastore. Goes through the rows in the worksheet and finds a row with the required identity.
        Parameters:
        op - ObjectProvider of object to locate