Package org.openremote.manager.datapoint
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 Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected static final Stringprotected Pathprotected intstatic final Stringstatic final intstatic final Stringstatic final intFields inherited from class org.openremote.manager.datapoint.AbstractDatapointService
assetStorageService, dataPointsPurgeScheduledFuture, maxAmountOfQueryPoints, OR_DATA_POINTS_QUERY_LIMIT, persistenceService, PRIORITY, scheduledExecutorService, timerServiceFields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanattributeIsStoreDatapoint(org.openremote.model.value.MetaHolder attributeInfo) protected StringbuildWhereClause(List<org.openremote.model.util.Pair<String, org.openremote.model.attribute.Attribute<?>>> attributes, boolean negate) protected ScheduledFuture<File> doExportDatapoints(org.openremote.model.attribute.AttributeRef[] attributeRefs, long fromTimestamp, long toTimestamp) 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.protected Class<org.openremote.model.datapoint.AssetDatapoint> protected Stringprotected Loggerprotected StringgetSelectExportQuery(org.openremote.model.attribute.AttributeRef[] attributeRefs, long fromTimestamp, long toTimestamp) Function for building an SQL query that SELECTs the content for the data export.voidinit(org.openremote.model.Container container) voidonAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent) voidonOutdatedAttributeEvent(OutdatedAttributeEvent outdatedAttributeEvent) protected voidvoidstart(org.openremote.model.Container container) Methods inherited from class org.openremote.manager.datapoint.AbstractDatapointService
canQueryDatapoints, doPurge, doQueryDatapoints, getDatapointPeriod, getDatapoints, getDatapointsCount, getDatapointsCount, getFirstPurgeMillis, getPriority, getUpsertPreparedStatement, queryDatapoints, queryDatapoints, setUpsertValues, stop, toString, upsertValue, upsertValue, upsertValuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openremote.model.ContainerService
getPriority, stopMethods inherited from interface org.openremote.agent.protocol.ProtocolDatapointService
upsertValue, upsertValue, upsertValues
-
Field Details
-
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
- See Also:
-
OR_DATA_POINTS_EXPORT_LIMIT_DEFAULT
public static final int OR_DATA_POINTS_EXPORT_LIMIT_DEFAULT- See Also:
-
EXPORT_STORAGE_DIR_NAME
- See Also:
-
maxDatapointAgeDays
protected int maxDatapointAgeDays -
datapointExportLimit
protected int datapointExportLimit -
exportPath
-
-
Constructor Details
-
AssetDatapointService
public AssetDatapointService()
-
-
Method Details
-
init
- Specified by:
initin interfaceorg.openremote.model.ContainerService- Overrides:
initin classAbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.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
-
getDatapointClass
- Specified by:
getDatapointClassin classAbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
-
getDatapointTableName
- Specified by:
getDatapointTableNamein classAbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
-
getLogger
- Specified by:
getLoggerin classAbstractDatapointService<org.openremote.model.datapoint.AssetDatapoint>
-
purgeDataPoints
protected void purgeDataPoints() -
buildWhereClause
-
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.
-