Search in sources :

Example 16 with MWorkflow

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

the class MPPOrder method updateQtyBatchs.

/**
	 * Set QtyBatchSize and QtyBatchs using Workflow and QtyEntered
	 * @param ctx context
	 * @param order MO
	 * @param override if false, will set QtyBatchSize even if is already set (QtyBatchSize!=0)
	 */
public static void updateQtyBatchs(Properties ctx, I_PP_Order order, boolean override) {
    BigDecimal qtyBatchSize = order.getQtyBatchSize();
    if (qtyBatchSize.signum() == 0 || override) {
        int AD_Workflow_ID = order.getAD_Workflow_ID();
        // No workflow entered, or is just a new record:
        if (AD_Workflow_ID <= 0)
            return;
        MWorkflow wf = MWorkflow.get(ctx, AD_Workflow_ID);
        qtyBatchSize = wf.getQtyBatchSize().setScale(0, RoundingMode.UP);
        order.setQtyBatchSize(qtyBatchSize);
    }
    BigDecimal QtyBatchs;
    if (qtyBatchSize.signum() == 0)
        QtyBatchs = Env.ONE;
    else
        QtyBatchs = order.getQtyOrdered().divide(qtyBatchSize, 0, BigDecimal.ROUND_UP);
    order.setQtyBatchs(QtyBatchs);
}
Also used : MWorkflow(org.compiere.wf.MWorkflow) BigDecimal(java.math.BigDecimal)

Example 17 with MWorkflow

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

the class WFPanel method load.

//	dispose
/**
	 * 	Load Workflow & Nodes
	 * 	@param AD_Workflow_ID ID
	 */
public void load(int AD_Workflow_ID) {
    log.fine("AD_Workflow_ID=" + AD_Workflow_ID);
    if (AD_Workflow_ID == 0)
        return;
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    //	Get Workflow
    m_wf = new MWorkflow(Env.getCtx(), AD_Workflow_ID, null);
    nodeContainer.removeAll();
    nodeContainer.setWorkflow(m_wf);
    //	Add Nodes for Paint
    MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID);
    for (int i = 0; i < nodes.length; i++) {
        WFNode wfn = new WFNode(nodes[i]);
        nodeContainer.add(wfn);
        //	Add Lines
        MWFNodeNext[] nexts = nodes[i].getTransitions(AD_Client_ID);
        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 image = new Imagemap();
        image.setWidth(dimension.width + "px");
        image.setHeight(dimension.height + "px");
        image.setContent(imageContent);
        contentPanel.appendChild(image);
        image.addEventListener(Events.ON_CLICK, this);
        for (WFNode node : nodeContainer.getNodes()) {
            Area area = new Area();
            Rectangle rect = node.getBounds();
            area.setCoords(rect.x + "," + rect.y + "," + (rect.x + rect.width) + "," + (rect.y + rect.height));
            image.appendChild(area);
            area.setId("WFN_" + node.getAD_WF_Node_ID());
            StringBuffer tooltip = new StringBuffer();
            String s = node.getNode().getDescription(true);
            if (s != null && s.trim().length() > 0)
                tooltip.append(s);
            String h = node.getNode().getHelp(true);
            if (h != null && h.trim().length() > 0) {
                if (tooltip.length() > 0)
                    tooltip.append(". ");
                tooltip.append(h);
            }
            area.setTooltiptext(tooltip.toString());
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    //	Info Text
    StringBuffer msg = new StringBuffer("");
    msg.append("<H2>").append(m_wf.getName(true)).append("</H2>");
    String s = m_wf.getDescription(true);
    if (s != null && s.length() > 0)
        msg.append("<B>").append(s).append("</B>");
    s = m_wf.getHelp(true);
    if (s != null && s.length() > 0)
        msg.append("<BR>").append(s);
    infoTextPane.setContent(msg.toString());
}
Also used : MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) Rectangle(java.awt.Rectangle) MWFNode(org.compiere.wf.MWFNode) Dimension(java.awt.Dimension) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MWFNodeNext(org.compiere.wf.MWFNodeNext) BufferedImage(java.awt.image.BufferedImage) ApplicationException(org.adempiere.webui.exception.ApplicationException) Area(org.zkoss.zul.Area) WFLine(org.compiere.apps.wf.WFLine) AImage(org.zkoss.image.AImage) Imagemap(org.zkoss.zul.Imagemap)

Example 18 with MWorkflow

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

the class DefaultRoutingServiceImplTest method assertCalculateDuration.

/**
	 * @see RoutingService#calculateDuration(I_AD_WF_Node) 
	 */
protected void assertCalculateDuration(final double expectedDuration, int qtyBatchSize, int setupTime, int duration, int unitsCycles, int overlapUnits) {
    MWorkflow wf = createWorkflow(qtyBatchSize);
    I_AD_WF_Node node = createNode(wf, "10", setupTime, duration, unitsCycles, overlapUnits);
    BigDecimal actualDuration = routingService.calculateDuration(node);
    assertEquals(expectedDuration, actualDuration.doubleValue());
}
Also used : I_AD_WF_Node(org.compiere.model.I_AD_WF_Node) MWorkflow(org.compiere.wf.MWorkflow) BigDecimal(java.math.BigDecimal)

Example 19 with MWorkflow

use of org.compiere.wf.MWorkflow 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();
    WebSessionCtx wsc = WebSessionCtx.get(request);
    ctx = wsc.ctx;
    //String loginInfo = (String)sess.getAttribute(WebEnv.SA_LOGININFO);
    if (ctx == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Get Parameter: Menu_ID
    int AD_Menu_ID = WebUtil.getParameterAsInt(request, "AD_Menu_ID");
    //  Get Parameter: Menu_ID
    int AD_Window_ID = WebUtil.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
    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)

Example 20 with MWorkflow

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

the class WWorkflow method loadWorkflow.

//createLayout
/**
	 *  Load workflw and initialize the session attributes.
	 *
	 *
	 *  @param ctx
 	 *  @param AD_Workflow_ID
	 *  @param sess
	 *
	 */
private void loadWorkflow(Properties ctx, int AD_Workflow_ID, HttpSession sess) {
    MWorkflow wf = new MWorkflow(ctx, AD_Workflow_ID, null);
    //get the MWFNode in order
    MWFNode[] nodes = wf.getNodes(true, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    MWFNode wfn = null;
    ArrayList nodes_ID = new ArrayList();
    for (int i = 0; i < nodes.length; i++) {
        wfn = nodes[i];
        nodes_ID.add(new Integer(wfn.getAD_WF_Node_ID()));
    }
    //for
    int[][] imageMap = generateImageMap(nodes_ID);
    //printMap(imageMap);
    //set session attribtes
    sess.setAttribute(WORKFLOW, wf);
    sess.setAttribute(NODES, nodes);
    sess.setAttribute(NODES_ID, nodes_ID);
    sess.setAttribute(IMAGE_MAP, imageMap);
    sess.setAttribute(ACTIVE_NODE, new Integer(-999));
}
Also used : MWorkflow(org.compiere.wf.MWorkflow) ArrayList(java.util.ArrayList) MWFNode(org.compiere.wf.MWFNode)

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