Package org.apache.unomi.api.services
Interface RulesService
- All Known Implementing Classes:
RulesServiceImpl
public interface RulesService
A service to access and operate on
Rule
s.-
Method Summary
Modifier and TypeMethodDescriptionGet all rules available in the system.Retrieves the statistics for all the rulesgetMatchingRules
(Event event) Retrieves all the matching rules for a specific eventRetrieves the rule identified by the specified identifier.getRuleDetails
(Query query) Retrieves rule details for rules matching the specified query.Retrieves the metadata for all known rules.getRuleMetadatas
(Query query) Retrieves rule metadatas for rules matching the specifiedQuery
.getRuleStatistics
(String ruleId) Retrieves the statistics for a rulegetTrackedConditions
(Item item) Retrieves tracked conditions (rules with a condition marked with thetrackedCondition
tag and whichsourceEventCondition
matches the specified item) for the specified item.void
Refresh the rules for this instance by reloading them from the persistence backendvoid
removeRule
(String ruleId) Deletes the rule identified by the specified identifier.void
Resets all the rule statistics to zero, useful when testing or if you want to set a point in time.void
Persists the specified rule to the context server.
-
Method Details
-
getRuleMetadatas
Retrieves the metadata for all known rules. Note that it only includes the rules in memory, not those persisted in storage.- Returns:
- the Set of known metadata
-
getRuleMetadatas
Retrieves rule metadatas for rules matching the specifiedQuery
.- Parameters:
query
- the query the rules which metadata we want to retrieve must match- Returns:
- a
PartialList
of rules metadata for the rules matching the specified query
-
getRuleDetails
Retrieves rule details for rules matching the specified query.- Parameters:
query
- the query specifying which rules to retrieve- Returns:
- a
PartialList
of rule details for the rules matching the specified query
-
getAllRules
Get all rules available in the system. (This is not doing a persistence query to retrieve the rules, it's using the internal in memory cache that is refreshed every second by default but can vary depending on your own configuration)- Returns:
- all rules available.
-
getRule
Retrieves the rule identified by the specified identifier.- Parameters:
ruleId
- the identifier of the rule we want to retrieve- Returns:
- the rule identified by the specified identifier or
null
if no such rule exists.
-
getRuleStatistics
Retrieves the statistics for a rule- Parameters:
ruleId
- the identifier of the rule- Returns:
- a long representing the number of times the rule was matched and executed.
-
getAllRuleStatistics
Map<String,RuleStatistics> getAllRuleStatistics()Retrieves the statistics for all the rules- Returns:
- a map containing rule IDs as key, and the RuleStatistics object as a value
-
resetAllRuleStatistics
void resetAllRuleStatistics()Resets all the rule statistics to zero, useful when testing or if you want to set a point in time. -
setRule
Persists the specified rule to the context server.- Parameters:
rule
- the rule to be persisted
-
removeRule
Deletes the rule identified by the specified identifier.- Parameters:
ruleId
- the identifier of the rule we want to delete
-
getTrackedConditions
Retrieves tracked conditions (rules with a condition marked with thetrackedCondition
tag and whichsourceEventCondition
matches the specified item) for the specified item.- Parameters:
item
- the item which tracked conditions we want to retrieve- Returns:
- the Set of tracked conditions for the specified item
-
getMatchingRules
Retrieves all the matching rules for a specific event- Parameters:
event
- the event we want to retrieve all the matching rules for- Returns:
- a set of rules that match the event passed in the parameters
-
refreshRules
void refreshRules()Refresh the rules for this instance by reloading them from the persistence backend
-