Search in sources :

Example 1 with KiePMMLSessionUtils

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;
}
Also used : PMML4Result(org.kie.api.pmml.PMML4Result) KiePMMLSessionUtils(org.kie.pmml.models.drools.utils.KiePMMLSessionUtils) KieBase(org.kie.api.KieBase) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException)

Aggregations

KieBase (org.kie.api.KieBase)1 PMML4Result (org.kie.api.pmml.PMML4Result)1 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)1 KiePMMLSessionUtils (org.kie.pmml.models.drools.utils.KiePMMLSessionUtils)1