Examples of SubProcess


Examples of org.eclipse.bpmn2.SubProcess

    return reason;
  }

  @Override
  public boolean update(IUpdateContext context) {
    SubProcess process = (SubProcess) getBusinessObjectForPictogramElement(context.getPictogramElement());

    Graphiti.getPeService().setPropertyValue(context.getPictogramElement(), TRIGGERED_BY_EVENT,
            Boolean.toString(process.isTriggeredByEvent()));

    RoundedRectangle rectangle = (RoundedRectangle) Graphiti.getPeService()
            .getAllContainedPictogramElements(context.getPictogramElement()).iterator().next()
            .getGraphicsAlgorithm();
    LineStyle lineStyle = process.isTriggeredByEvent() ? LineStyle.DOT : LineStyle.SOLID;
    rectangle.setLineStyle(lineStyle);

    return true;
  }
View Full Code Here

Examples of org.eclipse.bpmn2.SubProcess

      super(fp, "Expanded Sub-Process", "Inner activity");
    }

    @Override
    protected SubProcess createFlowElement(ICreateContext context) {
      SubProcess subProcess = ModelHandler.FACTORY.createSubProcess();
      subProcess.setName("SubProcess");
      subProcess.setTriggeredByEvent(false);
      return subProcess;
    }
View Full Code Here

Examples of org.eclipse.bpmn2.SubProcess

  public PictogramElement add(IAddContext context) {

    int width = context.getWidth() > 0 ? context.getWidth() : 100;
    int height = context.getHeight() > 0 ? context.getHeight() : 100;

    SubProcess subprocess = (SubProcess) context.getNewObject();

    IGaService gaService = Graphiti.getGaService();
    IPeService peService = Graphiti.getPeService();

    ContainerShape containerShape = peService.createContainerShape(context.getTargetContainer(), true);
    Rectangle invisibleRect = gaService.createInvisibleRectangle(containerShape);

    gaService.setLocationAndSize(invisibleRect, context.getX(), context.getY(), width, height + 18);

    Shape rectShape = peService.createShape(containerShape, false);
    RoundedRectangle rect = gaService.createRoundedRectangle(rectShape, 5, 5);
       
    StyleUtil.applyBGStyle(rect, this);   

    gaService.setLocationAndSize(rect, 0, 0, width, height);
    decorateRect(rect);
    link(rectShape, subprocess);

    Rectangle box = gaService.createRectangle(rect);
    gaService.setLocationAndSize(box, 40, 80, 20, 20);
    box.setFilled(false);
    box.setForeground(manageColor(StyleUtil.CLASS_FOREGROUND));
    decorateBox(box);

    Shape textShape = peService.createShape(containerShape, false);
    MultiText text = gaService.createDefaultMultiText(getDiagram(), textShape, subprocess.getName());
    gaService.setLocationAndSize(text, 10, 10, 80, 80);
    text.setStyle(StyleUtil.getStyleForText(getDiagram()));
    text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
    text.setVerticalAlignment(Orientation.ALIGNMENT_TOP);
    text.getFont().setBold(true);
View Full Code Here

Examples of org.jbpm.ui.common.model.Subprocess

        }

        NodeList processStates = document.getElementsByTagName(PROCESS_STATE_NODE);
        for (int i = 0; i < processStates.getLength(); i++) {
            Node node = processStates.item(i);
            Subprocess subprocess = create(node, definition);
            List<VariableMapping> variablesList = new ArrayList<VariableMapping>();
            NodeList nodeList = node.getChildNodes();
            for (int j = 0; j < nodeList.getLength(); j++) {
                Node childNode = nodeList.item(j);
                if (SUB_PROCESS_NODE.equals(childNode.getNodeName())) {
                    subprocess.setSubProcessName(getAttribute(childNode, NAME_ATTR));
                }
                if (VARIABLE_NODE.equals(childNode.getNodeName())) {
                    VariableMapping variable = new VariableMapping();
                    variable.setProcessVariable(getAttribute(childNode, NAME_ATTR));
                    variable.setSubprocessVariable(getAttribute(childNode, MAPPED_NAME_ATTR));
                    variable.setUsage(getAttribute(childNode, ACCESS_ATTR));
                    variablesList.add(variable);
                }
            }
            subprocess.setVariablesList(variablesList);
        }

        NodeList multiInstanceStates = document.getElementsByTagName(MULTI_INSTANCE_STATE_NODE);
        for (int i = 0; i < multiInstanceStates.getLength(); i++) {
            Node node = multiInstanceStates.item(i);
View Full Code Here

Examples of org.jbpm.ui.common.model.Subprocess

import org.jbpm.ui.dialog.SubprocessDialog;

public class SubprocessDelegate extends BaseActionDelegate {

    public void run(IAction action) {
        Subprocess subprocess = (Subprocess) selectedPart.getModel();
        openDetails(subprocess);
    }
View Full Code Here

Examples of org.jbpm.ui.common.model.Subprocess

        }

        NodeList processStates = document.getElementsByTagName(PROCESS_STATE_NODE);
        for (int i = 0; i < processStates.getLength(); i++) {
            Node node = processStates.item(i);
            Subprocess subprocess = create(node, definition);
            List<VariableMapping> variablesList = new ArrayList<VariableMapping>();
            NodeList nodeList = node.getChildNodes();
            for (int j = 0; j < nodeList.getLength(); j++) {
                Node childNode = nodeList.item(j);
                if (SUB_PROCESS_NODE.equals(childNode.getNodeName())) {
                    subprocess.setSubProcessName(getAttribute(childNode, NAME_ATTR));
                }
                if (VARIABLE_NODE.equals(childNode.getNodeName())) {
                    VariableMapping variable = new VariableMapping();
                    variable.setProcessVariable(getAttribute(childNode, NAME_ATTR));
                    variable.setSubprocessVariable(getAttribute(childNode, MAPPED_NAME_ATTR));
                    variable.setUsage(getAttribute(childNode, ACCESS_ATTR));
                    variablesList.add(variable);
                }
            }
            subprocess.setVariablesList(variablesList);
        }
        NodeList endStates = document.getElementsByTagName(END_STATE_NODE);
        for (int i = 0; i < endStates.getLength(); i++) {
            Node node = endStates.item(i);
            create(node, definition);
View Full Code Here

Examples of org.jbpm.ui.common.model.Subprocess

        }
        if (node instanceof Active) {
            writeActions(document, nodeElement, (Active) node);
        }
        if (node instanceof Subprocess) {
            Subprocess subprocess = (Subprocess) node;
            Element subProcessElement = document.createElement(SUB_PROCESS_NODE);
            setAttribute(subProcessElement, NAME_ATTR, subprocess.getSubProcessName());
            nodeElement.appendChild(subProcessElement);
            for (VariableMapping variable : subprocess.getVariablesList()) {
                Element variableElement = document.createElement(VARIABLE_NODE);
                setAttribute(variableElement, NAME_ATTR, variable.getProcessVariable());
                setAttribute(variableElement, MAPPED_NAME_ATTR, variable.getSubprocessVariable());
                setAttribute(variableElement, ACCESS_ATTR, variable.getUsage());
                nodeElement.appendChild(variableElement);
View Full Code Here

Examples of sos.spooler.Subprocess

    /**
     * Create and execute subprocess
     */
    public Subprocess executeSubprocess(String command, String commandParameters, HashMap environment) throws Exception {
   
        Subprocess subprocess = null;
        boolean terminated = true;
       
        try {
            subprocess = spooler_task.create_subprocess();
           
            // execute subprocesses as a process group to have all child processes being killed if the timeout is exceeded 
            subprocess.set_own_process_group(true);
           
            subprocess.set_ignore_error(this.isIgnoreError());
            subprocess.set_ignore_signal(this.isIgnoreSignal());
            subprocess.set_priority_class(this.getPriorityClass());
            if (this.getTimeout() > 0) subprocess.set_timeout(this.getTimeout());

            // execute the command and parameters in background
            String commandLine = command + " " + commandParameters;
           
            // hand all order parameters that start with "env_" or "environment_" as environment variables to the subprocess
            String[] parameterNames = this.getParameters().names().split(";");
            for(int i=0; i<parameterNames.length; i++) {
                /*if (parameterNames[i].startsWith("env_")) {
                    subprocess.set_environment(parameterNames[i].substring(4).toUpperCase(), this.getParameters().value(parameterNames[i]));
                } else if (parameterNames[i].startsWith("environment_")) {
                    subprocess.set_environment(parameterNames[i].substring(12).toUpperCase(), this.getParameters().value(parameterNames[i]));
                }*/
                commandLine = myReplaceAll(commandLine,"\\$\\{" + parameterNames[i] + "\\}", this.getParameters().value(parameterNames[i]).replaceAll("[\\\\]", "\\\\\\\\"));
            }
            
 
            // set specific environment variables
            subprocess.set_environment("SCHEDULER_TRIGGER_FILE", this.getTriggerFilename());
           
            if (environment != null) {
               Iterator envIterator = environment.keySet().iterator();
                while(envIterator.hasNext()) {
                   Object envName  = envIterator.next();
                   Object envValue = environment.get(envName.toString());
                   commandLine = myReplaceAll(commandLine,"\\$\\{" + envName.toString() + "\\}", envValue.toString().replaceAll("[\\\\]", "\\\\\\\\"));
               }
            }
           
            // operating system environment variables
            if (this.envvars != null) {
              Iterator envIterator = this.envvars.keySet().iterator();
               while(envIterator.hasNext()) {
                  Object envName  = envIterator.next();
                  Object envValue = this.envvars.get(envName.toString());
                  commandLine = myReplaceAll(commandLine,"\\$\\{" + envName.toString() + "\\}", envValue.toString().replaceAll("[\\\\]", "\\\\\\\\"));
              }
           }
                      
            // adding environment variables from parameters with attribute env=yes
            if (this.additional_envvars != null) {
              Iterator envIterator = this.additional_envvars.keySet().iterator();
               while(envIterator.hasNext()) {
                  String envName  = (String) envIterator.next();
                  String envValue = (String) this.additional_envvars.get(envName);
                  if (envName == null) continue;
                  int varBegin = envValue.indexOf("${");
                  while (varBegin > -1) {
                      int varEnd = envValue.indexOf("}", varBegin+2);
                      if (varEnd > 0) {
                          String varName = envValue.substring(varBegin+2, varEnd);
                          boolean hasBasename = varName.startsWith("basename:");
                          if (hasBasename) varName = varName.substring(9);
                          if (this.getParameters().value(varName) != null) {
                              if (hasBasename) {
                                  envValue = myReplaceAll(envValue, "\\$\\{basename:" + varName + "\\}", new File(this.getParameters().value(varName)).getName().replaceAll("[\\\\]", "\\\\\\\\"));
                              } else {
                                  envValue = myReplaceAll(envValue, "\\$\\{" + varName + "\\}", this.getParameters().value(varName).replaceAll("[\\\\]", "\\\\\\\\"));
                              }
                              this.getLogger().debug9("environment variable substituted: " + varName);
                          } else {
                              this.getLogger().info("unsubstitutable variable found for environment: " + varName);
                          }
                      }
                      varBegin = envValue.indexOf("${", varEnd+1);
                  }
                  this.getLogger().debug1(".. setting environment variable: "  + envName + "=" + envValue);
                  subprocess.set_environment(envName, envValue);
              }
           }
           
           
            // execute the command
            this.getLogger().info("executing command: " + commandLine);
            subprocess.start(commandLine);

            // wait for the specified timeout for termination of the subprocess
            if (this.getTimeout() > 0) {
                terminated = subprocess.wait_for_termination(this.getTimeout());
            } else {
                subprocess.wait_for_termination();
            }
            if (!terminated){
                this.getLogger().warn("timeout reached for subprocess, process will be terminated");
                subprocess.kill();
                subprocess.wait_for_termination();
            } else {
            }
           
            boolean stdErrEmpty = true;
            String stdErrString = "";
            String stdOutString = "";

            this.getLogger().info("output reported to stdout for " + commandLine + ":");
            while(this.stdoutStream != null && this.stdoutStream.ready()) {
                String stdOutLine = stdoutStream.readLine();
                this.getLogger().info(stdOutLine);
                stdOutString += stdOutLine + "\n";
            }

            this.getLogger().info("output reported to stderr for " + commandLine + ":");
            while(this.stderrStream != null && this.stderrStream.ready()) {
                String stdErrLine = stderrStream.readLine();
                this.getLogger().info(stdErrLine);
                if (stdErrLine.trim().length()>0) stdErrEmpty = false;
                stdErrString += stdErrLine + "\n";
            }
            if (spooler_job.order_queue() != null){
                spooler_task.order().params().set_var("scheduler_order_stderr_output", stdErrString);
                spooler_task.order().params().set_var("scheduler_order_stdout_output", stdOutString);
                spooler_task.order().params().set_var("scheduler_order_exit_code", String.valueOf(subprocess.exit_code()));
                spooler_task.order().params().set_var("scheduler_order_terminated", (terminated ? "true" : "false"));
            }
           
            if((subprocess.exit_code() != 0)){
                if (this.isIgnoreError()) this.getLogger().info("command terminated with exit code: " + subprocess.exit_code());
                else throw new Exception("command terminated with exit code: " + subprocess.exit_code());                   
            }
            if((subprocess.termination_signal() != 0)){
                if (this.isIgnoreSignal()) this.getLogger().info("command terminated with signal: " + subprocess.termination_signal());
                else throw new Exception("command terminated with signal: " + subprocess.termination_signal());                 
            }
            if(!this.isIgnoreStderr() && !stdErrEmpty) {
                throw new Exception("command terminated with output to stderr:\n" + stdErrString);
            }
                       
View Full Code Here

Examples of sos.spooler.Subprocess

    public boolean spooler_process() {

        Order order = null;
        String orderId = "(none)";
        Subprocess subprocess = null;
       
        try {

            try {
       
                 this.setLogger(new SOSSchedulerLogger(spooler_log));
                if (spooler_job.order_queue() != null) {
                    order = spooler_task.order();
                    orderId = order.id();
               
                    if (order.params().value("configuration_path") != null && order.params().value("configuration_path").length() > 0) {
                        this.setConfigurationPath(order.params().value("configuration_path"));
                    } else if (spooler_task.params().value("configuration_path") != null && spooler_task.params().value("configuration_path").length() > 0) {
                        this.setConfigurationPath(spooler_task.params().value("configuration_path"));
                    }

                    if (order.params().value("configuration_file") != null && order.params().value("configuration_file").length() > 0) {
                        this.setConfigurationFilename(order.params().value("configuration_file"));
                    } else if (spooler_task.params().value("configuration_file") != null && spooler_task.params().value("configuration_file").length() > 0) {
                        this.setConfigurationFilename(spooler_task.params().value("configuration_file"));
                    }

                    // load and assign configuration
                    this.initConfiguration();
                }

                // prepare parameters and attributes
                this.prepare();

            } catch (Exception e) {
                throw new Exception("error occurred preparing order: " + e.getMessage());
            }
           

            try { // to process order
                if (this.getCommand() == null || this.getCommand().length() == 0)
                    throw new Exception("no command was specified to process order");
               
                subprocess = this.executeSubprocess();

            } catch (Exception e) {
                throw new Exception(e.getMessage());
            }
           
            return (spooler_task.job().order_queue() != null) ? true : false;
           
        } catch (Exception e) {
            spooler_log.warn("error occurred processing order [" + orderId + "]: " + e.getMessage());
            return false;
        } finally {
            try { this.cleanup(); } catch (Exception e) {};
            if (subprocess != null) try { subprocess.close(); } catch (Exception e) {}
        }
    }
View Full Code Here

Examples of sos.spooler.Subprocess

      String[] commands = command.split("\n");
      getLogger().debug6("Found " + commands.length + " commands.");
      // neu: mit subprocess

      for (int i = 0; i < commands.length && !timedOut; i++) {
        Subprocess subProc = spooler_task.create_subprocess();
        subProc.set_own_process_group(ownProcessGroup);
        subProc.set_ignore_error(ignoreError);
        subProc.set_ignore_signal(ignoreSignal);
        subProc.set_priority_class(priorityClass);
        try {
          setEnvironment(orderPayload, subProc);
        }
        catch (Exception e) {
          throw new Exception("Error occured setting environment variables: " + e);
        }
        // execute interpreter
        if (program != null && program.length() > 0) {
          subProc.start(program + " " + commands[i]);
          spooler_log.info("executing \"" + program + " " + commands[i] + "\"");
        }
        else {
          subProc.start(commands[i]);
          spooler_log.info("executing \"" + commands[i] + "\"");
        }
        if (orderPayload != null && orderPayload.var("timeout") != null && orderPayload.var("timeout").toString().length() > 0
            && !orderPayload.var("timeout").toString().equals("0")) {
          spooler_log.info("executable file is launched with process id " + subProc.pid() + " for timeout in "
              + orderPayload.var("timeout").toString() + "s");
          boolean terminated = subProc.wait_for_termination(Double.parseDouble(orderPayload.var("timeout").toString()));
          if (!terminated) {
            spooler_log.info("timeout reached, process will be terminated.");
            subProc.kill();
            subProc.wait_for_termination();
            timedOut = true;
          }

        }
        else {
          spooler_log.info("executable file is launched with process id " + subProc.pid());
          subProc.wait_for_termination();

        }
        if (!timedOut)
          spooler_log.info("file executed");
        spooler_log.debug9("Exit code: " + subProc.exit_code());

        boolean stdErrEmpty = true;
        String stdErrString = "";
        String stdOutString = "";
        spooler_log.info("std_out for " + commands[i] + ":");
        while (stdoutStream != null && stdoutStream.ready()) {
          String stdOutLine = stdoutStream.readLine();
          spooler_log.info(stdOutLine);
          stdOutString += stdOutLine + "\n";
        }
        spooler_log.info("std_err for " + commands[i] + ":");

        while (stderrStream != null && stderrStream.ready()) {
          String stdErrLine = stderrStream.readLine();
          spooler_log.info(stdErrLine);
          if (stdErrLine.trim().length() > 0)
            stdErrEmpty = false;
          stdErrString += stdErrLine + "\n";
        }
        if (orderJob && order != null) {
          Variable_set realOrderPayload = order.params();
          SetVar(realOrderPayload, conStd_err_output, stdErrString);
          SetVar(realOrderPayload, conStd_out_output, stdOutString);
          SetVar(realOrderPayload, conExit_code, "" + subProc.exit_code());
          SetVar(realOrderPayload, "timed_out", "" + timedOut);
          // for compatibility with SubProcessJob
          SetVar(realOrderPayload, "scheduler_order_terminated", (!timedOut ? "true" : "false"));
          replaceAliases(realOrderPayload, outputParameterAliases);
        } // additionally set task parameters for use with copy-from:
        Variable_set taskParams = spooler_task.params();
        SetVar(taskParams, conStd_err_output, stdErrString);
        SetVar(taskParams, conStd_out_output, stdOutString);
        SetVar(taskParams, conExit_code, "" + subProc.exit_code());
        SetVar(taskParams, "timed_out", "" + timedOut);
        replaceAliases(taskParams, outputParameterAliases);

        if (timedOut && !ignoreTimeout) {
          throw new Exception("Process had to be killed because of timeout");
        }
        if ((subProc.exit_code() != 0)) {
          if (ignoreError)
            spooler_log.info("Command terminated with exit code: " + subProc.exit_code());
          else
            throw new Exception("Command terminated with exit code: " + subProc.exit_code());
        }
        if ((subProc.termination_signal() != 0)) {
          if (ignoreSignal)
            spooler_log.info("Command terminated with signal: " + subProc.termination_signal());
          else
            throw new Exception("Command terminated with signal: " + subProc.termination_signal());
        }
        if (!ignoreStderr && !stdErrEmpty) {
          throw new Exception("Command terminated with text in stderr:\n" + stdErrString);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.