25 lines
815 B
Python
25 lines
815 B
Python
from core.rule import Rule, ACTION_TYPE_TEST
|
|
|
|
|
|
class RuleForTestingRete(Rule):
|
|
def __init__(self, *disjunctions, name=None):
|
|
"""
|
|
:param disjunctions: list of list of Condition. List of OR. inner list is a list of AND
|
|
:para name: optional name for the rule
|
|
"""
|
|
try:
|
|
predicate = " or ".join([
|
|
" and ".join([str(c) for c in disjunction.conditions]) for disjunction in
|
|
disjunctions])
|
|
except AttributeError:
|
|
predicate = "N/A"
|
|
|
|
super().__init__(ACTION_TYPE_TEST, name, predicate)
|
|
self.disjunctions = disjunctions
|
|
self.metadata.id = 9999
|
|
self.metadata.is_compiled = True
|
|
self.metadata.is_enabled = True
|
|
|
|
def get_rete_disjunctions(self):
|
|
return self.disjunctions
|