| java.lang.Object org.zilonis.shell.GenericEventHandler
All known Subclasses: org.zilonis.tool.ui.AnalysisToolParserEventHandler,
Method Summary | |
protected Action | actionTemplate(String strId, int type, String clazz, AST child) | protected Action | actionTemplateForClass(String strId, int type, String clazz, AST child) | public void | addProduction(String name, int salience, Condition condition, Action action) | protected Condition | addRemainingAttributes(String id, LinkedList<AttributeValuePair> attributesList, Condition condition) | public void | assertTriplet(Triplet triplet) | protected Condition | conditionTemplate(String id, String clazz, AST child) | protected Condition | conditionTemplateForClass(String id, String clazz, AST child) | public void | defineAnonymousFact(String id, String clazz, AST template) | public void | defineClassFact(String id, String clazz, AST template) | public void | defineFact(AST template) | public Condition | defineRule(String name, int salience, AST conditionList, AST actionList) | public void | endDocument() | public void | error(Exception e, String message) | protected Action | getAction(int id, AST action, HashMap<String, Entity> symbolTable) | protected Action | getActionList(AST actionList, HashMap<String, Entity> symbolTable) | protected Action | getActionTemplate(int id, int type, AST actionTemplate) | protected Condition | getAssignmentCondition(String id, AST condition, AST action, HashMap<String, Entity> symbolTable) generates the conditions for an assignment on the left hand side example:
(defrule wholesalerPricing ?x <- (SKU (wholesalerOnly true) (sellPrice
?price)) => (modify ?x (sellPrice 0) (listPrice (* ?price 0.75)
(discountPrice (* 0.5 ?price))))
needs to be: (defrule wholesalerPricing (?id clazz SKU) //
getConditionTemplate returns from here (?id wholesalerOnly true) (?id
sellPrice ?price) // to here (?id listPrice ?id_var_1) (?id discountPrice
?id_var_2) => (retract (?id listPrice ?id_var_1)) (retract (?id
discountPrice ?id_var_2)) (retract (?id sellPrice ?price)) (assert (?id
sellPrice 0)) (assert (?id listPrice (* ?price 0.75))) (assert (?id
discountPrice (* ?price 0.5))))
for achieving that, we first iterate over the actions to select the
attributes that will be modified on the selected object. | protected LinkedList<AttributeValuePair> | getAttributesThatModifyActionsUseFromVariable(String id, String variable, AST action) | protected Condition | getCondition(IdGenerator idGenerator, AST condition, AST action, HashMap<String, Entity> symbolTable) | protected Condition | getConditionList(AST conditionList, AST actionList, HashMap<String, Entity> symbolTable) | protected Condition | getConditionList(IdGenerator idGenerator, AST conditionList, AST actionList, HashMap<String, Entity> symbolTable) | protected Condition | getConditionTemplate(String id, AST conditionTemplate) | protected Action | getExpressionAction(int id, AST action, HashMap<String, Entity> symbolTable) | protected Action | getModifyAction(AST action, HashMap<String, Entity> symbolTable) | public Rete | getRete() | protected Action | getRetractAction(Condition c) | public Scope | getScope() | public Condition | getTestCondition(AST condition) | public String[] | getVariables(AST ast) | public WME | jumpUntilNewId(WME wme) | public void | link() | public void | listFacts() | public void | loadFile(AST filename) | public void | noPrettyPrint() | public void | prettyPrint() | protected void | replace(LinkedList<AttributeValuePair> attributesList, String attribute, String value) | protected void | replaceAttributesThatAreInConditions(LinkedList<AttributeValuePair> attributesList, Condition condition) | public void | retractAllFacts() | public void | retractTriplet(Triplet triplet) | public void | run() | protected void | setConditionsAndSalienceTo(Action action, Condition earlierCondition, int salience) | public void | setConsole(PrintStream console) | public void | setScope(Scope scope) | public void | startDocument() | public void | unlink() |
prettyPrint | protected boolean prettyPrint(Code) | | |
GenericEventHandler | public GenericEventHandler(Rete rete)(Code) | | |
defineAnonymousFact | public void defineAnonymousFact(String id, String clazz, AST template)(Code) | | |
defineFact | public void defineFact(AST template)(Code) | | |
defineRule | public Condition defineRule(String name, int salience, AST conditionList, AST actionList)(Code) | | |
endDocument | public void endDocument()(Code) | | |
getActionTemplate | protected Action getActionTemplate(int id, int type, AST actionTemplate)(Code) | | |
getAssignmentCondition | protected Condition getAssignmentCondition(String id, AST condition, AST action, HashMap<String, Entity> symbolTable)(Code) | | generates the conditions for an assignment on the left hand side example:
(defrule wholesalerPricing ?x <- (SKU (wholesalerOnly true) (sellPrice
?price)) => (modify ?x (sellPrice 0) (listPrice (* ?price 0.75)
(discountPrice (* 0.5 ?price))))
needs to be: (defrule wholesalerPricing (?id clazz SKU) //
getConditionTemplate returns from here (?id wholesalerOnly true) (?id
sellPrice ?price) // to here (?id listPrice ?id_var_1) (?id discountPrice
?id_var_2) => (retract (?id listPrice ?id_var_1)) (retract (?id
discountPrice ?id_var_2)) (retract (?id sellPrice ?price)) (assert (?id
sellPrice 0)) (assert (?id listPrice (* ?price 0.75))) (assert (?id
discountPrice (* ?price 0.5))))
for achieving that, we first iterate over the actions to select the
attributes that will be modified on the selected object. From those
actions we get the variables. In the above example that would include
listPrice and discountPrice. This operation is done in
getAttributesThatModifyActionsUseFromVariable After that, we modify the
attributes that are already in use in the conditions. Then we add the
attributes that were left as another condition to the condition list. and
finally creating the entity for the symbol table to be use when
generating the actions
|
getAttributesThatModifyActionsUseFromVariable | protected LinkedList<AttributeValuePair> getAttributesThatModifyActionsUseFromVariable(String id, String variable, AST action)(Code) | | this method returns the that the modify actions modify
on the specified variables the values are generated dynamically based on
the id
|
listFacts | public void listFacts()(Code) | | |
loadFile | public void loadFile(AST filename)(Code) | | |
noPrettyPrint | public void noPrettyPrint()(Code) | | |
prettyPrint | public void prettyPrint()(Code) | | |
replaceAttributesThatAreInConditions | protected void replaceAttributesThatAreInConditions(LinkedList<AttributeValuePair> attributesList, Condition condition)(Code) | | We check each condition to make sure that the conditions that were
already in the rule are not define twice
|
retractAllFacts | public void retractAllFacts()(Code) | | |
setConditionsAndSalienceTo | protected void setConditionsAndSalienceTo(Action action, Condition earlierCondition, int salience)(Code) | | |
startDocument | public void startDocument()(Code) | | |
unlink | public void unlink()(Code) | | Used by the UI tools To unlink the creation of rules from the UI
|
|
|