Package de.danet.an.workflow.tools.scarab

Source Code of de.danet.an.workflow.tools.scarab.GetDependencyCopiedFrom

/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2004 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* The initial version of this code has been contributed by Init AG
* (http://www.init-ka.de).
*
* $Id: GetDependencyCopiedFrom.java 1607 2006-09-29 12:32:13Z drmlipp $
*
* $Log$
* Revision 1.1  2004/09/15 20:10:12  mlipp
* Started adding Scarab interface.
*
*/
package de.danet.an.workflow.tools.scarab;

import java.io.Serializable;

import java.util.Map;
import java.util.Vector;

import java.rmi.RemoteException;

import de.danet.an.workflow.omgcore.ProcessData;

import de.danet.an.workflow.api.Activity;
import de.danet.an.workflow.api.DefaultProcessData;
import de.danet.an.workflow.api.FormalParameter;

import de.danet.an.workflow.spis.aii.ApplicationNotStoppedException;
import de.danet.an.workflow.spis.aii.CannotExecuteException;
import de.danet.an.workflow.spis.aii.ResultProvider;
import de.danet.an.workflow.spis.aii.ToolAgent;

/**
* This class provides a tool that gets issue id(as a result), if
* issue has any dependency (duplicated or blocked issues). If issue
* has no dependency result returns null.
*
* @author lgrischancew@init-ka.de
* @author <a href="mailto:lipp@danet.de"></a>
* @created on 22.03.2004
* @version $Revision: 1607 $
*/
public class GetDependencyCopiedFrom
    implements ToolAgent, ResultProvider, Serializable {

    private static final org.apache.commons.logging.Log logger
  = org.apache.commons.logging.LogFactory
  .getLog(GetDependencyCopiedFrom.class);

    private String serverUrl = "http://localhost:12345";

    /** The result container. */
    private ThreadLocal result = new ThreadLocal ();

    /**
     * Set the server URL. Defaults to
     * <code>http://localhost:12345</code>.
     *
     * @param serverUrl the server URL
     */
    public void setServerUrl(String serverUrl) {
  this.serverUrl = serverUrl;
    }
       
    public void invoke(Activity activity, FormalParameter[] formPars, Map map)
  throws CannotExecuteException ,RemoteException {

  try {
      String issueId = (String)map.get(formPars[0].id());
      String dependTypeName = (String)map.get(formPars[1].id());
      String resId = null;
      for (int i = 0; i < formPars.length; i++) {
    if (formPars[i].mode() != FormalParameter.Mode.IN) {
        resId = formPars[i].id();
        continue;
    }
      }

      ProcessData data = new DefaultProcessData();
      Vector w  = (Vector)
    (XmlRpcCall.rpc
     (serverUrl, "scm.getDependencyCopiedFrom", new Object[]
         { issueId,dependTypeName
         } ));
      if (w.size() > 0) {
    for(int i = 0; i<w.size();i++){
        data.put(resId,w.elementAt(i));
    }
      } else {
    data.put(resId, null)
      }
      result.set (data);
  } finally {
      if (logger.isDebugEnabled()) {
    logger.debug ("Finished invocation of " + activity.uniqueKey());
      }
  }
    }

    /**
     * Return the result evaluated during {@link ToolAgent#invoke
     * <code>invoke</code>}. The method will only be called once after
     * each invoke, i.e. the attribute holding the result be be
     * cleared in this method.
     *
     * @return the result data or <code>null</code> if the invocation
     * does not return any data.
     */
    public Object result () {
  Map res = (Map)result.get();
  result.set (null);
  return res;
    }

    public void terminate(Activity activity)
  throws ApplicationNotStoppedException {
  throw new ApplicationNotStoppedException
      ("Terminate not implemented");
    }
}
TOP

Related Classes of de.danet.an.workflow.tools.scarab.GetDependencyCopiedFrom

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.