Search in sources :

Example 1 with BaseKnowledgeBuilderResultImpl

use of org.drools.compiler.compiler.BaseKnowledgeBuilderResultImpl in project drools by kiegroup.

the class KnowledgeBuilderImpl method addProcessFromXml.

public void addProcessFromXml(Resource resource) {
    if (processBuilder == null) {
        throw new RuntimeException("Unable to instantiate a process assembler");
    }
    if (ResourceType.DRF.equals(resource.getResourceType())) {
        addBuilderResult(new DeprecatedResourceTypeWarning(resource, "RF"));
    }
    this.resource = resource;
    try {
        List<Process> processes = processBuilder.addProcessFromXml(resource);
        List<BaseKnowledgeBuilderResultImpl> errors = processBuilder.getErrors();
        if (errors.isEmpty()) {
            if (this.kBase != null && processes != null) {
                for (Process process : processes) {
                    if (filterAccepts(ResourceChange.Type.PROCESS, process.getNamespace(), process.getId())) {
                        this.kBase.addProcess(process);
                    }
                }
            }
        } else {
            this.results.addAll(errors);
            errors.clear();
        }
    } catch (Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        }
        addBuilderResult(new ProcessLoadError(resource, "Unable to load process.", e));
    }
    this.results = getResults(this.results);
    this.resource = null;
}
Also used : ProcessLoadError(org.drools.compiler.compiler.ProcessLoadError) BaseKnowledgeBuilderResultImpl(org.drools.compiler.compiler.BaseKnowledgeBuilderResultImpl) Process(org.kie.api.definition.process.Process) DeprecatedResourceTypeWarning(org.drools.compiler.compiler.DeprecatedResourceTypeWarning) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ExpanderException(org.drools.compiler.lang.ExpanderException) DroolsParserException(org.drools.compiler.compiler.DroolsParserException) SAXException(org.xml.sax.SAXException)

Aggregations

IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 BaseKnowledgeBuilderResultImpl (org.drools.compiler.compiler.BaseKnowledgeBuilderResultImpl)1 DeprecatedResourceTypeWarning (org.drools.compiler.compiler.DeprecatedResourceTypeWarning)1 DroolsParserException (org.drools.compiler.compiler.DroolsParserException)1 ProcessLoadError (org.drools.compiler.compiler.ProcessLoadError)1 ExpanderException (org.drools.compiler.lang.ExpanderException)1 Process (org.kie.api.definition.process.Process)1 SAXException (org.xml.sax.SAXException)1