Class AssetDatapointService

java.lang.Object
org.openremote.manager.datapoint.AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
org.openremote.manager.datapoint.AssetDatapointService
All Implemented Interfaces:
org.openremote.agent.protocol.ProtocolDatapointService, org.openremote.model.ContainerService

public class AssetDatapointService extends AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint> implements org.openremote.agent.protocol.ProtocolDatapointService
Store and retrieve datapoints for asset attributes and periodically purge data points based on MetaItemType.DATA_POINTS_MAX_AGE_DAYS MetaItem and OR_DATA_POINTS_MAX_AGE_DAYS setting; storage duration defaults to 31 days.
  • Field Details

    • OR_DATA_POINTS_MAX_AGE_DAYS

      public static final String OR_DATA_POINTS_MAX_AGE_DAYS
      See Also:
    • OR_DATA_POINTS_MAX_AGE_DAYS_DEFAULT

      public static final int OR_DATA_POINTS_MAX_AGE_DAYS_DEFAULT
      See Also:
    • OR_DATA_POINTS_EXPORT_LIMIT

      public static final String OR_DATA_POINTS_EXPORT_LIMIT
      See Also:
    • OR_DATA_POINTS_EXPORT_LIMIT_DEFAULT

      public static final int OR_DATA_POINTS_EXPORT_LIMIT_DEFAULT
      See Also:
    • EXPORT_STORAGE_DIR_NAME

      protected static final String EXPORT_STORAGE_DIR_NAME
      See Also:
    • maxDatapointAgeDays

      protected int maxDatapointAgeDays
    • datapointExportLimit

      protected int datapointExportLimit
    • exportPath

      protected Path exportPath
  • Constructor Details

    • AssetDatapointService

      public AssetDatapointService()
  • Method Details

    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Overrides:
      init in class AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • attributeIsStoreDatapoint

      public static boolean attributeIsStoreDatapoint(org.openremote.model.value.MetaHolder attributeInfo)
    • onAttributeEvent

      public void onAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent)
    • onOutdatedAttributeEvent

      public void onOutdatedAttributeEvent(OutdatedAttributeEvent outdatedAttributeEvent)
    • getDatapointClass

      protected Class<org.openremote.model.datapoint.AssetDatapoint> getDatapointClass()
      Specified by:
      getDatapointClass in class AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
    • getDatapointTableName

      protected String getDatapointTableName()
      Specified by:
      getDatapointTableName in class AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
    • getLogger

      protected Logger getLogger()
      Specified by:
      getLogger in class AbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
    • purgeDataPoints

      protected void purgeDataPoints()
    • buildWhereClause

      protected String buildWhereClause(List<org.openremote.model.util.Pair<String,org.openremote.model.attribute.Attribute<?>>> attributes, boolean negate)
    • exportDatapoints

      public ScheduledFuture<File> exportDatapoints(org.openremote.model.attribute.AttributeRef[] attributeRefs, long fromTimestamp, long toTimestamp)
      Exports datapoints as CSV using SQL; the export path used in the SQL query must also be mapped into the manager container so it can be accessed by this process.
    • doExportDatapoints

      protected ScheduledFuture<File> doExportDatapoints(org.openremote.model.attribute.AttributeRef[] attributeRefs, long fromTimestamp, long toTimestamp)
    • getSelectExportQuery

      protected String getSelectExportQuery(org.openremote.model.attribute.AttributeRef[] attributeRefs, long fromTimestamp, long toTimestamp)
      Function for building an SQL query that SELECTs the content for the data export. Currently, it includes timestamp, asset name, attribute name, and the data point value. Be aware: this SQL query does NOT contain any CSV-related statements.