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);
}
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());
}
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());
}
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);
}
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));
}
Aggregations