Add clonning of values in fact logging to keep initial values
This commit is contained in:
parent
337a723d49
commit
998eb9980f
21 changed files with 199 additions and 85 deletions
|
|
@ -153,7 +153,7 @@ public class DroolsChtijbugRulesExecutionService {
|
|||
return chtijbugObjectRequest;
|
||||
|
||||
} catch (DroolsChtijbugException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("FireAllRulesAndStartProcess",e);
|
||||
}
|
||||
|
||||
throw new IllegalStateException("Unable to execute command " + chtijbugObjectRequest.getObjectRequest());
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.chtijbug.drools.runtime.impl;
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
import org.chtijbug.drools.common.reflection.ReflectionUtils;
|
||||
|
|
@ -380,9 +381,12 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
public Object fireAllRulesAndStartProcess(Object inputObject, String processName) throws DroolsChtijbugException {
|
||||
DroolsFactObject inputDroolsObject = null;
|
||||
DroolsFactObject outputDroolsObject = null;
|
||||
Object inputObjectClone;
|
||||
if (inputObject != null) {
|
||||
this.insertByReflection(inputObject);
|
||||
inputDroolsObject = DroolsFactObjectFactory.createFactObject(inputObject);
|
||||
Cloner cloner = new Cloner();
|
||||
inputObjectClone=cloner.deepClone(inputObject);
|
||||
inputDroolsObject = DroolsFactObjectFactory.createFactObject(inputObjectClone);
|
||||
}
|
||||
if (processName != null && processName.length() > 0) {
|
||||
this.startProcess(processName);
|
||||
|
|
@ -537,9 +541,12 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
|
||||
DroolsFactObject inputDroolsObject = null;
|
||||
DroolsFactObject outputDroolsObject = null;
|
||||
Object inputObjectClone;
|
||||
if (inputObject != null) {
|
||||
this.insertByReflection(inputObject);
|
||||
inputDroolsObject = DroolsFactObjectFactory.createFactObject(inputObject);
|
||||
Cloner cloner = new Cloner();
|
||||
inputObjectClone=cloner.deepClone(inputObject);
|
||||
inputDroolsObject = DroolsFactObjectFactory.createFactObject(inputObjectClone);
|
||||
}
|
||||
Map<String, Object> maps = new HashMap<String, Object>();
|
||||
maps.put("inputObject", inputObject);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@
|
|||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency-->
|
||||
<dependency>
|
||||
<groupId>io.github.kostaskougios</groupId>
|
||||
<artifactId>cloning</artifactId>
|
||||
<version>1.10.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.chtijbug.drools.runtimeevent.impl.fact;
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import org.chtijbug.drools.SessionContext;
|
||||
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||
import org.chtijbug.drools.entity.history.fact.DeletedFactHistoryEvent;
|
||||
|
|
@ -34,7 +35,8 @@ public class DeleteFactEventStrategy implements AbstractMemoryEventHandlerStrate
|
|||
Fact fact = new Fact();
|
||||
fact.setFullClassName(deletedFactHistoryEvent.getDeletedObject().getFullClassName());
|
||||
fact.setObjectVersion(deletedFactHistoryEvent.getDeletedObject().getObjectVersion());
|
||||
fact.setRealFact(deletedFactHistoryEvent.getDeletedObject().getRealObject());
|
||||
Cloner cloner = new Cloner();
|
||||
fact.setRealFact(cloner.deepClone(deletedFactHistoryEvent.getDeletedObject().getRealObject()));
|
||||
fact.setModificationDate(deletedFactHistoryEvent.getDateEvent());
|
||||
fact.setFactType(FactType.DELETED);
|
||||
RuleExecution existingInSessionRuleExecution = null;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package org.chtijbug.drools.runtimeevent.impl.fact;
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import org.chtijbug.drools.SessionContext;
|
||||
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||
import org.chtijbug.drools.entity.history.fact.InsertedFactHistoryEvent;
|
||||
|
|
@ -33,7 +34,8 @@ public class InsertedFactEventStrategy implements AbstractMemoryEventHandlerStra
|
|||
Fact fact = new Fact();
|
||||
fact.setFullClassName(insertedFactHistoryEvent.getInsertedObject().getFullClassName());
|
||||
fact.setObjectVersion(insertedFactHistoryEvent.getInsertedObject().getObjectVersion());
|
||||
fact.setRealFact(insertedFactHistoryEvent.getInsertedObject().getRealObject());
|
||||
Cloner cloner = new Cloner();
|
||||
fact.setRealFact(cloner.deepClone(insertedFactHistoryEvent.getInsertedObject().getRealObject()));
|
||||
fact.setModificationDate(insertedFactHistoryEvent.getDateEvent());
|
||||
fact.setFactType(FactType.INSERTED);
|
||||
fact.setEventid(insertedFactHistoryEvent.getEventID());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package org.chtijbug.drools.runtimeevent.impl.fact;
|
||||
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import org.chtijbug.drools.SessionContext;
|
||||
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||
import org.chtijbug.drools.entity.history.fact.UpdatedFactHistoryEvent;
|
||||
|
|
@ -32,17 +33,18 @@ public class UpdatedFactEventStrategy implements AbstractMemoryEventHandlerStrat
|
|||
@Override
|
||||
public void handleMessageInternally(HistoryEvent historyEvent, SessionContext sessionContext) {
|
||||
UpdatedFactHistoryEvent updatedFactHistoryEvent = (UpdatedFactHistoryEvent) historyEvent;
|
||||
Cloner cloner=new Cloner();
|
||||
Fact factOldValue = new Fact();
|
||||
factOldValue.setFullClassName(updatedFactHistoryEvent.getObjectOldValue().getFullClassName());
|
||||
factOldValue.setObjectVersion(updatedFactHistoryEvent.getObjectOldValue().getObjectVersion());
|
||||
factOldValue.setRealFact(updatedFactHistoryEvent.getObjectOldValue().getRealObject());
|
||||
factOldValue.setRealFact(cloner.deepClone(updatedFactHistoryEvent.getObjectOldValue().getRealObject()));
|
||||
factOldValue.setModificationDate(updatedFactHistoryEvent.getDateEvent());
|
||||
factOldValue.setFactType(FactType.UPDATED_OLDVALUE);
|
||||
factOldValue.setEventid(updatedFactHistoryEvent.getEventID());
|
||||
Fact factNewValue = new Fact();
|
||||
factNewValue.setFullClassName(updatedFactHistoryEvent.getObjectNewValue().getFullClassName());
|
||||
factNewValue.setObjectVersion(updatedFactHistoryEvent.getObjectNewValue().getObjectVersion());
|
||||
factNewValue.setRealFact(updatedFactHistoryEvent.getObjectNewValue().getRealObject());
|
||||
factNewValue.setRealFact(cloner.deepClone(updatedFactHistoryEvent.getObjectNewValue().getRealObject()));
|
||||
factNewValue.setModificationDate(updatedFactHistoryEvent.getDateEvent());
|
||||
factNewValue.setFactType(FactType.UPDATED_NEWVALUE);
|
||||
factNewValue.setEventid(updatedFactHistoryEvent.getEventID());
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package org.chtijbug.drools.runtimeevent.impl.knowledgeSession;
|
||||
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import org.chtijbug.drools.SessionContext;
|
||||
import org.chtijbug.drools.entity.DroolsFactObject;
|
||||
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||
|
|
@ -31,6 +32,7 @@ public class KnowledgeSessionFireAllRulesAndStartProcessEventStrategy implements
|
|||
public void handleMessageInternally(HistoryEvent historyEvent, SessionContext sessionContext) {
|
||||
SessionFireAllRulesAndStartProcess sessionFireAllRulesAndStartProcess = (SessionFireAllRulesAndStartProcess) historyEvent;
|
||||
SessionExecution existingSessionRutime = sessionContext.getSessionExecution();
|
||||
|
||||
if (existingSessionRutime != null) {
|
||||
if (sessionFireAllRulesAndStartProcess.getInputObject() != null) {
|
||||
DroolsFactObject inputObject = sessionFireAllRulesAndStartProcess.getInputObject();
|
||||
|
|
@ -38,7 +40,8 @@ public class KnowledgeSessionFireAllRulesAndStartProcessEventStrategy implements
|
|||
inputFact.setEventid(sessionContext.getSessionExecution().getStartEventID());
|
||||
inputFact.setFactType(FactType.INPUTDATA);
|
||||
inputFact.setFullClassName(inputObject.getFullClassName());
|
||||
inputFact.setRealFact(inputObject.getRealObject());
|
||||
Cloner cloner=new Cloner();
|
||||
inputFact.setRealFact(cloner.deepClone(inputObject.getRealObject()));
|
||||
inputFact.setModificationDate(sessionFireAllRulesAndStartProcess.getDateEvent());
|
||||
inputFact.setObjectVersion(inputObject.getObjectVersion());
|
||||
existingSessionRutime.getFacts().add(inputFact);
|
||||
|
|
@ -49,7 +52,8 @@ public class KnowledgeSessionFireAllRulesAndStartProcessEventStrategy implements
|
|||
outputFact.setEventid(sessionContext.getSessionExecution().getStopEventID());
|
||||
outputFact.setFactType(FactType.OUTPUTDATA);
|
||||
outputFact.setFullClassName(outputObject.getFullClassName());
|
||||
outputFact.setRealFact(outputObject.getRealObject());
|
||||
Cloner cloner=new Cloner();
|
||||
outputFact.setRealFact(cloner.deepClone(outputObject.getRealObject()));
|
||||
outputFact.setModificationDate(sessionFireAllRulesAndStartProcess.getDateEvent());
|
||||
outputFact.setObjectVersion(outputObject.getObjectVersion());
|
||||
existingSessionRutime.getFacts().add(outputFact);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package org.chtijbug.drools.runtimeevent.impl.rule;
|
||||
|
||||
|
||||
import com.rits.cloning.Cloner;
|
||||
import org.chtijbug.drools.SessionContext;
|
||||
import org.chtijbug.drools.entity.DroolsFactObject;
|
||||
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||
|
|
@ -49,10 +50,11 @@ public class BeforeRuleFiredEventStrategy implements AbstractMemoryEventHandlerS
|
|||
ruleExecution.setRuleName(beforeRuleFiredHistoryEvent.getRule().getRuleName());
|
||||
ruleExecution.setPackageName(beforeRuleFiredHistoryEvent.getRule().getRulePackageName());
|
||||
ruleExecution.setStartEventID(beforeRuleFiredHistoryEvent.getEventID());
|
||||
Cloner cloner = new Cloner();
|
||||
for (DroolsFactObject droolsFactObject : beforeRuleFiredHistoryEvent.getWhenObjects()) {
|
||||
if (droolsFactObject != null) {
|
||||
Fact fact = new Fact();
|
||||
fact.setRealFact(droolsFactObject.getRealObject());
|
||||
fact.setRealFact(cloner.deepClone(droolsFactObject.getRealObject()));
|
||||
fact.setFactType(FactType.WHEN);
|
||||
fact.setObjectVersion(droolsFactObject.getObjectVersion());
|
||||
fact.setFullClassName(droolsFactObject.getFullClassName());
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue