Class FilteringDatumDao

java.lang.Object
net.solarnetwork.node.dao.FilteringDatumDao
All Implemented Interfaces:
DatumDao

public class FilteringDatumDao extends Object implements DatumDao
Delegating DAO for NodeDatum that applies filters before persisting.
Since:
2.0
Version:
1.0
Author:
matt
  • Constructor Details

    • FilteringDatumDao

      public FilteringDatumDao(net.solarnetwork.service.OptionalService<DatumDao> delegate, net.solarnetwork.service.OptionalService<net.solarnetwork.service.DatumFilterService> filterService)
      Constructor.
      Parameters:
      delegate - the DAO to delegate to
      filterService - the transformer service
  • Method Details

    • storeDatum

      public void storeDatum(NodeDatum datum)
      Description copied from interface: DatumDao
      Store (create or update) a datum.
      Specified by:
      storeDatum in interface DatumDao
      Parameters:
      datum - the datum to persist
    • getDatumNotUploaded

      public List<NodeDatum> getDatumNotUploaded(String destination)
      Description copied from interface: DatumDao
      Get a List of Datum instances that have not been uploaded yet to a specific destination.

      This does not need to return all data, it can limit the amount returned at one time to conserve memory. This method can be called repeatedly if needed.

      Specified by:
      getDatumNotUploaded in interface DatumDao
      Parameters:
      destination - the destination to check
      Returns:
      list of Datum, or empty List if none available
    • setDatumUploaded

      public void setDatumUploaded(NodeDatum datum, Instant date, String destination, String trackingId)
      Description copied from interface: DatumDao
      Mark a datum as uploaded.
      Specified by:
      setDatumUploaded in interface DatumDao
      Parameters:
      datum - the Datum that has been uploaded successfully
      date - the date it was uploaded
      destination - the destination the Datum was uploaded to
      trackingId - the remote tracking ID assigned to the uploaded Datum
    • deleteUploadedDataOlderThan

      public int deleteUploadedDataOlderThan(int hours)
      Description copied from interface: DatumDao
      Delete both Datum and DatumUpload objects that have been successfully uploaded to at least one destination and are older than the specified number of hours.

      This is designed to free up space from local database storage for devices with limited storage capacity. It will not delete any Datum objects that have not been successfully uploaded anywhere.

      Specified by:
      deleteUploadedDataOlderThan in interface DatumDao
      Parameters:
      hours - the minimum number of hours old the data must be to delete
      Returns:
      the number of Datum (and associated DatumUpload) entities deleted