Java tutorial
/** * PureInfo Quake * @(#)Workflow.java 1.0 Oct 13, 2005 * * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. * All rights reserved, see the license file. * * www.pureinfo.com.cn */ package com.pureinfo.srm.config.workflow.model; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.dom4j.Element; import com.pureinfo.force.exception.PureException; import com.pureinfo.force.xml.IXMLSupporter; import com.pureinfo.force.xml.XMLUtil; import com.pureinfo.srm.config.workflow.WorkflowHelper; /** * <P> * Created on Oct 13, 2005 11:08:39 PM <BR> * Last modified on Oct 13, 2005 * </P> * * @author Freeman.Hu * @version 1.0, Oct 13, 2005 * @since Quake 1.0 */ public class WfProcess implements IXMLSupporter { public static final String ELEMENT_ACTIVITY = "activity"; public static final String ATTRIBUTE_NAME = "name"; public static final String ATTRIBUTE_TYPE = "type"; private Map /* WfActivity */ m_actities; private String m_sName; private String m_sType; public WfProcess() { } public WfProcess(String _sName) { m_sName = _sName; m_actities = new LinkedHashMap(); } public Map /* WfActivity */ getActivities() { return m_actities; } public void setActities(Map /* WfActivity */ actities) { m_actities = actities; } public String getName() { return m_sName; } /** * @see com.pureinfo.force.xml.IXMLSupporter#toXMLElement(org.dom4j.Element) */ public void toXMLElement(Element _element) throws PureException { _element.addAttribute(ATTRIBUTE_NAME, m_sName); _element.addAttribute(ATTRIBUTE_TYPE, m_sType); for (Iterator iter = m_actities.keySet().iterator(); iter.hasNext();) { WfActivity act = (WfActivity) m_actities.get(iter.next()); Element actEle = _element.addElement(ELEMENT_ACTIVITY); act.toXMLElement(actEle); } } /** * @see com.pureinfo.force.xml.IXMLSupporter#fromXML(org.dom4j.Element) */ public void fromXML(Element _element) throws PureException { m_sName = XMLUtil.getRequiredAttributeValue(_element, ATTRIBUTE_NAME); m_sType = XMLUtil.getRequiredAttributeValue(_element, ATTRIBUTE_TYPE); List actEles = _element.elements(ELEMENT_ACTIVITY); m_actities = new LinkedHashMap(); for (Iterator iter = actEles.iterator(); iter.hasNext();) { Element actEle = (Element) iter.next(); WfActivity act = new WfActivity(); act.fromXML(actEle); m_actities.put(act.getName(), act); } } public String getType() { return m_sType; } public void setType(String type) { m_sType = type; } public void setName(String name) { m_sName = name; } public String getActivitiesStringWithRoles(List _roles, String _default) throws PureException { String sActString = _default; for (Iterator iter3 = m_actities.keySet().iterator(); iter3.hasNext();) { String sActName = (String) iter3.next(); WfActivity act = (WfActivity) m_actities.get(sActName); if (act.check(_roles)) { sActName = WorkflowHelper.getActivityName(sActName); sActString = sActString.equals(_default) ? sActName : sActString + "," + sActName; } } return sActString; } }