Skip to content

Instantly share code, notes, and snippets.

@leogomes
Created October 20, 2013 19:15
Show Gist options
  • Save leogomes/7073936 to your computer and use it in GitHub Desktop.
Save leogomes/7073936 to your computer and use it in GitHub Desktop.
New version of generated CompiledNetwork that actually compiles :)
package org.drools.core.reteoo.compiled;
public class Compiledorg_drools_compiler_PersonNetwork extends
org.drools.core.reteoo.compiled.CompiledNetwork {
private org.drools.core.rule.constraint.MvelConstraint mvelConstraint15; // [AlphaNode(15)
// constraint=age
// ==
// 32]
private org.drools.core.rule.ContextEntry contextEntry15;
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode16; // [LeftInputAdapterNode(16)]
private java.util.Map nameToNodeId = new java.util.HashMap();
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode4; // [LeftInputAdapterNode(4)]
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode13; // [LeftInputAdapterNode(13)]
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode10; // [LeftInputAdapterNode(10)]
private org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode7; // [LeftInputAdapterNode(7)]
public Compiledorg_drools_compiler_PersonNetwork() {
nameToNodeId.put("Jose", 9);
nameToNodeId.put("Maria", 12);
nameToNodeId.put("Leo", 3);
nameToNodeId.put("Ana", 6);
}
protected void setNetworkNodeReference(
org.drools.core.common.NetworkNode node) {
switch (node.getId()) {
case 15:
mvelConstraint15 = (org.drools.core.rule.constraint.MvelConstraint) ((org.drools.core.reteoo.AlphaNode) node)
.getConstraint();
contextEntry15 = mvelConstraint15.createContextEntry();
break;
case 16:
leftInputAdapterNode16 = (org.drools.core.reteoo.LeftInputAdapterNode) node;
break;
case 4:
leftInputAdapterNode4 = (org.drools.core.reteoo.LeftInputAdapterNode) node;
break;
case 13:
leftInputAdapterNode13 = (org.drools.core.reteoo.LeftInputAdapterNode) node;
break;
case 10:
leftInputAdapterNode10 = (org.drools.core.reteoo.LeftInputAdapterNode) node;
break;
case 7:
leftInputAdapterNode7 = (org.drools.core.reteoo.LeftInputAdapterNode) node;
break;
}
}
public final void assertObject(
org.drools.core.common.InternalFactHandle handle,
org.drools.core.spi.PropagationContext context,
org.drools.core.common.InternalWorkingMemory wm) {
org.drools.compiler.Person fact = (org.drools.compiler.Person) handle
.getObject();
if (mvelConstraint15.isAllowed(handle, wm, contextEntry15)) {
leftInputAdapterNode16.assertObject(handle, context, wm);
}
Integer nameNodeId = (Integer) nameToNodeId.get(fact.getName());
if (nameNodeId != null) {
switch (nameNodeId.intValue()) {
case 3:
leftInputAdapterNode4.assertObject(handle, context, wm);
break;
case 12:
leftInputAdapterNode13.assertObject(handle, context, wm);
break;
case 9:
leftInputAdapterNode10.assertObject(handle, context, wm);
break;
case 6:
leftInputAdapterNode7.assertObject(handle, context, wm);
break;
}
}
}
public final void modifyObject(
org.drools.core.common.InternalFactHandle handle,
org.drools.core.reteoo.ModifyPreviousTuples modifyPreviousTuples,
org.drools.core.spi.PropagationContext context,
org.drools.core.common.InternalWorkingMemory wm) {
org.drools.compiler.Person fact = (org.drools.compiler.Person) handle
.getObject();
if (mvelConstraint15.isAllowed(handle, wm, contextEntry15)) {
leftInputAdapterNode16.modifyObject(handle, modifyPreviousTuples,
context, wm);
}
Integer nameNodeId = (Integer) nameToNodeId.get(fact.getName());
if (nameNodeId != null) {
switch (nameNodeId.intValue()) {
case 3:
leftInputAdapterNode4.modifyObject(handle,
modifyPreviousTuples, context, wm);
break;
case 12:
leftInputAdapterNode13.modifyObject(handle,
modifyPreviousTuples, context, wm);
break;
case 9:
leftInputAdapterNode10.modifyObject(handle,
modifyPreviousTuples, context, wm);
break;
case 6:
leftInputAdapterNode7.modifyObject(handle,
modifyPreviousTuples, context, wm);
break;
}
}
}
public final void byPassModifyToBetaNode(
org.drools.core.common.InternalFactHandle handle,
org.drools.core.reteoo.ModifyPreviousTuples modifyPreviousTuples,
org.drools.core.spi.PropagationContext context,
org.drools.core.common.InternalWorkingMemory wm) {
// Do I need to implement this?
}
public java.util.Map getAssociations() {
return new java.util.HashMap(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment