Search in sources :

Example 1 with ProcessErrorHandler

use of org.jbpm.process.builder.ProcessErrorHandler in project jbpm by kiegroup.

the class JavaProcessDialect method addProcess.

public void addProcess(final ProcessBuildContext context) {
    JavaDialect javaDialect = (JavaDialect) context.getDialectRegistry().getDialect("java");
    String processClass = processClassBuilder.buildRule(context);
    if (processClass == null) {
        // nothing to compile.
        return;
    }
    final Process process = context.getProcess();
    final ProcessDescr processDescr = context.getProcessDescr();
    // The compilation result is for the entire rule, so difficult to
    // associate with any descr
    javaDialect.addClassCompileTask(context.getPkg().getName() + "." + processDescr.getClassName(), processDescr, processClass, null, new ProcessErrorHandler(processDescr, process, "Process Compilation error"));
    JavaDialectRuntimeData data = (JavaDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData(javaDialect.getId());
    for (final Iterator it = context.getInvokers().keySet().iterator(); it.hasNext(); ) {
        final String className = (String) it.next();
        // Check if an invoker - Action has been associated
        // If so we add it to the PackageCompilationData as it will get
        // wired up on compilation
        final Object invoker = context.getInvokerLookup(className);
        if (invoker != null && invoker instanceof Wireable) {
            data.putInvoker(className, (Wireable) invoker);
        }
        final String text = (String) context.getInvokers().get(className);
        final BaseDescr descr = (BaseDescr) context.getDescrLookup(className);
        javaDialect.addClassCompileTask(className, descr, text, null, new ProcessInvokerErrorHandler(processDescr, process, "Unable to generate action invoker."));
    }
// setup the line mappins for this rule
// TODO @TODO must setup mappings
// final String name = this.pkg.getName() + "." + StringUtils.ucFirst(
// ruleDescr.getClassName() );
// final LineMappings mapping = new LineMappings( name );
// mapping.setStartLine( ruleDescr.getConsequenceLine() );
// mapping.setOffset( ruleDescr.getConsequenceOffset() );
// 
// context.getPkg().getPackageCompilationData().getLineMappings().put(
// name,
// mapping );
}
Also used : ProcessErrorHandler(org.jbpm.process.builder.ProcessErrorHandler) Wireable(org.drools.core.spi.Wireable) Iterator(java.util.Iterator) Process(org.kie.api.definition.process.Process) ProcessDescr(org.drools.compiler.lang.descr.ProcessDescr) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) ProcessInvokerErrorHandler(org.jbpm.process.builder.ProcessInvokerErrorHandler) JavaDialectRuntimeData(org.drools.core.rule.JavaDialectRuntimeData) JavaDialect(org.drools.compiler.rule.builder.dialect.java.JavaDialect)

Aggregations

Iterator (java.util.Iterator)1 BaseDescr (org.drools.compiler.lang.descr.BaseDescr)1 ProcessDescr (org.drools.compiler.lang.descr.ProcessDescr)1 JavaDialect (org.drools.compiler.rule.builder.dialect.java.JavaDialect)1 JavaDialectRuntimeData (org.drools.core.rule.JavaDialectRuntimeData)1 Wireable (org.drools.core.spi.Wireable)1 ProcessErrorHandler (org.jbpm.process.builder.ProcessErrorHandler)1 ProcessInvokerErrorHandler (org.jbpm.process.builder.ProcessInvokerErrorHandler)1 Process (org.kie.api.definition.process.Process)1