use of org.drools.runtime.StatelessKnowledgeSession in project jBPM5-Developer-Guide by Salaboy.
the class DefineCarPriceWorkItemHandler method executeWorkItem.
public void executeWorkItem(WorkItem wi, WorkItemManager wim) {
Car car = (Car) wi.getParameter("carInput");
System.out.println("Defining Car Price" + car);
StatelessKnowledgeSession session = createStatelessSession();
session.execute(car);
Map<String, Object> params = new HashMap<String, Object>();
params.put("carOutput", car);
wim.completeWorkItem(wi.getId(), params);
}
use of org.drools.runtime.StatelessKnowledgeSession in project jBPM5-Developer-Guide by Salaboy.
the class RankCarWorkItemHandler method executeWorkItem.
public void executeWorkItem(WorkItem wi, WorkItemManager wim) {
Car car = (Car) wi.getParameter("carInput");
System.out.println("Ranking Car" + car);
StatelessKnowledgeSession session = createStatelessSession();
session.execute(car);
Map<String, Object> params = new HashMap<String, Object>();
params.put("carOutput", car);
wim.completeWorkItem(wi.getId(), params);
}
use of org.drools.runtime.StatelessKnowledgeSession in project jBPM5-Developer-Guide by Salaboy.
the class RulesHelper method evaluate.
public static boolean evaluate(Car car) {
if (cachedResults.containsKey(car.getName())) {
return cachedResults.get(car.getName());
}
StatelessKnowledgeSession session = createStatelessSession("good_old_patterns/car-sell-or-drop-complex-decision.drl");
List list = new ArrayList();
list.add(car);
// Get external information that you don't want to keep in the process, for example:
// - Call an external service to get information about the stock market
// - Check the average price for this type of cars in ebay
// - Check for the competitors prices in the last two months
// We can get a metric about the current status of the market
// when the process is being executed and use that to influence our decision
MarketMetric metric = new MarketMetric(0.8);
list.add(metric);
session.execute(list);
cachedResults.put(car.getName(), metric.getResult());
return metric.getResult();
}
Aggregations