All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ow2.bonita.facade.runtime.command.WebExecuteTask Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (C) 2010  BonitaSoft S.A.
 * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
 * This library 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
 * version 2.1 of the License.
 * This library 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
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA  02110-1301, USA.
 **/
package org.ow2.bonita.facade.runtime.command;

import java.lang.reflect.Constructor;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.ow2.bonita.env.Environment;
import org.ow2.bonita.facade.runtime.InitialAttachment;
import org.ow2.bonita.facade.uuid.ActivityInstanceUUID;
import org.ow2.bonita.util.Command;

/***
 * This command starts a task sets the variables and attachments, executes the Groovy scripts and terminate the task
 * 
 * @author Anthony Birembaut, Matthieu Chaffotte, Nicolas Chabanoles, Elias Ricken de Medeiros
 */
public class WebExecuteTask implements Command {

  private static final long serialVersionUID = -183964674754241232L;
  
  protected ActivityInstanceUUID taskUUID;
  protected Map processVariables;
  protected Map activityVariables;
  protected Map undefinedVariables;
  protected Set attachments;
  protected List scriptsToExecute;
  protected Map scriptContext;
  
  public WebExecuteTask(final ActivityInstanceUUID taskUUID, final Map processVariables,
      final Map activityVariables, final Map undefinedVariables, final Set attachments, 
      final List scriptsToExecute, final Map scriptContext) {
    super();
    this.taskUUID = taskUUID;
    this.processVariables = processVariables;
    this.activityVariables = activityVariables;
    this.undefinedVariables = undefinedVariables;
    this.attachments = attachments;
    this.scriptsToExecute = scriptsToExecute;
    this.scriptContext = scriptContext;
  }
  
 

  @Override
  public Void execute(final Environment environment) throws Exception {
    final Class commandClass = Class.forName("org.ow2.bonita.facade.runtime.command.ServerWebExecuteTask");
    @SuppressWarnings("unchecked")
    final Constructor> commandConstructor = (Constructor>) commandClass.getConstructor(ActivityInstanceUUID.class, Map.class, Map.class, Map.class, Set.class, List.class, Map.class);
    final Command command = commandConstructor.newInstance(taskUUID, processVariables, activityVariables, undefinedVariables, attachments, scriptsToExecute, scriptContext);
    command.execute(environment);
    return null;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy