let me clear this by following code
public static void main(String[] args){
KnowledgeBase knowledgeBase = createKnowledgeBase();
ArrayList<SalesAmount> testSalesAmounts= getSalesAmount();
StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession();
for(SalesAmount eachSalesAmount: testSalesAmounts){
session.insert(eachSalesAmount);
session.fireAllRules();
}
}
public static ArrayList<SalesAmount> getTestSalesAmounts(){
ArrayList<SalesAmount> testSalesAmount = new ArrayList<SalesAmount>();
for(int i =0; i<15;i++){
Random random = new Random();
SalesAmount.testSalesAmount= new SalesAmount();
testSalesAmount.setId(i);
testSalesAmount.setSalesAmount(random.nextInt(500));
testSalesAmounts.add(testSalesAmount);
}
return testSalesAmounts;
}
SalesAmounts is assigned randomly using util class
and each fact is inserted at a time in the loop control
if after the loop , the data changes how can i fire the rules
please modify my code if any mistakes you find........
regards