[rules-users] Looping through a vector object in a rule
sdinoo
sdinoo at gmail.com
Thu May 5 08:03:31 EDT 2011
Hi Michael
Thank you for helping me out - but I need some more help
Pardon my ignorance, but I am still not clear how this can be done
I am looking for something in the language that will allow me to iterate
through the entire List/Vector object by object and then access each object
instances values like Object.getClaimAmount
Here is my calling program
public static final void main(String[] args) {
DURUtils rc = new DURUtils();
//Load the claims from CSV into History
ClaimsHistory claims = new ClaimsHistory();
List<DurClaim> historyClaims = claims.getHistory();
System.out.println("List Size = " + historyClaims.size());
//Create a New Incoming object
IncomingClaim ic = new IncomingClaim();
DurClaim inClaim = ic.getIncomingClaim();
try {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
ksession.insert(inClaim);
ksession.insert(historyClaims);
ksession.startProcess("com.drughistory");
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("trials/ClaimProcessing.bpmn"),
ResourceType.BPMN2);
//kbuilder.add(ResourceFactory.newClassPathResource("DurClaimRules.drl"),
ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("trials/History.drl"),
ResourceType.DRL);
return kbuilder.newKnowledgeBase();
}
All I want to do is some computation using the
incomingClaim with a List of the historyClaims
The incoming claim and the historyclaims are of the same model claim called
DURClaim
Again, this may be a very elemental question but I thought there would be an
easier way of doing this as I would like to keep the iteration processing in
the rule rather than outside in a Java Class
--
View this message in context: http://drools.46999.n3.nabble.com/Looping-through-a-vector-object-in-a-rule-tp2897872p2903115.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list