use of org.kie.pmml.models.drools.utils.KiePMMLSessionUtils in project drools by kiegroup.
the class KiePMMLDroolsModel method evaluate.
@Override
public Object evaluate(final Object knowledgeBase, final Map<String, Object> requestData, final PMMLContext context) {
logger.trace("evaluate {} {}", knowledgeBase, requestData);
if (!(knowledgeBase instanceof KieBase)) {
throw new KiePMMLException(String.format("Expecting KieBase, received %s", knowledgeBase.getClass().getName()));
}
final PMML4Result toReturn = getPMML4Result(targetField);
String fullClassName = this.getClass().getName();
String packageName = fullClassName.contains(".") ? fullClassName.substring(0, fullClassName.lastIndexOf('.')) : "";
KiePMMLSessionUtils.Builder builder = KiePMMLSessionUtils.builder((KieBase) knowledgeBase, name, packageName, toReturn).withObjectsInSession(requestData, fieldTypeMap).withOutputFieldsMap(context.getOutputFieldsMap());
if (logger.isDebugEnabled()) {
builder = builder.withAgendaEventListener(agendaEventListener);
}
final KiePMMLSessionUtils kiePMMLSessionUtils = builder.build();
kiePMMLSessionUtils.fireAllRules();
return toReturn;
}
Aggregations