Search in sources :

Example 6 with MWFNodeNext

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

use of org.compiere.wf.MWFNodeNext 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 8 with MWFNodeNext

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

the class ImportWorkflow method createTransition.

/**
	 * Search custom AD_WF_NodeNext, if it does not exist, create it
	 * @param first node, second node
	 * @return custom AD_WF_NodeNext
	 */
private boolean createTransition(MWFNode source, MWFNode target) {
    if (source == null)
        return true;
    final String whereClause = MWFNodeNext.COLUMNNAME_AD_WF_Node_ID + "=?";
    MWFNodeNext transition = new Query(getCtx(), MWFNodeNext.Table_Name, whereClause, get_TrxName()).setClient_ID().setParameters(target.get_ID()).first();
    if (transition == null) {
        transition = new MWFNodeNext(getCtx(), 0, get_TrxName());
    }
    transition.setAD_WF_Node_ID(source.get_ID());
    transition.setAD_WF_Next_ID(target.get_ID());
    transition.setEntityType(source.getEntityType());
    transition.saveEx();
    return true;
}
Also used : Query(org.compiere.model.Query) MWFNodeNext(org.compiere.wf.MWFNodeNext)

Example 9 with MWFNodeNext

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

the class MTable method getworkFlowProcess.

/**
	 * Get / Create Process and Work Flow
	 * @return
	 */
