Class RulesFacts

java.lang.Object
org.jeasy.rules.api.Facts
org.openremote.manager.rules.RulesFacts
All Implemented Interfaces:
Iterable<org.jeasy.rules.api.Fact<?>>, org.jeasy.rules.api.RuleListener

public class RulesFacts extends org.jeasy.rules.api.Facts implements org.jeasy.rules.api.RuleListener
NOTE: THIS IS NOT THREADSAFE
  • Field Details

    • MAX_RULES_TRIGGERED_PER_EXECUTION

      public static final int MAX_RULES_TRIGGERED_PER_EXECUTION
      See Also:
    • INITIAL_CAPACITY

      public static final int INITIAL_CAPACITY
      See Also:
    • ASSET_STATES

      public static final String ASSET_STATES
      See Also:
    • EXECUTION_VARS

      public static final String EXECUTION_VARS
      See Also:
    • ANONYMOUS_FACTS

      public static final String ANONYMOUS_FACTS
      See Also:
    • timerService

      protected final org.openremote.container.timer.TimerService timerService
    • assetStorageService

      protected final AssetStorageService assetStorageService
    • assetsFacade

      protected final org.openremote.model.rules.Assets assetsFacade
    • loggingContext

      protected final Object loggingContext
    • LOG

      protected final Logger LOG
    • triggerCount

      protected int triggerCount
    • trackLocationRules

      protected boolean trackLocationRules
    • assetStateLocationPredicateMap

      protected Map<String,Set<org.openremote.model.query.filter.GeofencePredicate>> assetStateLocationPredicateMap
  • Constructor Details

    • RulesFacts

      public RulesFacts(org.openremote.container.timer.TimerService timerService, AssetStorageService assetStorageService, org.openremote.model.rules.Assets assetsFacade, Object loggingContext, Logger logger)
  • Method Details

    • startTrackingLocationRules

      protected void startTrackingLocationRules()
    • stopTrackingLocationRules

      protected List<RulesEngine.AssetLocationPredicates> stopTrackingLocationRules()
    • getAssetStates

      public Collection<org.openremote.model.attribute.AttributeInfo> getAssetStates()
    • getAnonymousFacts

      public Collection<Object> getAnonymousFacts()
    • getNamedFacts

      public Map<String,Object> getNamedFacts()
    • getAllFacts

      public Stream<Object> getAllFacts()
    • getFactCount

      public long getFactCount()
    • getVars

      public Map<String,Object> getVars()
    • bind

      public RulesFacts bind(String var, Object value)
    • bound

      public <T> T bound(String var)
    • get

      public <T> T get(String name)
      Overrides:
      get in class org.jeasy.rules.api.Facts
    • getOptional

      public <T> Optional<T> getOptional(String name)
    • put

      public <T> void put(String name, T fact)
      Overrides:
      put in class org.jeasy.rules.api.Facts
    • put

      public RulesFacts put(Object o)
    • putAssetState

      public RulesFacts putAssetState(org.openremote.model.attribute.AttributeInfo assetState)
    • removeAssetState

      public RulesFacts removeAssetState(org.openremote.model.attribute.AttributeInfo assetState)
    • putTemporary

      public RulesFacts putTemporary(String expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(Duration expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(double expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(long expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(String name, String expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(String name, double expires, Object value)
    • putTemporary

      public RulesFacts putTemporary(String name, long expires, Object value)
    • hasTemporaryFacts

      public boolean hasTemporaryFacts()
    • getTemporaryFacts

      public Stream<org.openremote.model.rules.TemporaryFact<?>> getTemporaryFacts()
    • remove

      public void remove(String name)
      Overrides:
      remove in class org.jeasy.rules.api.Facts
    • remove

      public RulesFacts remove(Object fact)
    • reset

      public void reset()
      Reset rules triggered counter, used for loop detection.
    • beforeEvaluate

      public boolean beforeEvaluate(org.jeasy.rules.api.Rule rule, org.jeasy.rules.api.Facts facts)
      Specified by:
      beforeEvaluate in interface org.jeasy.rules.api.RuleListener
    • afterEvaluate

      public void afterEvaluate(org.jeasy.rules.api.Rule rule, org.jeasy.rules.api.Facts facts, boolean evaluationResult)
      Specified by:
      afterEvaluate in interface org.jeasy.rules.api.RuleListener
    • beforeExecute

      public void beforeExecute(org.jeasy.rules.api.Rule rule, org.jeasy.rules.api.Facts facts)
      Specified by:
      beforeExecute in interface org.jeasy.rules.api.RuleListener
    • onSuccess

      public void onSuccess(org.jeasy.rules.api.Rule rule, org.jeasy.rules.api.Facts facts)
      Specified by:
      onSuccess in interface org.jeasy.rules.api.RuleListener
    • onFailure

      public void onFailure(org.jeasy.rules.api.Rule rule, org.jeasy.rules.api.Facts facts, Exception exception)
      Specified by:
      onFailure in interface org.jeasy.rules.api.RuleListener
    • matchFact

      protected <T> Optional<T> matchFact(Object fact, Class<T> factType, Predicate<T> predicate)
    • matchFirst

      public <T> Optional<T> matchFirst(String name)
    • matchFirst

      public <T> Optional<T> matchFirst(String name, Predicate<T> predicate)
    • matchFirst

      public <T> Optional<T> matchFirst(String name, Class<T> factType, Predicate<T> predicate)
    • matchFirst

      public <T> Optional<T> matchFirst(Predicate<T> predicate)
    • matchFirst

      public <T> Optional<T> matchFirst(Class<T> factType)
    • matchFirst

      public <T> Optional<T> matchFirst(Class<T> factType, Predicate<T> predicate)
    • match

      public <T> Stream<T> match(Predicate<T> predicate)
    • match

      public <T> Stream<T> match(Class<T> factType)
    • match

      public <T> Stream<T> match(Class<T> factType, Predicate<T> predicate)
    • matchFirstAssetState

      public Optional<org.openremote.model.attribute.AttributeInfo> matchFirstAssetState(org.openremote.model.query.AssetQuery assetQuery)
    • matchAssetState

      public Stream<org.openremote.model.attribute.AttributeInfo> matchAssetState(org.openremote.model.query.AssetQuery assetQuery)
    • matchAssetState

      public Stream<org.openremote.model.attribute.AttributeInfo> matchAssetState(Predicate<org.openremote.model.attribute.AttributeInfo> p)
    • updateAssetState

      @Deprecated public RulesFacts updateAssetState(String assetId, String attributeName, Object value)
      Deprecated.
    • updateAssetState

      @Deprecated public RulesFacts updateAssetState(String assetId, String attributeName)
      Deprecated.
    • removeExpiredTemporaryFacts

      public void removeExpiredTemporaryFacts()
    • logFacts

      public boolean logFacts(Logger logger, Level level)
    • logVars

      public boolean logVars(Logger logger)
    • getClock

      public org.openremote.model.rules.RulesClock getClock()
    • asComparator

      public static Comparator<org.openremote.model.attribute.AttributeInfo> asComparator(org.openremote.model.query.AssetQuery.OrderBy orderBy)
    • storeLocationPredicates

      protected void storeLocationPredicates(List<org.openremote.model.query.filter.GeofencePredicate> foundLocationPredicates)
    • logRule

      protected void logRule(org.jeasy.rules.api.Rule rule, String msg, boolean logFacts, boolean logVars)