Class BaseDatumFilterSupport
- All Implemented Interfaces:
net.solarnetwork.service.Identifiable
- Direct Known Subclasses:
DatumFilterChainService
DatumFilterService to extend.- Since:
- 2.0
- Version:
- 1.1
- Author:
- matt
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default stat logging frequency.static final StringThe default value for the UID property.protected final net.solarnetwork.util.StatCounterA stats counter.Fields inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
logFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.BaseDatumFilterSupport(net.solarnetwork.util.StatCounter.Stat[] stats) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanconditionsMatch(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String, Object> parameters) Test if any configured conditions match the given arguments.net.solarnetwork.service.OptionalService<DatumService> Get the datum service.Get a description of this service.Get the operational modes service to use.Get an operational mode that is required by this service.Get the required tag expression.Get the source ID pattern.protected PatternGet the source ID regex.protected StringGenerate a status message.protected voidincrementIgnoredStats(long startTime) Increment the statistics for an "ignored" invocation.protected longIncrement the statistics for "input" invocation.protected voidincrementStats(long startTime, net.solarnetwork.domain.datum.DatumSamplesOperations in, net.solarnetwork.domain.datum.DatumSamplesOperations out) Increment the statistics for a "not ignored" invocation.static booleanmatchesAny(Pattern[] pats, String value, boolean emptyPatternMatches) Test if any regular expression in a set matches a string value.protected booleanTest if the configured required operational mode is active.static voidpopulateBaseSampleTransformSupportSettings(List<net.solarnetwork.settings.SettingSpecifier> settings) Populate settings for theBaseDatumFilterSupportclass.static voidpopulateBaseSampleTransformSupportSettings(List<net.solarnetwork.settings.SettingSpecifier> settings, String sourceIdDefault, String requiredOperationalModeDefault, String requiredTagDefault) Populate settings for theBaseDatumFilterSupportclass.protected voidpopulateStatusSettings(List<net.solarnetwork.settings.SettingSpecifier> settings) Populate a "status" setting.voidsetDatumService(net.solarnetwork.service.OptionalService<DatumService> datumService) Set the datum service.voidsetOpModesService(OperationalModesService opModesService) Set the operational modes service to use.voidsetRequiredOperationalMode(String requiredOperationalMode) Set an operational mode that is required by this service.voidsetRequiredTag(String requiredTag) Set the required tag expression.voidsetSourceId(String sourceIdPattern) Set a source ID pattern to match samples against.voidsmartPlaceholders(Map<String, Object> parameters) Create a parameter map that includes placeholders.protected booleansourceIdMatches(net.solarnetwork.domain.datum.Datum datum) Test if a given datum's source ID matches the configured source ID pattern.protected booleantagMatches(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples) Test if the configuredgetRequiredTag()expression matches the given datum or samples.Methods inherited from class net.solarnetwork.node.service.support.BaseIdentifiable
baseIdentifiableSettings, baseIdentifiableSettings, getExpressionServices, getPlaceholderService, populateExpressionDatumProperties, resolvePlaceholders, resolvePlaceholders, setExpressionServices, setPlaceholderServiceMethods inherited from class net.solarnetwork.service.support.BasicIdentifiable
basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getDisplayName, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUID, smartMetadataValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.solarnetwork.service.Identifiable
getDisplayName, getGroupUid, getUid
-
Field Details
-
DEFAULT_UID
The default value for the UID property.- See Also:
-
DEFAULT_STAT_LOG_FREQUENCY
public static final int DEFAULT_STAT_LOG_FREQUENCYThe default stat logging frequency.- Since:
- 1.2
- See Also:
-
stats
protected final net.solarnetwork.util.StatCounter statsA stats counter.The base stats will be
DatumFilterStats.- Since:
- 1.2
-
-
Constructor Details
-
BaseDatumFilterSupport
public BaseDatumFilterSupport()Constructor. -
BaseDatumFilterSupport
public BaseDatumFilterSupport(net.solarnetwork.util.StatCounter.Stat[] stats) Constructor.- Parameters:
stats- the status to use (can be null- Since:
- 1.2
-
-
Method Details
-
populateBaseSampleTransformSupportSettings
public static void populateBaseSampleTransformSupportSettings(List<net.solarnetwork.settings.SettingSpecifier> settings) Populate settings for theBaseDatumFilterSupportclass.This will use null for all default values.
- Parameters:
settings- the settings to populate- Since:
- 1.1
- See Also:
-
populateBaseSampleTransformSupportSettings
public static void populateBaseSampleTransformSupportSettings(List<net.solarnetwork.settings.SettingSpecifier> settings, String sourceIdDefault, String requiredOperationalModeDefault, String requiredTagDefault) Populate settings for theBaseDatumFilterSupportclass.This will add settings for the
sourceIdandrequiredOperationalModesettings.- Parameters:
settings- the list to add settings tosourceIdDefault- the defaultsourceIdvaluerequiredOperationalModeDefault- the defaultrequiredOperationalModevaluerequiredTagDefault- therequiredTagdefault value- Since:
- 1.1
-
populateStatusSettings
Populate a "status" setting.- Parameters:
settings- the settings to add the status to- Since:
- 1.2
- See Also:
-
getStatusMessage
Generate a status message.This will resolve the status.msg message and pass in parameters for all of the
DatumFilterStatsvalues along with a processing time average and "not ignored" processing time average.- Returns:
- the status message
-
incrementInputStats
protected long incrementInputStats()Increment the statistics for "input" invocation.- Returns:
- the current time, for passing to
incrementIgnoredStats(long)orincrementStats(long, DatumSamplesOperations, DatumSamplesOperations)later - Since:
- 1.2
-
incrementIgnoredStats
protected void incrementIgnoredStats(long startTime) Increment the statistics for an "ignored" invocation.- Parameters:
startTime- the start time- Since:
- 1.2
-
incrementStats
protected void incrementStats(long startTime, net.solarnetwork.domain.datum.DatumSamplesOperations in, net.solarnetwork.domain.datum.DatumSamplesOperations out) Increment the statistics for a "not ignored" invocation.- Parameters:
startTime- the start timein- the input samplesout- the output samples- Since:
- 1.2
-
matchesAny
Test if any regular expression in a set matches a string value.- Parameters:
pats- the regular expressions to usevalue- the value to testemptyPatternMatches- true if a null regular expression is treated as a match (thus matching any value)- Returns:
- true if at least one regular expression matches
value
-
sourceIdMatches
protected boolean sourceIdMatches(net.solarnetwork.domain.datum.Datum datum) Test if a given datum's source ID matches the configured source ID pattern.- Parameters:
datum- the datum whose source ID should be tested- Returns:
- true if the datum's
sourceIdvalue matches the configured source ID pattern, or no pattern is configured
-
operationalModeMatches
protected boolean operationalModeMatches()Test if the configured required operational mode is active.If
getRequiredOperationalMode()is configured but#getOpModesService()is not, this method will always return false.- Returns:
- true if an operational mode is required and that mode is currently active
- Since:
- 1.1
-
tagMatches
protected boolean tagMatches(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples) Test if the configuredgetRequiredTag()expression matches the given datum or samples.If no required tag expression is configured, this method returns true. Otherwise, the expression is split on a comma delimiter (surrounding whitespace is allowed) and each tag is tested against the
samplesanddatum. If any tag matches, true is returned, thus the multiple required tags are treated as if joined by a logicalORoperator. Any individual tag may be prefixed by ! to invert the match logic, meaning the given samples match if the given tag is not present.- Parameters:
datum- the datum (may be null)samples- the samples (may be null)- Returns:
- true if the configured
requiredTagexpression matches eithersamplesordatum - Since:
- 1.1
-
conditionsMatch
protected boolean conditionsMatch(net.solarnetwork.domain.datum.Datum datum, net.solarnetwork.domain.datum.DatumSamplesOperations samples, Map<String, Object> parameters) Test if any configured conditions match the given arguments.This method calls the following condition-testing methods:
Extending classes can override this to add additional tests.
- Parameters:
datum- the datum associated withsamplessamples- the samples object to transformparameters- optional implementation-specific parameters to pass to the transformer- Returns:
- true if all of the condition-testing methods return true
- Since:
- 1.1
-
smartPlaceholders
Create a parameter map that includes placeholders.If the
BaseIdentifiable.getPlaceholderService()is configured thePlaceholderService.smartCopyPlaceholders(Map)method will be invoked to create validNumberinstances out of placeholder values. Theparametersmap, if provided, will be copied into the returned map, overwriting any duplicate entries.- Parameters:
parameters- an optional set of parameters to copy into the result- Returns:
- a new map, never null
- Since:
- 1.1
-
getSourceIdPattern
Get the source ID regex.- Returns:
- the regex
-
getDescription
Get a description of this service.- Returns:
- the description
-
setUid
- Overrides:
setUidin classnet.solarnetwork.service.support.BasicIdentifiable
-
getSourceId
Get the source ID pattern.- Returns:
- The pattern.
-
setSourceId
Set a source ID pattern to match samples against. Samples will only be considered for filtering ifDatum.getSourceId()matches this pattern. ThesourceIdPatternmust be a validPatternregular expression. The expression will be allowed to match anywhere inDatum.getSourceId()values, so if the pattern must match the full value only then use pattern positional expressions like^and$.- Parameters:
sourceIdPattern- The source ID regex to match. Syntax errors in the pattern will be ignored and a null value will be set instead.
-
getOpModesService
Get the operational modes service to use.- Returns:
- the service, or null
-
setOpModesService
Set the operational modes service to use.- Parameters:
opModesService- the service to use- Since:
- 1.1
-
getRequiredOperationalMode
Get an operational mode that is required by this service.- Returns:
- the required operational mode, or null for none
- Since:
- 1.1
-
setRequiredOperationalMode
Set an operational mode that is required by this service.- Parameters:
requiredOperationalMode- the required operational mode, or null or an empty string that will be treated as null- Since:
- 1.1
-
getDatumService
Get the datum service.- Returns:
- the datum service
-
setDatumService
Set the datum service.- Parameters:
datumService- the datum service
-
getRequiredTag
Get the required tag expression.- Returns:
- the required tag
- Since:
- 1.1
-
setRequiredTag
Set the required tag expression.- Parameters:
requiredTag- the tag expression to set- Since:
- 1.1
-