Search in sources :

Example 21 with MWorkflow

use of org.compiere.wf.MWorkflow 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 22 with MWorkflow

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

the class ASPGenerateFields method generateWorkflow.

private void generateWorkflow(int p_AD_Workflow_ID) {
    // Add Workflow and Nodes
    MWorkflow workflow = new MWorkflow(getCtx(), p_AD_Workflow_ID, get_TrxName());
    if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Workflow WHERE ASP_Level_ID = ? AND AD_Workflow_ID = ?", p_ASP_Level_ID, workflow.getAD_Workflow_ID()) < 1) {
        X_ASP_Workflow aspWorkflow = new X_ASP_Workflow(getCtx(), 0, get_TrxName());
        aspWorkflow.setASP_Level_ID(p_ASP_Level_ID);
        aspWorkflow.setAD_Workflow_ID(workflow.getAD_Workflow_ID());
        aspWorkflow.setASP_Status(p_ASP_Status);
        if (aspWorkflow.save())
            noWorkflows++;
    }
}
Also used : MWorkflow(org.compiere.wf.MWorkflow) X_ASP_Workflow(org.compiere.model.X_ASP_Workflow)

Example 23 with MWorkflow

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

the class MakeToOrderStandardBOMandWF method test01.

public void test01() throws Exception {
    Qty = new BigDecimal(10);
    //Define Product
    product = MProduct.get(getCtx(), M_Product_ID);
    //Define Business Partner
    BPartner = new MBPartner(getCtx(), C_BPartner_ID, trxName);
    //Setting the BOM
    int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(product);
    if (PP_Product_BOM_ID > 0)
        bom = new MPPProductBOM(getCtx(), PP_Product_BOM_ID, trxName);
    else
        throw new AdempiereException("@NotFound@ @PP_ProductBOM_ID@");
    if (bom != null) {
        bom.setValue(product.getValue());
        bom.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
        bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
        bom.saveEx();
    }
    //force Workflow as standard
    workflow = new MWorkflow(getCtx(), AD_Workflow_ID, trxName);
    workflow.setValue(product.getValue());
    workflow.saveEx();
    if (AD_Workflow_ID > 0)
        workflow = MWorkflow.get(getCtx(), AD_Workflow_ID);
    else
        throw new AdempiereException("@NotFound@ @AD_Workflow_ID@");
    /* Validate Exception if a Planning data is no defined
		MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Org_ID, M_Warehouse_ID , S_Resource_ID , M_Product_ID, trxName); 	
		pp.setS_Resource_ID(50000);
		pp.saveEx();*/
    createOrder();
    MPPOrder expected = createPPOrder();
    I_PP_Order actual = MPPOrder.forC_OrderLine_ID(getCtx(), oline.get_ID(), oline.getM_Product_ID(), trxName);
    if (actual == null) {
        throw new AdempiereException("@NotFound@ @PP_Order_ID@ not was generate");
    }
    assertEquals("Confirming Manufacturing Order", expected, actual);
}
Also used : I_PP_Order(org.eevolution.model.I_PP_Order) AdempiereException(org.adempiere.exceptions.AdempiereException) MWorkflow(org.compiere.wf.MWorkflow) MBPartner(org.compiere.model.MBPartner) MPPProductBOM(org.eevolution.model.MPPProductBOM) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Example 24 with MWorkflow

use of org.compiere.wf.MWorkflow 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 25 with MWorkflow

use of org.compiere.wf.MWorkflow 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)

Aggregations

MWorkflow (org.compiere.wf.MWorkflow)36 MWFNode (org.compiere.wf.MWFNode)18 BigDecimal (java.math.BigDecimal)9 ArrayList (java.util.ArrayList)8 MWFNodeNext (org.compiere.wf.MWFNodeNext)7 Query (org.compiere.model.Query)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 HttpSession (javax.servlet.http.HttpSession)4 AdempiereException (org.adempiere.exceptions.AdempiereException)4 BufferedImage (java.awt.image.BufferedImage)3 Properties (java.util.Properties)3 MProduct (org.compiere.model.MProduct)3 Trx (org.compiere.util.Trx)3 MPPProductPlanning (org.eevolution.model.MPPProductPlanning)3 Dimension (java.awt.Dimension)2 RoundingMode (java.math.RoundingMode)2 Arrays (java.util.Arrays)2 List (java.util.List)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 CostDimension (org.adempiere.engine.CostDimension)2