ActivityUniqueKey.java :  » Workflow-Engines » wfmopen-2.1.1 » de » danet » an » workflow » api » Java Open Source

Java Open Source » Workflow Engines » wfmopen 2.1.1 
wfmopen 2.1.1 » de » danet » an » workflow » api » ActivityUniqueKey.java
/*
 * This file is part of the WfMOpen project.
 * Copyright (C) 2001-2003 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
 *
 * $Id: ActivityUniqueKey.java,v 1.2 2006/09/29 12:32:07 drmlipp Exp $
 *
 * $Log: ActivityUniqueKey.java,v $
 * Revision 1.2  2006/09/29 12:32:07  drmlipp
 * Consistently using WfMOpen as projct name now.
 *
 * Revision 1.1.1.1  2003/06/30 20:05:13  drmlipp
 * Initial import
 *
 * Revision 1.6  2003/06/27 08:51:46  lipp
 * Fixed copyright/license information.
 *
 * Revision 1.5  2002/11/26 11:23:30  lipp
 * Modified RemoteException comment.
 *
 * Revision 1.4  2002/10/02 10:58:13  lipp
 * Modifications for tool invocation.
 *
 * Revision 1.3  2002/07/05 20:35:12  lipp
 * Redefined ActivityUniqueKey constructor parameter sequence.
 *
 * Revision 1.2  2002/06/26 21:45:43  lipp
 * Added equals and hash.
 *
 * Revision 1.1  2002/06/15 19:02:02  lipp
 * New utility type.
 *
 */
package de.danet.an.workflow.api;

import java.io.Serializable;

import java.rmi.RemoteException;

import de.danet.an.workflow.omgcore.WfActivity;
import de.danet.an.workflow.omgcore.WfProcess;

/**
 * This class implements a unique activity key. The OMG interface defines
 * the key returned by the
 * {@link de.danet.an.workflow.omgcore.WfExecutionObject#key
 * <code>key()</code>} method as unique within the scope of the containing 
 * process only. The key of a process in turn is unique only among the 
 * processes with a common process manager.<P>
 *
 * This class therefore combines the activity key, the process key and
 * the process manager name to a unique activity key.
 *
 * @author <a href="mailto:mnl@mnl.de">Michael N. Lipp</a>
 * @version $Revision: 1.2 $
 */

public class ActivityUniqueKey implements Serializable {

    private String mgrName;
    private String procKey;
    private String actKey;
    
    /**
     * Creates an instance of <code>ActivityUniqueKey</code>
     * for the given activity.
     *
     * @param activity the <code>WfActivity</code>.
     * @throws RemoteException if a system-level error occurs.
     */
    public ActivityUniqueKey (WfActivity activity) 
  throws RemoteException {
  actKey = activity.key();
  WfProcess proc = activity.container();
  procKey = proc.key();
  String mgrName = proc.manager().name();
    }

    /**
     * Creates an instance of <code>ActivityUniqueKey</code>
     * from the given partial keys.
     *
     * @param managerName the process manager name.
     * @param processKey the process key.
     * @param activityKey the activity key.
     */
    public ActivityUniqueKey (String managerName, String processKey, 
            String activityKey) {
  if (activityKey == null || processKey == null
      || managerName == null) {
      throw new IllegalArgumentException ();
  }
  mgrName = managerName;
  procKey = processKey;
  actKey = activityKey;
    }

    /**
     * Two <code>ActivityUniqueKey</code>s are equal, if all
     * attributes are equal.
     *
     * @param other a <code>ActivityUniqueKey</code> value
     * @return <code>true</code> if objects are equal.
     */
    public boolean equals(Object other) {
  ActivityUniqueKey o = (ActivityUniqueKey)other;
  return actKey.equals (o.actKey)
      && procKey.equals (o.procKey)
      && mgrName.equals (o.mgrName);
    }

    /**
     * Calculate a hash code for a <code>ActivityUniqueKey</code>
     * object.
     *
     * @return the hash code.
     */
    public int hashCode() {
  return actKey.hashCode() ^ procKey.hashCode() ^ mgrName.hashCode();
    }
    
    /**
     * Return the activity key.
     *
     * @return the activity key.
     */
    public String activityKey () {
  return actKey;
    }

    /**
     * Return the process key.
     *
     * @return the process key.
     */
    public String processKey () {
  return procKey;
    }

    /**
     * Return the process manager name.
     *
     * @return the process manager name.
     */
    public String managerName () {
  return mgrName;
    }

    /**
     * Generate a string representation for debugging purposes.
     * @return a string representation.
     */
    public String toString () {
  return "Activity[" + mgrName + "/" + procKey + "/" + actKey + "]";
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.