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();
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);
}
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();
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);
}
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));
}
use of org.compiere.wf.MWorkflow in project adempiere by adempiere.
the class ImportWorkflow method importRecords.
/**
* import records from I_Workflow to AD_Workflow table
*/
public void importRecords() {
List<X_I_Workflow> iworkflows = getRecords(false, m_IsImportOnlyNoErrors);
for (X_I_Workflow importWorkflow : iworkflows) {
MWFNode node = null;
MWorkflow workflow = getWorkflow(importWorkflow);
if (workflow != null) {
node = getWorkflowNode(importWorkflow, workflow);
}
if (node != null) {
if (workflow.getAD_WF_Node_ID() <= 0) {
workflow.setAD_WF_Node_ID(node.get_ID());
workflow.saveEx();
}
importWorkflow.setAD_WF_Node_ID(node.get_ID());
importWorkflow.setAD_Workflow_ID(workflow.get_ID());
imported++;
}
importWorkflow.setI_IsImported(true);
importWorkflow.setProcessed(true);
importWorkflow.saveEx();
}
// create the transition
for (X_I_Workflow importWorkflow : iworkflows) {
MWFNode node = (MWFNode) importWorkflow.getAD_WF_Node();
if (node != null) {
int node_id = getID(MWFNode.Table_Name, "AD_Workflow_ID= ? AND Value=?", new Object[] { importWorkflow.getAD_Workflow_ID(), importWorkflow.getNodeNextValue() });
if (node_id > 0) {
MWFNode next = new MWFNode(getCtx(), node_id, get_TrxName());
createTransition(node, next);
}
}
}
}
use of org.compiere.wf.MWorkflow in project adempiere by adempiere.
the class ImportWorkflow method getWorkflow.
/**
* Search custom AD_Workflow, if it does not exist, create it
* @param iWf
* @return custom AD_Workflow
*/
public MWorkflow getWorkflow(X_I_Workflow iWf) {
MWorkflow workflow = new Query(getCtx(), MWorkflow.Table_Name, "Value=? AND Name=?", get_TrxName()).setClient_ID().setParameters(iWf.getValue(), iWf.getName()).firstOnly();
if (workflow == null) {
workflow = new MWorkflow(getCtx(), 0, get_TrxName());
workflow.setValue(iWf.getValue());
workflow.setName(iWf.getName());
}
workflow.setIsBetaFunctionality(iWf.isBetaFunctionality());
workflow.setWorkflowType(iWf.getWorkflowType());
workflow.setAccessLevel(iWf.getAccessLevel());
workflow.setValidFrom(iWf.getValidFrom());
workflow.setValidTo(iWf.getValidTo());
workflow.setPublishStatus(iWf.getPublishStatus());
workflow.setVersion(iWf.getVersion());
workflow.setAuthor(iWf.getAuthor());
workflow.setIsDefault(iWf.isDefault());
workflow.setAD_WorkflowProcessor_ID(iWf.getAD_WorkflowProcessor_ID());
workflow.setDurationUnit(iWf.getDurationUnit());
workflow.setAD_Table_ID(iWf.getAD_Table_ID());
workflow.setDocValueLogic(iWf.getDocValueLogic());
workflow.setEntityType(iWf.getEntityType());
// Workflow Manufacturing
workflow.setProcessType(iWf.getProcessType());
workflow.setS_Resource_ID(iWf.getS_Resource_ID());
workflow.setDocumentNo(iWf.getDocumentNo());
workflow.setMovingTime(iWf.getMovingTime());
workflow.setUnitsCycles(iWf.getUnitsCycles());
workflow.setQtyBatchSize(iWf.getQtyBatchSize());
// workflow.setOverlapUnits(iWf.getOverlapUnits());
workflow.setQueuingTime(iWf.getQueuingTime());
workflow.setSetupTime(iWf.getSetupTime());
workflow.setYield(iWf.getYield());
workflow.saveEx();
return workflow;
}
Aggregations