Search in sources :

Example 11 with KnowledgeBuilderResult

use of org.kie.internal.builder.KnowledgeBuilderResult in project drools by kiegroup.

the class PMML4Compiler method compile.

public String compile(InputStream source, ClassLoader classLoader) {
    this.results = new ArrayList<KnowledgeBuilderResult>();
    PMML pmml = loadModel(PMML, source);
    return compile(pmml, classLoader);
}
Also used : PMML(org.kie.dmg.pmml.pmml_4_2.descr.PMML) KnowledgeBuilderResult(org.kie.internal.builder.KnowledgeBuilderResult)

Example 12 with KnowledgeBuilderResult

use of org.kie.internal.builder.KnowledgeBuilderResult in project drools by kiegroup.

the class PMML4Compiler method precompile.

public List<PMMLResource> precompile(InputStream stream, ClassLoader classLoader, KieBaseModel rootKieBaseModel) {
    List<PMMLResource> resources = new ArrayList<>();
    KieServices services = KieServices.Factory.get();
    KieModuleModel module = services.newKieModuleModel();
    this.results = new ArrayList<KnowledgeBuilderResult>();
    PMML pmml = loadModel(PMML, stream);
    helper.setResolver(classLoader);
    PMML4Unit unit = new PMML4UnitImpl(pmml);
    if (unit.containsMiningModel()) {
        Miningmodel rootModel = unit.getRootMiningModel();
        resources = buildResourcesFromModel(pmml, rootModel, null, classLoader, module);
    } else {
        PMML4Model rootModel = unit.getRootModel();
        if (rootModel != null) {
            helper.setPack(rootModel.getModelPackageName());
            KieBaseModel kbm = module.newKieBaseModel(rootModel.getModelId());
            kbm.addPackage(helper.getPack()).setDefault(true).setEventProcessingMode(EventProcessingOption.CLOUD);
            PMMLResource resource = new PMMLResource(helper.getPack());
            resource.setKieBaseModel(kbm);
            resource.addRules(rootModel.getModelId(), this.compile(pmml, classLoader));
            resources.add(resource);
        }
    }
    return resources;
}
Also used : ArrayList(java.util.ArrayList) Miningmodel(org.kie.pmml.pmml_4_2.model.Miningmodel) KieServices(org.kie.api.KieServices) PMMLResource(org.drools.compiler.compiler.PMMLResource) KieBaseModel(org.kie.api.builder.model.KieBaseModel) KieModuleModel(org.kie.api.builder.model.KieModuleModel) PMML(org.kie.dmg.pmml.pmml_4_2.descr.PMML) PMML4UnitImpl(org.kie.pmml.pmml_4_2.model.PMML4UnitImpl) KnowledgeBuilderResult(org.kie.internal.builder.KnowledgeBuilderResult)

Aggregations

KnowledgeBuilderResult (org.kie.internal.builder.KnowledgeBuilderResult)12 ArrayList (java.util.ArrayList)6 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)3 PackageDescr (org.drools.compiler.lang.descr.PackageDescr)3 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 PMMLResource (org.drools.compiler.compiler.PMMLResource)2 ProjectClassLoader (org.drools.core.common.ProjectClassLoader)2 PMML (org.kie.dmg.pmml.pmml_4_2.descr.PMML)2 ResultSeverity (org.kie.internal.builder.ResultSeverity)2 JCodeModel (com.sun.codemodel.JCodeModel)1 BadCommandLineException (com.sun.tools.xjc.BadCommandLineException)1 ErrorReceiver (com.sun.tools.xjc.ErrorReceiver)1 Model (com.sun.tools.xjc.model.Model)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1