Search in sources :

Example 16 with MWFNode

use of org.compiere.wf.MWFNode in project adempiere by adempiere.

the class WWorkflow method doPost.

//  doGet
/**
	 *  Process the HTTP Post request - Initial Call.
	 *
	 *  Execute the received command
	 *  Update session attributes
	 *  Create output
	 *
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //WUtil.debug(new String("In do Post"),"");
    HttpSession sess = request.getSession();
    WebSessionCtx wsc = WebSessionCtx.get(request);
    Properties ctx = wsc.ctx;
    if (ctx == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //String loginInfo = (String)sess.getAttribute(WEnv.SA_LOGININFO);
    //get session attributes
    MWorkflow wf = (MWorkflow) sess.getAttribute(WORKFLOW);
    MWFNode[] nodes = (MWFNode[]) sess.getAttribute(NODES);
    ArrayList nodes_ID = (ArrayList) sess.getAttribute(NODES_ID);
    int[][] imageMap = (int[][]) sess.getAttribute(IMAGE_MAP);
    int activeNode = ((Integer) sess.getAttribute(ACTIVE_NODE)).intValue();
    //execute commnad
    String m_command = request.getParameter(M_Command);
    int j_command = WebUtil.getParameterAsInt(request, J_Command);
    //WUtil.debug(m_command,"m_command");
    //WUtil.debug(""+j_command,"j_command");
    executeCommand(m_command, j_command, wf, activeNode, nodes, nodes_ID, sess);
    //get updated session attributes
    wf = (MWorkflow) sess.getAttribute(WORKFLOW);
    nodes = (MWFNode[]) sess.getAttribute(NODES);
    nodes_ID = (ArrayList) sess.getAttribute(NODES_ID);
    imageMap = (int[][]) sess.getAttribute(IMAGE_MAP);
    activeNode = ((Integer) sess.getAttribute(ACTIVE_NODE)).intValue();
    //create layout
    WebDoc doc = preparePage("loginInfo");
    doc = createLayout(doc, wf, activeNode, nodes, nodes_ID, imageMap);
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebDoc(org.compiere.util.WebDoc) MWorkflow(org.compiere.wf.MWorkflow) ArrayList(java.util.ArrayList) MWFNode(org.compiere.wf.MWFNode) WebSessionCtx(org.compiere.util.WebSessionCtx) Properties(java.util.Properties)

Example 17 with MWFNode

use of org.compiere.wf.MWFNode in project adempiere by adempiere.

the class WWFPanelManufacturing method load.

private void load(int workflowId) {
    //	Get Workflow
    MWorkflow wf = new MWorkflow(Env.getCtx(), workflowId, null);
    WFNodeContainer nodeContainer = new WFNodeContainer();
    nodeContainer.setWorkflow(wf);
    //	Add Nodes for Paint
    MWFNode[] nodes = wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
    for (int i = 0; i < nodes.length; i++) {
        WFNode wfn = new WFNode(nodes[i]);
        nodeContainer.add(wfn);
        //	Add Lines
        MWFNodeNext[] nexts = nodes[i].getTransitions(Env.getAD_Client_ID(Env.getCtx()));
        for (int j = 0; j < nexts.length; j++) nodeContainer.add(new WFLine(nexts[j]));
    }
    Dimension dimension = nodeContainer.getDimension();
    BufferedImage bi = new BufferedImage(dimension.width + 2, dimension.height + 2, BufferedImage.TYPE_INT_ARGB);
    nodeContainer.paint(bi.createGraphics());
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        ImageIO.write(bi, "png", os);
        AImage imageContent = new AImage("workflow.png", os.toByteArray());
        imageMap.setWidth(dimension.width + "px");
        imageMap.setHeight(dimension.height + "px");
        imageMap.setContent(imageContent);
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
}
Also used : WFNode(org.adempiere.webui.apps.wf.WFNode) MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MWFNodeNext(org.compiere.wf.MWFNodeNext) BufferedImage(java.awt.image.BufferedImage) WFLine(org.compiere.apps.wf.WFLine) AImage(org.zkoss.image.AImage) WFNodeContainer(org.adempiere.webui.apps.wf.WFNodeContainer)

Example 18 with MWFNode

use of org.compiere.wf.MWFNode in project adempiere by adempiere.

the class WorkflowTest method testQuery.

public void testQuery() throws Exception {
    //
    // Check MWFActivity
    int AD_Table_ID = MRequisition.Table_ID;
    // dummy;
    int Record_ID = 1;
    MWFActivity.get(getCtx(), AD_Table_ID, Record_ID, false);
    MWFActivity.get(getCtx(), AD_Table_ID, Record_ID, true);
    //
    // Check MWFEventAudit
    // dummy
    int AD_WF_Process_ID = 1;
    // dummy
    int AD_WF_Node_ID = 1;
    MWFEventAudit.get(getCtx(), AD_WF_Process_ID, AD_WF_Node_ID, getTrxName());
    MWFEventAudit.get(getCtx(), AD_WF_Process_ID, getTrxName());
    //
    // Check MWFProcess 
    MWFProcess proc = new Query(getCtx(), MWFProcess.Table_Name, null, getTrxName()).setClient_ID().setOrderBy(MWFProcess.COLUMNNAME_AD_WF_Process_ID).first();
    if (proc != null) {
        proc.getActivities(true, false, getTrxName());
        proc.getActivities(true, true, getTrxName());
    } else {
    // TODO: check MWFProcess - need better test
    }
    //
    // Check MWorkflow, MWFNode, MWFNodeNext etc
    int AD_Client_ID = getAD_Client_ID();
    // Process_Requisition
    int AD_Workflow_ID = 115;
    MWorkflow wf = MWorkflow.get(getCtx(), AD_Workflow_ID);
    for (MWFNode node : wf.getNodes(false, AD_Client_ID)) {
        MWFNodePara.getParameters(node.getCtx(), node.getAD_WF_Node_ID());
        for (MWFNodeNext next : node.getTransitions(AD_Client_ID)) {
            next.getConditions(true);
            next.getConditions(false);
        }
    }
    // Check MWorkflowProcessor
    for (MWorkflowProcessor processor : MWorkflowProcessor.getActive(getCtx())) {
        processor.getLogs();
    }
//
//
}
Also used : MWFProcess(org.compiere.wf.MWFProcess) Query(org.compiere.model.Query) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) MWFNodeNext(org.compiere.wf.MWFNodeNext) MWorkflowProcessor(org.compiere.wf.MWorkflowProcessor)

Example 19 with MWFNode

use of org.compiere.wf.MWFNode in project adempiere by adempiere.

the class WWorkflow method doPost.

//  doGet
/**
	 *  Process the HTTP Post request - Initial Call.
	 *
	 *  Execute the received command
	 *  Update session attributes
	 *  Create output
	 *
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //WUtil.debug(new String("In do Post"),"");
    HttpSession sess = request.getSession();
    MobileSessionCtx wsc = MobileSessionCtx.get(request);
    Properties ctx = wsc.ctx;
    if (ctx == null) {
        MobileUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //String loginInfo = (String)sess.getAttribute(WEnv.SA_LOGININFO);
    //get session attributes
    MWorkflow wf = (MWorkflow) sess.getAttribute(WORKFLOW);
    MWFNode[] nodes = (MWFNode[]) sess.getAttribute(NODES);
    ArrayList nodes_ID = (ArrayList) sess.getAttribute(NODES_ID);
    int[][] imageMap = (int[][]) sess.getAttribute(IMAGE_MAP);
    int activeNode = ((Integer) sess.getAttribute(ACTIVE_NODE)).intValue();
    //execute commnad
    String m_command = request.getParameter(M_Command);
    int j_command = MobileUtil.getParameterAsInt(request, J_Command);
    //WUtil.debug(m_command,"m_command");
    //WUtil.debug(""+j_command,"j_command");
    executeCommand(m_command, j_command, wf, activeNode, nodes, nodes_ID, sess);
    //get updated session attributes
    wf = (MWorkflow) sess.getAttribute(WORKFLOW);
    nodes = (MWFNode[]) sess.getAttribute(NODES);
    nodes_ID = (ArrayList) sess.getAttribute(NODES_ID);
    imageMap = (int[][]) sess.getAttribute(IMAGE_MAP);
    activeNode = ((Integer) sess.getAttribute(ACTIVE_NODE)).intValue();
    //create layout
    MobileDoc doc = preparePage("loginInfo");
    doc = createLayout(doc, wf, activeNode, nodes, nodes_ID, imageMap);
    MobileUtil.createResponse(request, response, this, null, doc, false);
}
Also used : HttpSession(javax.servlet.http.HttpSession) MWorkflow(org.compiere.wf.MWorkflow) ArrayList(java.util.ArrayList) MWFNode(org.compiere.wf.MWFNode) Properties(java.util.Properties)

Example 20 with MWFNode

use of org.compiere.wf.MWFNode in project adempiere by adempiere.

the class WWorkflow method doGet.

//  init
/**
	 *  Process the HTTP Get request - Initial Call.
	 *  <br>
	 *  http://localhost/adempiere/WWorkflow?AD_Menu_ID=123
	 *  <br>
	 *
	 *  Find the AD_Workflow_ID
	 *  Load workflow and initial session atribute
	 *  Create output
	 *
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //Log.trace(Log.l1_User, "WWorkflow.doGet");
    //WUtil.debug(new String("In do get"),"");
    //  Get Session attributes
    HttpSession sess = request.getSession();
    MobileSessionCtx wsc = MobileSessionCtx.get(request);
    ctx = wsc.ctx;
    //String loginInfo = (String)sess.getAttribute(WebEnv.SA_LOGININFO);
    if (ctx == null) {
        MobileUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Get Parameter: Menu_ID
    int AD_Menu_ID = MobileUtil.getParameterAsInt(request, "AD_Menu_ID");
    //  Get Parameter: Menu_ID
    int AD_Window_ID = MobileUtil.getParameterAsInt(request, "AD_Window_ID");
    //set language
    AD_Language = Env.getAD_Language(ctx);
    //load AD_Workflow_ID
    int AD_Workflow_ID = getAD_Workflow_ID(AD_Menu_ID);
    //load workflow
    loadWorkflow(ctx, AD_Workflow_ID, sess);
    //get session attributes
    MWorkflow wf = (MWorkflow) sess.getAttribute(WORKFLOW);
    MWFNode[] nodes = (MWFNode[]) sess.getAttribute(NODES);
    ArrayList nodes_ID = (ArrayList) sess.getAttribute(NODES_ID);
    int[][] imageMap = (int[][]) sess.getAttribute(IMAGE_MAP);
    int activeNode = ((Integer) sess.getAttribute(ACTIVE_NODE)).intValue();
    //create output
    MobileDoc doc = preparePage("loginInfo");
    doc = createLayout(doc, wf, activeNode, nodes, nodes_ID, imageMap);
    MobileUtil.createResponse(request, response, this, null, doc, false);
}
Also used : HttpSession(javax.servlet.http.HttpSession) MWorkflow(org.compiere.wf.MWorkflow) ArrayList(java.util.ArrayList) MWFNode(org.compiere.wf.MWFNode)

Aggregations

MWFNode (org.compiere.wf.MWFNode)29 MWorkflow (org.compiere.wf.MWorkflow)17 MWFNodeNext (org.compiere.wf.MWFNodeNext)8 ArrayList (java.util.ArrayList)7 Point (java.awt.Point)4 HttpSession (javax.servlet.http.HttpSession)4 BufferedImage (java.awt.image.BufferedImage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 Properties (java.util.Properties)3 WFLine (org.compiere.apps.wf.WFLine)3 Trx (org.compiere.util.Trx)3 ValueNamePair (org.compiere.util.ValueNamePair)3 Dimension (java.awt.Dimension)2 BigDecimal (java.math.BigDecimal)2 SQLException (java.sql.SQLException)2 MProduct (org.compiere.model.MProduct)2 Query (org.compiere.model.Query)2 WebDoc (org.compiere.util.WebDoc)2 WebSessionCtx (org.compiere.util.WebSessionCtx)2 AImage (org.zkoss.image.AImage)2