Search in sources :

Example 36 with MWorkflow

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

the class PackInHandler method endElement.

/**
     *	Receive notification of the end of an element.
     * 	@param uri namespace
     * 	@param localName simple name
     * 	@param qName qualified name
     * 	@throws SAXException
     */
public void endElement(String uri, String localName, String qName) throws SAXException {
    // Check namespace.
    String elementValue = null;
    if ("".equals(uri))
        elementValue = qName;
    else
        elementValue = uri + localName;
    if (elementValue.equals("adempiereAD")) {
        processDeferElements();
        processMenuElements();
        if (!PK_Status.equals("Completed with errors"))
            PK_Status = "Completed successfully";
        //Update package history log with package status
        StringBuffer sqlB = new StringBuffer("UPDATE AD_Package_Imp " + "SET PK_Status = '" + PK_Status + "' WHERE AD_Package_Imp_ID = " + AD_Package_Imp_ID);
        int no = DB.executeUpdate(sqlB.toString(), m_trxName);
        if (no == -1)
            log.info("Update to package summary failed");
        //Update package list with package status		
        sqlB = new StringBuffer("UPDATE AD_Package_Imp_Inst " + "SET PK_Status = '" + PK_Status + "' WHERE AD_Package_Imp_Inst_ID = " + AD_Package_Imp_Inst_ID);
        no = DB.executeUpdate(sqlB.toString(), m_trxName);
        if (no == -1)
            log.info("Update to package list failed");
        if (workflow.size() > 0) {
            for (Element e : workflow) {
                Attributes atts = e.attributes;
                String workflowName = atts.getValue("Name");
                MWorkflow wf = null;
                int workflow_id = IDFinder.get_IDWithColumn("AD_Workflow", "Name", workflowName, m_AD_Client_ID, m_trxName);
                if (workflow_id > 0) {
                    wf = new MWorkflow(m_ctx, workflow_id, m_trxName);
                    int node_id = 0;
                    String name = atts.getValue("ADWorkflowNodeNameID");
                    if (name != null && name.trim().length() > 0) {
                        MWFNode[] nodes = wf.getNodes(false, m_AD_Client_ID);
                        for (MWFNode node : nodes) {
                            if (node.getName().trim().equals(name.trim())) {
                                node_id = node.getAD_WF_Node_ID();
                                wf.setAD_WF_Node_ID(node_id);
                                if (!wf.save())
                                    System.out.println("Can not save Start Node " + name + "to Workflow " + workflowName + " do not exist ");
                                break;
                            }
                        }
                        if (node_id == 0)
                            System.out.println("Unresolved: Start Node to Workflow " + workflowName + " do not exist ");
                        else
                            break;
                    }
                }
            }
        }
        if (nodes.size() > 0) {
            for (Element e : nodes) {
                Attributes atts = e.attributes;
                String nodeName = atts.getValue("Name");
                MWFNode node = null;
                int id = IDFinder.get_IDWithColumn("AD_WF_Node", "Name", nodeName, m_AD_Client_ID, false, m_trxName);
                if (id > 0) {
                    node = new MWFNode(m_ctx, id, m_trxName);
                    String workflowNodeName = atts.getValue("WorkflowNameID").trim();
                    if (workflowNodeName != null && workflowNodeName.trim().length() > 0) {
                        int workflow_id = IDFinder.get_IDWithColumn("AD_Workflow", "Name", workflowNodeName, m_AD_Client_ID, m_trxName);
                        if (workflow_id > 0) {
                            node.setWorkflow_ID(workflow_id);
                            if (!node.save()) {
                                System.out.println("can not save Workflow " + workflowNodeName);
                            }
                        } else
                            System.out.println("Unresolved: Workflow " + workflowNodeName + " do not exist ");
                    }
                }
            }
        }
        logDocument.endElement("", "", "adempiereDocument");
        logDocument.endDocument();
        try {
            fw_document.close();
        } catch (Exception e) {
        }
        //reset
        setupHandlers();
    } else {
        Element e = stack.pop();
        if (e.defer) {
            defer.add(new DeferEntry(e, false));
        } else {
            ElementHandler handler = handlers.get(elementValue);
            if (handler != null)
                handler.endElement(m_ctx, e);
            if (e.defer || e.deferEnd)
                defer.add(new DeferEntry(e, false));
            else if (!e.skip) {
                if (log.isLoggable(Level.INFO))
                    log.info("Processed: " + e.getElementValue() + " - " + e.attributes.getValue(0));
            }
        }
    }
}
Also used : MWorkflow(org.compiere.wf.MWorkflow) Attributes(org.xml.sax.Attributes) MWFNode(org.compiere.wf.MWFNode) ProcessElementHandler(org.adempiere.pipo.handler.ProcessElementHandler) UserRoleElementHandler(org.adempiere.pipo.handler.UserRoleElementHandler) PrintFormatItemElementHandler(org.adempiere.pipo.handler.PrintFormatItemElementHandler) WindowElementHandler(org.adempiere.pipo.handler.WindowElementHandler) RoleElementHandler(org.adempiere.pipo.handler.RoleElementHandler) FormElementHandler(org.adempiere.pipo.handler.FormElementHandler) TabElementHandler(org.adempiere.pipo.handler.TabElementHandler) FieldElementHandler(org.adempiere.pipo.handler.FieldElementHandler) ModelValidatorElementHandler(org.adempiere.pipo.handler.ModelValidatorElementHandler) ReportViewColElementHandler(org.adempiere.pipo.handler.ReportViewColElementHandler) ViewColumnElementHandler(org.adempiere.pipo.handler.ViewColumnElementHandler) DataElementHandler(org.adempiere.pipo.handler.DataElementHandler) PreferenceElementHandler(org.adempiere.pipo.handler.PreferenceElementHandler) ReportViewElementHandler(org.adempiere.pipo.handler.ReportViewElementHandler) WorkflowNodeNextElementHandler(org.adempiere.pipo.handler.WorkflowNodeNextElementHandler) ViewDefinitionElementHandler(org.adempiere.pipo.handler.ViewDefinitionElementHandler) DistFileElementHandler(org.adempiere.pipo.handler.DistFileElementHandler) ImpFormatRowElementHandler(org.adempiere.pipo.handler.ImpFormatRowElementHandler) EntityTypeElementHandler(org.adempiere.pipo.handler.EntityTypeElementHandler) MenuElementHandler(org.adempiere.pipo.handler.MenuElementHandler) WorkflowElementHandler(org.adempiere.pipo.handler.WorkflowElementHandler) WorkflowNodeElementHandler(org.adempiere.pipo.handler.WorkflowNodeElementHandler) WindowAccessElementHandler(org.adempiere.pipo.handler.WindowAccessElementHandler) ImpFormatElementHandler(org.adempiere.pipo.handler.ImpFormatElementHandler) ReferenceTableElementHandler(org.adempiere.pipo.handler.ReferenceTableElementHandler) ReferenceListElementHandler(org.adempiere.pipo.handler.ReferenceListElementHandler) AdElementHandler(org.adempiere.pipo.handler.AdElementHandler) PrintFormatElementHandler(org.adempiere.pipo.handler.PrintFormatElementHandler) TaskAccessElementHandler(org.adempiere.pipo.handler.TaskAccessElementHandler) ViewElementHandler(org.adempiere.pipo.handler.ViewElementHandler) ProcessAccessElementHandler(org.adempiere.pipo.handler.ProcessAccessElementHandler) BrowseFieldElementHandler(org.adempiere.pipo.handler.BrowseFieldElementHandler) TableElementHandler(org.adempiere.pipo.handler.TableElementHandler) MessageElementHandler(org.adempiere.pipo.handler.MessageElementHandler) OrgRoleElementHandler(org.adempiere.pipo.handler.OrgRoleElementHandler) FormAccessElementHandler(org.adempiere.pipo.handler.FormAccessElementHandler) SQLStatementElementHandler(org.adempiere.pipo.handler.SQLStatementElementHandler) WorkflowAccessElementHandler(org.adempiere.pipo.handler.WorkflowAccessElementHandler) ColumnElementHandler(org.adempiere.pipo.handler.ColumnElementHandler) DynValRuleElementHandler(org.adempiere.pipo.handler.DynValRuleElementHandler) TaskElementHandler(org.adempiere.pipo.handler.TaskElementHandler) PrintPaperElementHandler(org.adempiere.pipo.handler.PrintPaperElementHandler) ReferenceElementHandler(org.adempiere.pipo.handler.ReferenceElementHandler) BrowseElementHandler(org.adempiere.pipo.handler.BrowseElementHandler) WorkflowNodeNextConditionElementHandler(org.adempiere.pipo.handler.WorkflowNodeNextConditionElementHandler) FieldGroupElementHandler(org.adempiere.pipo.handler.FieldGroupElementHandler) CodeSnipitElementHandler(org.adempiere.pipo.handler.CodeSnipitElementHandler) ProcessParaElementHandler(org.adempiere.pipo.handler.ProcessParaElementHandler) FileNotFoundException(java.io.FileNotFoundException) SAXException(org.xml.sax.SAXException) SQLException(java.sql.SQLException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException)

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