upgrade to 7.25.0.Final and update to new internal API and object of drools
This commit is contained in:
parent
54e4d6de45
commit
cb36a81265
6 changed files with 36 additions and 24 deletions
|
|
@ -22,7 +22,9 @@ import org.chtijbug.drools.entity.history.fact.InsertedFactHistoryEvent;
|
|||
import org.chtijbug.drools.entity.history.fact.UpdatedFactHistoryEvent;
|
||||
import org.chtijbug.drools.runtime.DroolsFactObjectFactory;
|
||||
import org.drools.core.definitions.rule.impl.RuleImpl;
|
||||
import org.drools.core.event.rule.impl.RuleRuntimeEventImpl;
|
||||
import org.drools.core.event.rule.impl.ObjectDeletedEventImpl;
|
||||
import org.drools.core.event.rule.impl.ObjectInsertedEventImpl;
|
||||
import org.drools.core.event.rule.impl.ObjectUpdatedEventImpl;
|
||||
import org.drools.core.spi.PropagationContext;
|
||||
import org.kie.api.event.rule.ObjectDeletedEvent;
|
||||
import org.kie.api.event.rule.ObjectInsertedEvent;
|
||||
|
|
@ -32,6 +34,10 @@ import org.kie.api.runtime.rule.FactHandle;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//import org.drools.core.definitions.rule.impl.RuleImpl;
|
||||
//import org.drools.core.event.rule.impl.RuleRuntimeEventImpl;
|
||||
//import org.drools.core.spi.PropagationContext;
|
||||
|
||||
public class FactHandlerListener implements RuleRuntimeEventListener {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(FactHandlerListener.class);
|
||||
|
|
@ -53,15 +59,13 @@ public class FactHandlerListener implements RuleRuntimeEventListener {
|
|||
ruleBaseSession.setData(f, newObject, ff);
|
||||
//____ Adding the Insert Event from the History Container
|
||||
InsertedFactHistoryEvent insertFactHistoryEvent = new InsertedFactHistoryEvent(this.ruleBaseSession.nextEventId(), ff, this.ruleBaseSession.getRuleBaseID(), this.ruleBaseSession.getSessionId());
|
||||
if (insertFactHistoryEvent.getRuleName() == null && event instanceof RuleRuntimeEventImpl) {
|
||||
PropagationContext propagationContext = ((RuleRuntimeEventImpl) event).getPropagationContext();
|
||||
if (insertFactHistoryEvent.getRuleName() == null && event instanceof ObjectInsertedEventImpl) {
|
||||
PropagationContext propagationContext = ((ObjectInsertedEventImpl) event).getPropagationContext();
|
||||
this.updateRuleDetailFromPropagationContext(propagationContext, insertFactHistoryEvent);
|
||||
|
||||
}
|
||||
this.ruleBaseSession.addHistoryElement(insertFactHistoryEvent);
|
||||
} finally
|
||||
|
||||
{
|
||||
} finally {
|
||||
logger.debug("<<objectInserted");
|
||||
}
|
||||
|
||||
|
|
@ -81,8 +85,8 @@ public class FactHandlerListener implements RuleRuntimeEventListener {
|
|||
ruleBaseSession.setData(f, newValue, factNewValue);
|
||||
//____ Adding the Update Event from the History Container
|
||||
UpdatedFactHistoryEvent updatedFactHistoryEvent = new UpdatedFactHistoryEvent(this.ruleBaseSession.nextEventId(), factOldValue, factNewValue, this.ruleBaseSession.getRuleBaseID(), this.ruleBaseSession.getSessionId());
|
||||
if (updatedFactHistoryEvent.getRuleName() == null && event instanceof RuleRuntimeEventImpl) {
|
||||
PropagationContext propagationContext = ((RuleRuntimeEventImpl) event).getPropagationContext();
|
||||
if (updatedFactHistoryEvent.getRuleName() == null && event instanceof ObjectUpdatedEventImpl) {
|
||||
PropagationContext propagationContext = ((ObjectUpdatedEventImpl) event).getPropagationContext();
|
||||
this.updateRuleDetailFromPropagationContext(propagationContext, updatedFactHistoryEvent);
|
||||
}
|
||||
this.ruleBaseSession.addHistoryElement(updatedFactHistoryEvent);
|
||||
|
|
@ -103,8 +107,8 @@ public class FactHandlerListener implements RuleRuntimeEventListener {
|
|||
//____ Adding a Delete Event from the HistoryContainer
|
||||
|
||||
DeletedFactHistoryEvent deleteFactEvent = new DeletedFactHistoryEvent(this.ruleBaseSession.nextEventId(), deletedFact, this.ruleBaseSession.getRuleBaseID(), this.ruleBaseSession.getSessionId());
|
||||
if (event instanceof RuleRuntimeEventImpl) {
|
||||
PropagationContext propagationContext = ((RuleRuntimeEventImpl) event).getPropagationContext();
|
||||
if (event instanceof ObjectDeletedEventImpl) {
|
||||
PropagationContext propagationContext = ((ObjectDeletedEventImpl) event).getPropagationContext();
|
||||
this.updateRuleDetailFromPropagationContext(propagationContext, deleteFactEvent);
|
||||
this.ruleBaseSession.addHistoryElement(deleteFactEvent);
|
||||
}
|
||||
|
|
@ -114,11 +118,13 @@ public class FactHandlerListener implements RuleRuntimeEventListener {
|
|||
}
|
||||
|
||||
private void updateRuleDetailFromPropagationContext(PropagationContext propagationContext, FactHistoryEvent historyEvent) {
|
||||
if (propagationContext.getRuleOrigin() instanceof RuleImpl) {
|
||||
if (propagationContext.getRuleOrigin() != null
|
||||
&& propagationContext.getRuleOrigin() instanceof RuleImpl) {
|
||||
RuleImpl ruleOrigin = (RuleImpl) propagationContext.getRuleOrigin();
|
||||
historyEvent.setRuleName(ruleOrigin.getName());
|
||||
historyEvent.setRulePackageName(ruleOrigin.getPackageName());
|
||||
historyEvent.setRuleflowGroup(ruleOrigin.getRuleFlowGroup());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -46,6 +46,8 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
//import org.drools.core.definitions.rule.impl.RuleImpl;
|
||||
|
||||
/**
|
||||
* @author nheron
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ import org.chtijbug.drools.entity.history.rule.AfterRuleFlowActivatedHistoryEven
|
|||
import org.chtijbug.drools.entity.history.rule.AfterRuleFlowDeactivatedHistoryEvent;
|
||||
import org.chtijbug.drools.entity.history.rule.BeforeRuleFiredHistoryEvent;
|
||||
import org.chtijbug.drools.entity.history.session.SessionFireAllRulesMaxNumberReachedEvent;
|
||||
import org.drools.core.common.DefaultFactHandle;
|
||||
import org.drools.core.common.InternalFactHandle;
|
||||
import org.drools.core.reteoo.InitialFactImpl;
|
||||
import org.kie.api.event.rule.*;
|
||||
import org.kie.api.runtime.KieRuntime;
|
||||
import org.kie.api.runtime.rule.FactHandle;
|
||||
|
|
@ -34,6 +34,9 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
//import org.drools.core.common.InternalFactHandle;
|
||||
//import org.drools.core.reteoo.InitialFactImpl;
|
||||
|
||||
|
||||
/**
|
||||
* @author nheron
|
||||
|
|
@ -86,16 +89,17 @@ public class RuleHandlerListener extends DefaultAgendaEventListener {
|
|||
BeforeRuleFiredHistoryEvent newBeforeRuleEvent = new BeforeRuleFiredHistoryEvent(this.ruleBaseSession.nextEventId(), this.nbRuleFired + 1, droolsRuleObject, this.ruleBaseSession.getRuleBaseID(), this.ruleBaseSession.getSessionId());
|
||||
//____ Adding all objects info contained in the Activation object into the history Events
|
||||
for (FactHandle h : listFact) {
|
||||
if (h instanceof InternalFactHandle) {
|
||||
if (h instanceof DefaultFactHandle) {
|
||||
InternalFactHandle defaultFactHandle = (InternalFactHandle) h;
|
||||
//System.out.println(defaultFactHandle.toString());
|
||||
if (defaultFactHandle.getObject() instanceof InitialFactImpl) {
|
||||
// org.drools.reteoo.InitialFactImpl initialFact = (org.drools.reteoo.InitialFactImpl)defaultFactHandle.getObject();
|
||||
//TODO in case of NOT, OR, etc..
|
||||
Object object = defaultFactHandle.getObject();
|
||||
DroolsFactObject sourceFactObject = ruleBaseSession.getLastFactObjectVersionFromFactHandle(h);
|
||||
newBeforeRuleEvent.getWhenObjects().add(sourceFactObject);
|
||||
|
||||
} else {
|
||||
DroolsFactObject sourceFactObject = ruleBaseSession.getLastFactObjectVersionFromFactHandle(h);
|
||||
newBeforeRuleEvent.getWhenObjects().add(sourceFactObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//_____ Add Event into the History Container
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.chtijbug.drools.runtime.test
|
|||
|
||||
import org.chtijbug.drools.runtime.test.Fibonacci;
|
||||
|
||||
dialect "mvel"
|
||||
dialect "java"
|
||||
|
||||
rule "infiniteLoop"
|
||||
when
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.chtijbug.drools.runtime.test
|
|||
|
||||
import org.chtijbug.drools.runtime.test.Fibonacci;
|
||||
|
||||
dialect "mvel"
|
||||
dialect "java"
|
||||
|
||||
rule Recurse
|
||||
when
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -20,7 +20,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<jbpm.version>7.23.0.Final</jbpm.version>
|
||||
<jbpm.version>7.25.0.Final</jbpm.version>
|
||||
|
||||
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue