droflosession.java

来自「OpenWFE是一个开放源码的Java工作流引擎。它是一个完整的业务处理管理套件」· Java 代码 · 共 582 行 · 第 1/2 页

JAVA
582
字号
/* * Copyright (c) 2005, John Mettraux, OpenWFE.org * All rights reserved. *  * Redistribution and use in source and binary forms, with or without  * modification, are permitted provided that the following conditions are met: *  * . Redistributions of source code must retain the above copyright notice, this *   list of conditions and the following disclaimer.   *  * . Redistributions in binary form must reproduce the above copyright notice,  *   this list of conditions and the following disclaimer in the documentation  *   and/or other materials provided with the distribution. *  * . Neither the name of the "OpenWFE" nor the names of its contributors may be *   used to endorse or promote products derived from this software without *   specific prior written permission. *  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  * POSSIBILITY OF SUCH DAMAGE. * * $Id: DrofloSession.java 2432 2006-03-15 10:27:54Z jmettraux $ *///// DrofloSession.java//// jmettraux@openwfe.org//// generated with // jtmpl 1.1.00 16.08.2003 John Mettraux (jmettraux@openwfe.org)//package openwfe.org.droflo;import java.io.PrintWriter;import javax.servlet.ServletContext;import javax.servlet.http.HttpSession;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import openwfe.org.ApplicationContext;import openwfe.org.misc.WebUtils;import openwfe.org.engine.Definitions;import openwfe.org.engine.launch.Launcher;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.expressions.BuildException;import openwfe.org.engine.expressions.FlowExpression;import openwfe.org.engine.expressions.FlowExpressionId;import openwfe.org.engine.expressions.ProcessDefinition;import openwfe.org.engine.expressions.CompositeFlowExpression;import openwfe.org.engine.expressions.map.ExpressionMap;/** * A kind of flow definition... * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Id: DrofloSession.java 2432 2006-03-15 10:27:54Z jmettraux $ </font> * * @author jmettraux@openwfe.org */public class DrofloSession{    //    // CONSTANTS & co    public final static String DROFLO_SESSION         = "drofloSession";    public final static String IN_EDIT_MODE        = "droflo.inEditMode";    public final static String APPLICATION_CONFIGURATION        = "applicationConfiguration";    private final static int UNDO_LEVELS = 10;    //    // FIELDS    private ServletContext servletContext = null;    private ApplicationContext applicationContext = null;    private ProcessDefinition flowDefinition = null;    private String webappUrl = null;    private Throwable exception = null;    private boolean inEditMode = false;    private boolean minorVisible = false;    private boolean helpVisible = true;    private boolean editInXml = false;    private FlowExpression expressionToEdit = null;    private java.util.List undoStack =         new java.util.ArrayList(UNDO_LEVELS);    private InFlowWorkItem workitem = null;    //    // CONSTRUCTORS    public DrofloSession         (final String webappUrl,         final ServletContext servletContext,         final ApplicationContext applicationContext,          final boolean inEditMode)    {        this.webappUrl = webappUrl;        this.servletContext = servletContext;        this.applicationContext = applicationContext;        this.inEditMode = inEditMode;        log("DrofloSession() this.inEditMode = "+this.inEditMode);    }    //    // METHODS    private void log (final String message)    {        this.servletContext.log(message);    }    private void log (final String message, final Throwable t)    {        this.servletContext.log(message, t);    }    public String getWebappUrl ()    {        return this.webappUrl;    }    public InFlowWorkItem getWorkItem ()    {        return this.workitem;    }    public boolean isInEditMode ()     {         return             //this.inEditMode && (this.expressionToEdit == null);             this.inEditMode;    }    public void setInEditMode (final boolean b)    {        this.inEditMode = b;    }    public boolean isHelpVisible ()    {        return this.helpVisible;    }    public void toggleHelp ()    {        this.helpVisible = ! this.helpVisible;    }    public boolean isMinorVisible ()    {        return this.minorVisible;    }    public void toggleMinor ()    {        this.minorVisible = ! this.minorVisible;    }    public Launcher getLauncher ()    {        return Definitions.getLauncher(getApplicationContext());    }    public boolean getEditInXml ()    {        return this.editInXml;    }    public void setEditInXml (final boolean b)    {        this.editInXml = b;    }    /**     * loads a worfklow in the session     */    public void loadWorkflow (final String flowDefinitionUrl)        throws BuildException    {        log("loadWorkflow() url : "+flowDefinitionUrl);        this.flowDefinition = getLauncher()            .loadProcessDefinition(flowDefinitionUrl);    }    /**     * removes an expression from the current flow definition     */    public void removeExpression (final String expId)    {        final FlowExpressionId id = this.flowDefinition            .getFlowExpressionId(expId);        this.flowDefinition.removeChild(id);    }    private FlowExpressionId buildExpressionId (String expId, String expName)    {        if (expId == null || expName == null) return null;        FlowExpressionId model = this.flowDefinition.getId();        FlowExpressionId result = (FlowExpressionId)model.clone();        result.setExpressionId(expId);        result.setExpressionName(expName);        return result;    }    public void addExpression        (final String expressionName,          final String expId,         final String sPosition)     throws        BuildException    {        log("addExpression() expressionName is >"+expressionName+"<");        log("addExpression() expId is >"+expId+"<");        log("addExpression() position is >"+sPosition+"<");        final FlowExpression exp =             this.flowDefinition.getExpression(expId);        FlowExpressionId id = null;        if (exp != null) id = exp.getId();        int position = -1;        if (sPosition != null)            position = Integer.parseInt(sPosition);        this.flowDefinition.add(expressionName, id, position);    }    public void moveExpression (final String action, final String expId)    {        log("moveExpression() action is >"+action+"<  expId is >"+expId+"<");        final FlowExpression fe = this.flowDefinition.getExpression(expId);        final CompositeFlowExpression cfe =             (CompositeFlowExpression)this.flowDefinition.get(fe.getParent());        // should directly work as the 'moveX' button is only presented        // in a sequence or something like this                if (action.equals("moveup"))        {            cfe.moveUpChild(fe.getId());        }        else        {            cfe.moveDownChild(fe.getId());        }    }    public void newFlowDefinition ()    {        try        {            this.flowDefinition = new ProcessDefinition                (getApplicationContext(),                 "http://localhost:7079/__new_flow__1.0.xml",

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?