private int getworkFlowProcess() {
    //	Search or create Work Flow
    MWorkflow workFlow = MWorkflow.getWorkFlowFromDocumentTable(getCtx(), getAD_Table_ID(), get_TrxName());
    //	validate null
    if (workFlow == null) {
        workFlow = new MWorkflow(getCtx(), 0, get_TrxName());
        workFlow.setValue("Process_" + getName());
        workFlow.setName(workFlow.getValue());
        workFlow.setDescription("(Standard Process_" + getName() + ")");
        workFlow.setWorkflowType(X_AD_Workflow.WORKFLOWTYPE_DocumentProcess);
        workFlow.setAD_Table_ID(getAD_Table_ID());
        workFlow.setAccessLevel(getAccessLevel());
        workFlow.setEntityType(getEntityType());
        workFlow.setPublishStatus(X_AD_Workflow.PUBLISHSTATUS_Test);
        workFlow.setAuthor("ADempiere");
        workFlow.setDuration(1);
        workFlow.saveEx();
        //	Create Work Flow Node for (Start)
        MWFNode wfNode_Start = new MWFNode(workFlow, "(Start)", "(Start)");
        wfNode_Start.setDescription(workFlow.getName());
        wfNode_Start.setEntityType(getEntityType());
        wfNode_Start.setJoinElement(X_AD_WF_Node.JOINELEMENT_XOR);
        wfNode_Start.setSplitElement(X_AD_WF_Node.SPLITELEMENT_XOR);
        wfNode_Start.setAction(X_AD_WF_Node.ACTION_WaitSleep);
        wfNode_Start.saveEx();
        //	Set Start node in Workflow
        workFlow.setAD_WF_Node_ID(wfNode_Start.getAD_WF_Node_ID());
        workFlow.saveEx();
        //	Create Work Flow Node for (DocAuto)
        MWFNode wfNode_Auto = new MWFNode(workFlow, "(DocAuto)", "(DocAuto)");
        wfNode_Auto.setDescription(workFlow.getName());
        wfNode_Auto.setEntityType(getEntityType());
        wfNode_Auto.setJoinElement(X_AD_WF_Node.JOINELEMENT_XOR);
        wfNode_Auto.setSplitElement(X_AD_WF_Node.SPLITELEMENT_XOR);
        wfNode_Auto.setAction(X_AD_WF_Node.ACTION_DocumentAction);
        wfNode_Auto.setDocAction(X_AD_WF_Node.DOCACTION_None);
        wfNode_Auto.saveEx();
        //	Create Work Flow Node for (DocPrepare)
        MWFNode wfNode_Prepare = new MWFNode(workFlow, "(DocPrepare)", "(DocPrepare)");
        wfNode_Prepare.setDescription(workFlow.getName());
        wfNode_Prepare.setEntityType(getEntityType());
        wfNode_Prepare.setJoinElement(X_AD_WF_Node.JOINELEMENT_XOR);
        wfNode_Prepare.setSplitElement(X_AD_WF_Node.SPLITELEMENT_XOR);
        wfNode_Prepare.setAction(X_AD_WF_Node.ACTION_DocumentAction);
        wfNode_Prepare.setDocAction(X_AD_WF_Node.DOCACTION_Prepare);
        wfNode_Prepare.saveEx();
        //	Create Work Flow Node for (DocComplete)
        MWFNode wfNode_Complete = new MWFNode(workFlow, "(DocComplete)", "(DocComplete)");
        wfNode_Complete.setDescription(workFlow.getName());
        wfNode_Complete.setEntityType(getEntityType());
        wfNode_Complete.setJoinElement(X_AD_WF_Node.JOINELEMENT_XOR);
        wfNode_Complete.setSplitElement(X_AD_WF_Node.SPLITELEMENT_XOR);
        wfNode_Complete.setAction(X_AD_WF_Node.ACTION_DocumentAction);
        wfNode_Complete.setDocAction(X_AD_WF_Node.DOCACTION_Complete);
        wfNode_Complete.saveEx();
        //	Create Transition For Start Node
        //	For Start
        MWFNodeNext wfNodeNext = new MWFNodeNext(wfNode_Start, wfNode_Prepare.getAD_WF_Node_ID());
        wfNodeNext.setDescription("(Standard Approval)");
        wfNodeNext.setEntityType(getEntityType());
        wfNodeNext.setSeqNo(10);
        wfNodeNext.setIsStdUserWorkflow(true);
        wfNodeNext.saveEx();
        //	For DocAuto
        wfNodeNext = new MWFNodeNext(wfNode_Start, wfNode_Auto.getAD_WF_Node_ID());
        wfNodeNext.setDescription("(Standard Transition)");
        wfNodeNext.setEntityType(getEntityType());
        wfNodeNext.setSeqNo(100);
        wfNodeNext.setIsStdUserWorkflow(false);
        wfNodeNext.saveEx();
        //	Create Transition For Prepare Node
        //	For DocComplete
        wfNodeNext = new MWFNodeNext(wfNode_Prepare, wfNode_Complete.getAD_WF_Node_ID());
        wfNodeNext.setDescription("(Standard Transition)");
        wfNodeNext.setEntityType(getEntityType());
        wfNodeNext.setSeqNo(100);
        wfNodeNext.setIsStdUserWorkflow(false);
        wfNodeNext.saveEx();
    }
    //	Create Standard Process for Document Action
    int m_AD_Process_ID = MProcess.getProcess_ID(getTableName() + "_Process", get_TrxName());
    if (m_AD_Process_ID <= 0) {
        MProcess workFlowProcess = new MProcess(getCtx(), 0, get_TrxName());
        workFlowProcess.setValue(getTableName() + "_Process");
        workFlowProcess.setName("Process " + getName());
        workFlowProcess.setEntityType(getEntityType());
        workFlowProcess.setAccessLevel(getAccessLevel());
        workFlowProcess.setAD_Workflow_ID(workFlow.getAD_Workflow_ID());
        workFlowProcess.saveEx();
        //	Default Return
        return workFlowProcess.getAD_Process_ID();
    }
    //	Default Return
    return m_AD_Process_ID;
}
Also used : MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) MWFNodeNext(org.compiere.wf.MWFNodeNext)

Example 10 with MWFNodeNext

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

the class WFEditor 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 : MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) Dimension(java.awt.Dimension) 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)

Aggregations

MWFNodeNext (org.compiere.wf.MWFNodeNext)10 MWFNode (org.compiere.wf.MWFNode)8 MWorkflow (org.compiere.wf.MWorkflow)7 BufferedImage (java.awt.image.BufferedImage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 WFLine (org.compiere.apps.wf.WFLine)3 AImage (org.zkoss.image.AImage)3 Dimension (java.awt.Dimension)2 Point (java.awt.Point)2 Query (org.compiere.model.Query)2 Rectangle (java.awt.Rectangle)1 JPopupMenu (javax.swing.JPopupMenu)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)1 WFNode (org.adempiere.webui.apps.wf.WFNode)1 WFNodeContainer (org.adempiere.webui.apps.wf.WFNodeContainer)1 ApplicationException (org.adempiere.webui.exception.ApplicationException)1 MProduct (org.compiere.model.MProduct)1 MWFProcess (org.compiere.wf.MWFProcess)1 MWorkflowProcessor (org.compiere.wf.MWorkflowProcessor)1