WIP
This commit is contained in:
parent
e4b31838f4
commit
6dfd6e4148
83 changed files with 1276 additions and 3084 deletions
|
|
@ -52,8 +52,8 @@ public class RuleBaseSingleton implements RuleBasePackage {
|
|||
/**
|
||||
* unique ID of the RuleBase in the JVM
|
||||
*/
|
||||
protected EventCounter eventCounter = EventCounter.newCounter();
|
||||
protected EventCounter sessionCounter = EventCounter.newCounter();
|
||||
protected EventCounter eventCounter = EventCounter.Companion.newCounter();
|
||||
protected EventCounter sessionCounter = EventCounter.Companion.newCounter();
|
||||
/**
|
||||
* Rule Base ID
|
||||
*/
|
||||
|
|
@ -170,7 +170,7 @@ public class RuleBaseSingleton implements RuleBasePackage {
|
|||
try {
|
||||
lockKbase.acquire();
|
||||
} catch (Exception e) {
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.KbaseAcquire, "", e);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getKbaseAcquire(), "", e);
|
||||
}
|
||||
//_____ Now we can create a new stateful session using KnowledgeBase
|
||||
//_____ Now we can create a new stateful session using KnowledgeBase
|
||||
|
|
@ -200,7 +200,7 @@ public class RuleBaseSingleton implements RuleBasePackage {
|
|||
newRuleBaseSession = new RuleBaseStatefulSession(this.ruleBaseID, sessionId, newDroolsSession, maxNumberRulesToExecute, sessionHistoryListener);
|
||||
//_____ Release semaphore
|
||||
} else {
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.KbaseNotInitialised, "", null);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getKbaseNotInitialised(), "", null);
|
||||
}
|
||||
//____ return the wrapped KnowledgeSession
|
||||
return newRuleBaseSession;
|
||||
|
|
@ -228,7 +228,7 @@ public class RuleBaseSingleton implements RuleBasePackage {
|
|||
kieContainer = this.knowledgeModule.build();
|
||||
} catch (Exception e) {
|
||||
logger.error("error to load Agent", e);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.ErrorToLoadAgent, "", e);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getErrorToLoadAgent(), "", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
private Long sessionId;
|
||||
|
||||
private HistoryListener historyListener;
|
||||
private EventCounter eventCounter = EventCounter.newCounter();
|
||||
private EventCounter eventCounter = EventCounter.Companion.newCounter();
|
||||
private Cloner cloner = new Cloner(new ObjenesisInstantiationStrategy());
|
||||
|
||||
public RuleBaseStatefulSession(Long ruleBaseID, Long sessionId, KieSession knowledgeSession, int maxNumberRuleToExecute, HistoryListener historyListener) throws DroolsChtijbugException {
|
||||
|
|
@ -129,13 +129,13 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
DroolsProcessObject droolsProcessObject = processList.get(processInstance.getProcess().getId());
|
||||
|
||||
if (droolsProcessObject == null) {
|
||||
droolsProcessObject = DroolsProcessObject.createDroolsProcessObject(processInstance.getProcess().getId(),
|
||||
droolsProcessObject = DroolsProcessObject.Companion.createDroolsProcessObject(processInstance.getProcess().getId(),
|
||||
processInstance.getProcess().getName(),
|
||||
processInstance.getProcess().getPackageName(), processInstance.getProcess().getType(), processInstance.getProcess().getVersion());
|
||||
processList.put(processInstance.getProcess().getId(), droolsProcessObject);
|
||||
}
|
||||
|
||||
droolsProcessInstanceObject = DroolsProcessInstanceObject.createDroolsProcessInstanceObject(String.valueOf(processInstance.getId()), droolsProcessObject);
|
||||
droolsProcessInstanceObject = DroolsProcessInstanceObject.Companion.createDroolsProcessInstanceObject(String.valueOf(processInstance.getId()), droolsProcessObject);
|
||||
processInstanceList.put(droolsProcessInstanceObject.getId(), droolsProcessInstanceObject);
|
||||
}
|
||||
return droolsProcessInstanceObject;
|
||||
|
|
@ -168,10 +168,10 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
|
||||
DroolsNodeInstanceObject droolsNodeInstanceObject = droolsProcessInstanceObject.getDroolsNodeInstanceObjet(String.valueOf(nodeInstance.getId()));
|
||||
if (droolsNodeInstanceObject == null) {
|
||||
DroolsNodeObject droolsNodeObject = DroolsNodeObject.createDroolsNodeObject(String.valueOf(nodeInstance.getNode().getId()), nodeType);
|
||||
DroolsNodeObject droolsNodeObject = DroolsNodeObject.Companion.createDroolsNodeObject(String.valueOf(nodeInstance.getNode().getId()), nodeType);
|
||||
droolsProcessInstanceObject.getProcess().addDroolsNodeObject(droolsNodeObject);
|
||||
droolsNodeObject.setRuleflowGroupName(ruleFlowGroupName);
|
||||
droolsNodeInstanceObject = DroolsNodeInstanceObject.createDroolsNodeInstanceObject(String.valueOf(nodeInstance.getId()), droolsNodeObject);
|
||||
droolsNodeInstanceObject = DroolsNodeInstanceObject.Companion.createDroolsNodeInstanceObject(String.valueOf(nodeInstance.getId()), droolsNodeObject);
|
||||
droolsProcessInstanceObject.addDroolsNodeInstanceObject(droolsNodeInstanceObject);
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
DroolsRuleObject droolsRuleObject = listRules.get(rule.toString());
|
||||
RuleImpl ruleInstance = (RuleImpl) rule;
|
||||
if (droolsRuleObject == null) {
|
||||
droolsRuleObject = DroolsRuleObject.createDroolRuleObject(rule.getName(), rule.getPackageName());
|
||||
droolsRuleObject = DroolsRuleObject.Companion.createDroolRuleObject(rule.getName(), rule.getPackageName());
|
||||
droolsRuleObject.setRuleFlowGroup(ruleInstance.getAgendaGroup());
|
||||
addDroolsRuleObject(droolsRuleObject);
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
try {
|
||||
getterValue = method.invoke(newObject, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.insertByReflection, "getterValue = method.invoke(newObject, (Object[]) null);", e);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getInsertByReflection(), "getterValue = method.invoke(newObject, (Object[]) null);", e);
|
||||
}
|
||||
if (getterValue == null)
|
||||
continue;
|
||||
|
|
@ -406,7 +406,7 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
try {
|
||||
this.knowledgeSession.fireAllRules();
|
||||
} catch (Exception e) {
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.fireAllRules, "", e);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getFireAllRules(), "", e);
|
||||
}
|
||||
|
||||
long stopTime = System.currentTimeMillis();
|
||||
|
|
@ -416,7 +416,7 @@ public class RuleBaseStatefulSession implements RuleBaseSession {
|
|||
SessionFireAllRulesMaxNumberReachedEvent sessionFireAllRulesMaxNumberReachedEvent = new SessionFireAllRulesMaxNumberReachedEvent(eventCounter.next(), ruleHandlerListener.getNbRuleFired(), maxNumberRuleToExecute, this.ruleBaseID, this.sessionId);
|
||||
this.addHistoryElement(sessionFireAllRulesMaxNumberReachedEvent);
|
||||
}
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.MaxNumberRuleExecutionReached, "nbRulesExecuted" + afterNumberRules + " and MaxNumberRules for the session is set to " + maxNumberRuleToExecute, null);
|
||||
throw new DroolsChtijbugException(DroolsChtijbugException.Companion.getMaxNumberRuleExecutionReached(), "nbRulesExecuted" + afterNumberRules + " and MaxNumberRules for the session is set to " + maxNumberRuleToExecute, null);
|
||||
}
|
||||
if (this.historyListener != null) {
|
||||
SessionFireAllRulesEndEvent sessionFireAllRulesEndEvent = new SessionFireAllRulesEndEvent(eventCounter.next(), this.ruleBaseID, this.sessionId, stopTime - startTime, afterNumberRules - beforeNumberRules);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import static org.junit.Assert.fail;
|
|||
* Time: 09:44
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class RuleHandlerListenerTest {
|
||||
public class RuleHandlerHistoryListenerTest {
|
||||
static RuleBasePackage ruleBasePackage;
|
||||
RuleBaseSession session;
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public class RuleHandlerListenerTest {
|
|||
session.fireAllRules();
|
||||
fail();
|
||||
} catch (DroolsChtijbugException e) {
|
||||
assertThat(e.getKey()).isEqualTo(DroolsChtijbugException.MaxNumberRuleExecutionReached);
|
||||
assertThat(e.getKey()).isEqualTo(DroolsChtijbugException.Companion.getMaxNumberRuleExecutionReached());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ public class RuleHandlerListenerTest {
|
|||
fail();
|
||||
} catch (DroolsChtijbugException e) {
|
||||
assertThat(session.getNumberRulesExecuted()).isEqualTo(10);
|
||||
assertThat(e.getKey()).isEqualTo(DroolsChtijbugException.MaxNumberRuleExecutionReached);
|
||||
assertThat(e.getKey()).isEqualTo(DroolsChtijbugException.Companion.getMaxNumberRuleExecutionReached());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue