Package org.jbpm.client.impl

Source Code of org.jbpm.client.impl.PvmServiceImpl

/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jbpm.client.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jbpm.PvmService;
import org.jbpm.client.CommandService;
import org.jbpm.client.Deploy;
import org.jbpm.client.FindExecution;
import org.jbpm.client.FindLatestProcessDefinition;
import org.jbpm.client.FindProcessDefinition;
import org.jbpm.client.FindProcessDefinitionNames;
import org.jbpm.client.FindProcessDefinitions;
import org.jbpm.client.GetJobs;
import org.jbpm.client.GetVariables;
import org.jbpm.client.GetVariable;
import org.jbpm.client.SetVariables;
import org.jbpm.client.Signal;
import org.jbpm.client.StartExecution;
import org.jbpm.env.session.Job;
import org.jbpm.env.session.Message;
import org.jbpm.env.session.Timer;
import org.jbpm.pvm.Execution;
import org.jbpm.pvm.ProcessDefinition;

/**
* @author Tom Baeyens
*/
public class PvmServiceImpl implements PvmService {

  CommandService commandService;

  public PvmServiceImpl(CommandService commandService) {
    this.commandService = commandService;
  }

  public void deploy(ProcessDefinition processDefinition) {
    commandService.execute(new Deploy(processDefinition));
  }

  public ProcessDefinition findLatestProcessDefinition(String processDefinitionName) {
    return (ProcessDefinition) commandService.execute(new FindLatestProcessDefinition(processDefinitionName));
  }

  public ProcessDefinition findProcessDefinition(String processDefinitionName, int version) {
    return (ProcessDefinition) commandService.execute(new FindProcessDefinition(processDefinitionName, version));
  }

  public List<String> findProcessDefinitionNames() {
    return (List) commandService.execute(new FindProcessDefinitionNames());
  }

  public List<ProcessDefinition> findProcessDefinitions(String processDefinitionName) {
    return (List) commandService.execute(new FindProcessDefinitions(processDefinitionName));
  }

  public ProcessDefinition findProcessDefinition(long processDefinitionDbid) {
    return (ProcessDefinition) commandService.execute(new FindProcessDefinition(processDefinitionDbid));
  }

  public Execution startExecution(String processDefinitionName) {
    return startExecution(processDefinitionName, null, null);
  }
 
  public Execution startExecution(long processDefinitionDbid){
    return startExecution(processDefinitionDbid, null, null);
  }
 
  public Execution startExecution(String processDefinitionName, Map<String, Object> executionVariables){
    return startExecution(processDefinitionName, executionVariables, null);
  }
 
  public Execution startExecution(long processDefinitionDbid, Map<String, Object> executionVariables){
    return startExecution(processDefinitionDbid, executionVariables, null);
  }

  public Execution startExecution(String processDefinitionName, Map<String, Object> executionVariables, String executionKey){
    StartExecution startExecution = new StartExecution(processDefinitionName);
    startExecution.setVariables(executionVariables);
    startExecution.setKey(executionKey);
    return (Execution) commandService.execute(startExecution);
  }
 
  public Execution startExecution(long processDefinitionDbid, Map<String, Object> executionVariables, String executionKey){
    StartExecution startExecution = new StartExecution(processDefinitionDbid);
    startExecution.setVariables(executionVariables);
    startExecution.setKey(executionKey);
    return (Execution) commandService.execute(startExecution);
  }

  public Execution signal(long executionDbid) {
    return (Execution) commandService.execute(new Signal(executionDbid));
  }

  public Execution signal(long executionDbid, String signalName) {
    return (Execution) commandService.execute(new Signal(executionDbid, signalName));
  }

  public Execution signal(long executionDbid, String signalName, Map<String, Object> parameters) {
    return (Execution) commandService.execute(new Signal(executionDbid, signalName, parameters));
  }

  public Execution findExecution(long executionDbid) {
    return (Execution) commandService.execute(new FindExecution(executionDbid));
  }

  public Execution findExecution(String processDefinitionName, String key) {
    return (Execution) commandService.execute(new FindExecution(processDefinitionName, key));
  }

  public Object getVariable(long executionDbid, String variableName) {
    return commandService.execute(new GetVariable(executionDbid, variableName));
  }

  public Map<String, Object> getVariables(long executionDbid, List<String> variableNames) {
    return (Map) commandService.execute(new GetVariables(executionDbid, variableNames));
  }

  public Execution setVariable(long executionDbid, String name, Object value) {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(name, value);
    return setVariables(executionDbid, variables);
  }

  public Execution setVariables(long executionDbid, Map<String, Object> variables) {
    return (Execution) commandService.execute(new SetVariables(executionDbid, variables));
  }

  public List<Job> getJobs() {
    return (List) commandService.execute(new GetJobs());
  }
}
TOP

Related Classes of org.jbpm.client.impl.PvmServiceImpl

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.