Search in sources :

Example 11 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class ProcessElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Process_ID = Env.getContextAsInt(ctx, "AD_Process_ID");
    if (processes.contains(AD_Process_ID))
        return;
    processes.add(AD_Process_ID);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    String sqlW = "SELECT AD_Process_ID FROM AD_PROCESS WHERE AD_PROCESS_ID = " + AD_Process_ID;
    AttributesImpl atts = new AttributesImpl();
    PreparedStatement pstmt1 = null;
    pstmt1 = DB.prepareStatement(sqlW, getTrxName(ctx));
    try {
        ResultSet rs1 = pstmt1.executeQuery();
        while (rs1.next()) {
            X_AD_Process m_Process = new X_AD_Process(ctx, rs1.getInt("AD_Process_ID"), null);
            log.log(Level.INFO, "AD_ReportView_ID: " + m_Process.getAD_Process_ID());
            if (m_Process.isReport() && m_Process.getAD_ReportView_ID() > 0) {
                packOut.createReportview(m_Process.getAD_ReportView_ID(), document);
            }
            if (m_Process.isReport() && m_Process.getAD_PrintFormat_ID() > 0) {
                packOut.createPrintFormat(m_Process.getAD_PrintFormat_ID(), document);
            }
            if (m_Process.getAD_Workflow_ID() > 0) {
                packOut.createWorkflow(m_Process.getAD_Workflow_ID(), document);
            }
            if (m_Process.getAD_Form_ID() > 0) {
                packOut.createForm(m_Process.getAD_Form_ID(), document);
            }
            if (m_Process.getAD_Browse_ID() > 0) {
                packOut.createBrowse(m_Process.getAD_Browse_ID(), document);
            }
            createProcessBinding(atts, m_Process);
            document.startElement("", "", "process", atts);
            // processpara tags
            String sqlP = "SELECT * FROM AD_PROCESS_PARA WHERE AD_PROCESS_ID = " + AD_Process_ID + " ORDER BY " + X_AD_Process_Para.COLUMNNAME_SeqNo + "," + X_AD_Process_Para.COLUMNNAME_AD_Process_Para_ID;
            PreparedStatement pstmtP = null;
            pstmtP = DB.prepareStatement(sqlP, getTrxName(ctx));
            try {
                ResultSet rsP = pstmtP.executeQuery();
                while (rsP.next()) {
                    if (rsP.getInt("AD_Reference_ID") > 0)
                        packOut.createReference(rsP.getInt("AD_Reference_ID"), document);
                    if (rsP.getInt("AD_Reference_Value_ID") > 0)
                        packOut.createReference(rsP.getInt("AD_Reference_Value_ID"), document);
                    if (rsP.getInt("AD_Val_Rule_ID") > 0)
                        packOut.createDynamicRuleValidation(rsP.getInt("AD_Val_Rule_ID"), document);
                    createProcessPara(ctx, document, rsP.getInt("AD_Process_Para_ID"));
                }
                rsP.close();
                pstmtP.close();
                pstmtP = null;
            } catch (Exception e) {
                log.log(Level.SEVERE, "getProcess_Para", e);
                if (e instanceof SAXException)
                    throw (SAXException) e;
                else if (e instanceof SQLException)
                    throw new DatabaseAccessException("Failed to export process.", e);
                else if (e instanceof RuntimeException)
                    throw (RuntimeException) e;
                else
                    throw new RuntimeException("Failed to export process.", e);
            } finally {
                try {
                    if (pstmtP != null)
                        pstmtP.close();
                } catch (Exception e) {
                }
                pstmtP = null;
            }
            document.endElement("", "", "process");
        }
        rs1.close();
        pstmt1.close();
        pstmt1 = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "getProcess", e);
    } finally {
        try {
            if (pstmt1 != null)
                pstmt1.close();
        } catch (Exception e) {
        }
        pstmt1 = null;
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) X_AD_Process(org.compiere.model.X_AD_Process) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SQLException(java.sql.SQLException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException)

Example 12 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class AdElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int adElement_id = Env.getContextAsInt(ctx, X_AD_Element.COLUMNNAME_AD_Element_ID);
    if (processedElements.contains(adElement_id))
        return;
    processedElements.add(adElement_id);
    X_AD_Element m_AdElement = new X_AD_Element(ctx, adElement_id, null);
    AttributesImpl atts = new AttributesImpl();
    createAdElementBinding(atts, m_AdElement);
    document.startElement("", "", "element", atts);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    packOut.createTranslations(X_AD_Element.Table_Name, m_AdElement.get_ID(), document);
    document.endElement("", "", "element");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) PackOut(org.adempiere.pipo.PackOut) X_AD_Element(org.compiere.model.X_AD_Element)

Example 13 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class PrintFormatElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_PrintFormat_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_PrintFormat_ID);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    if (formats.contains(AD_PrintFormat_ID))
        return;
    formats.add(AD_PrintFormat_ID);
    AttributesImpl atts = new AttributesImpl();
    String sql = null;
    sql = "SELECT AD_PrintFormat_ID " + "FROM AD_PrintFormat " + "WHERE (AD_PrintFormat_ID IN " + "(SELECT AD_PrintFormatChild_ID FROM AD_PrintFormatItem WHERE AD_PrintFormat_ID = " + AD_PrintFormat_ID + " AND PrintFormatType = 'P' GROUP BY AD_PrintFormatChild_ID) OR AD_PrintFormat_ID = " + AD_PrintFormat_ID + ")";
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            X_AD_PrintFormat m_Printformat = new X_AD_PrintFormat(ctx, rs.getInt("AD_PrintFormat_ID"), null);
            if (m_Printformat.getAD_PrintPaper_ID() > 0)
                packOut.createPrintPaper(m_Printformat.getAD_PrintPaper_ID(), document);
            createPrintFormatBinding(atts, m_Printformat);
            document.startElement("", "", "printformat", atts);
            String sql2 = "SELECT * FROM AD_PrintFormatItem WHERE AD_PrintFormat_ID= " + m_Printformat.getAD_PrintFormat_ID() + " ORDER BY " + X_AD_PrintFormatItem.COLUMNNAME_SeqNo + "," + X_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormatItem_ID;
            PreparedStatement pstmt2 = null;
            pstmt2 = DB.prepareStatement(sql2, getTrxName(ctx));
            try {
                ResultSet rs2 = pstmt2.executeQuery();
                while (rs2.next()) {
                    createItem(ctx, document, rs2.getInt("AD_PrintFormatItem_ID"));
                }
                rs2.close();
                pstmt2.close();
                pstmt2 = null;
            } finally {
                try {
                    if (pstmt2 != null)
                        pstmt2.close();
                } catch (Exception e) {
                }
                pstmt2 = null;
            }
            document.endElement("", "", "printformat");
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        if (e instanceof SAXException)
            throw (SAXException) e;
        else if (e instanceof SQLException)
            throw new DatabaseAccessException("Failed to export print format.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export print format.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) X_AD_PrintFormat(org.compiere.model.X_AD_PrintFormat) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SQLException(java.sql.SQLException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException)

Example 14 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class MenuElementHandler method createApplication.

private void createApplication(Properties ctx, TransformerHandler document, int AD_Menu_ID) throws SAXException {
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    String sql = null;
    // int x = 0;
    sql = "SELECT A.Node_ID, B.AD_Menu_ID, B.Name, B.AD_WINDOW_ID, B.AD_WORKFLOW_ID, B.AD_TASK_ID, " + "B.AD_PROCESS_ID, B.AD_FORM_ID , B.AD_BROWSE_ID, B.AD_WORKBENCH_ID " + "FROM AD_TreeNoDemm A, AD_Menu B " + "WHERE A.Node_ID = " + AD_Menu_ID + " AND A.Node_ID = B.AD_Menu_ID";
    AttributesImpl atts = new AttributesImpl();
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            X_AD_Menu m_Menu = new X_AD_Menu(ctx, rs.getInt("AD_Menu_ID"), null);
            atts = createMenuBinding(atts, m_Menu);
            document.startElement("", "", "menu", atts);
            if (rs.getInt("AD_WINDOW_ID") > 0 || rs.getInt("AD_WORKFLOW_ID") > 0 || rs.getInt("AD_TASK_ID") > 0 || rs.getInt("AD_PROCESS_ID") > 0 || rs.getInt("AD_FORM_ID") > 0 || rs.getInt("AD_BROWSE_ID") > 0 || rs.getInt("AD_WORKBENCH_ID") > 0) {
                // Call CreateWindow.
                if (rs.getInt("AD_WINDOW_ID") > 0) {
                    packOut.createWindow(rs.getInt("AD_WINDOW_ID"), document);
                } else // Call CreateProcess.
                if (rs.getInt("AD_PROCESS_ID") > 0) {
                    packOut.createProcess(rs.getInt("AD_PROCESS_ID"), document);
                } else // Call CreateTask.
                if (rs.getInt("AD_TASK_ID") > 0) {
                    packOut.createTask(rs.getInt("AD_TASK_ID"), document);
                } else // Call CreateForm.
                if (rs.getInt("AD_FORM_ID") > 0) {
                    packOut.createForm(rs.getInt("AD_FORM_ID"), document);
                } else // Call CreateBrowse.
                if (rs.getInt("AD_BROWSE_ID") > 0) {
                    packOut.createBrowse(rs.getInt("AD_BROWSE_ID"), document);
                } else // Call CreateWorkflow
                if (rs.getInt("AD_Workflow_ID") > 0) {
                    packOut.createWorkflow(rs.getInt("AD_Workflow_ID"), document);
                }
            // Call CreateModule because entry is a summary menu
            } else {
                createModule(ctx, document, rs.getInt("Node_ID"));
            }
            document.endElement("", "", "menu");
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "getWindows", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Menu(org.compiere.model.X_AD_Menu) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) SAXException(org.xml.sax.SAXException)

Example 15 with PackOut

use of org.adempiere.pipo.PackOut in project adempiere by adempiere.

the class BrowseElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Browse_ID = Env.getContextAsInt(ctx, "AD_Browse_ID");
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    MBrowse m_Browse = new MBrowse(ctx, AD_Browse_ID, null);
    AttributesImpl atts = new AttributesImpl();
    packOut.createView(m_Browse.getAD_View_ID(), document);
    packOut.createProcess(m_Browse.getAD_Process_ID(), document);
    createBrowseBinding(atts, m_Browse);
    document.startElement("", "", "browse", atts);
    // Tab Tag
    StringBuilder whereClause = new StringBuilder(I_AD_Browse_Field.COLUMNNAME_AD_Browse_ID).append("=?");
    List<MBrowseField> browseFields = new Query(ctx, I_AD_Browse_Field.Table_Name, whereClause.toString(), getTrxName(ctx)).setParameters(m_Browse.getAD_Browse_ID()).list();
    for (MBrowseField bf : browseFields) {
        createBrowseField(ctx, document, bf.getAD_Browse_Field_ID());
    }
    // Loop tags.
    document.endElement("", "", "browse");
}
Also used : MBrowseField(org.adempiere.model.MBrowseField) AttributesImpl(org.xml.sax.helpers.AttributesImpl) Query(org.compiere.model.Query) PackOut(org.adempiere.pipo.PackOut) MBrowse(org.adempiere.model.MBrowse)

Aggregations

PackOut (org.adempiere.pipo.PackOut)17 AttributesImpl (org.xml.sax.helpers.AttributesImpl)16 PreparedStatement (java.sql.PreparedStatement)8 ResultSet (java.sql.ResultSet)8 SAXException (org.xml.sax.SAXException)8 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)6 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)5 SQLException (java.sql.SQLException)4 Query (org.compiere.model.Query)3 MBrowseField (org.adempiere.model.MBrowseField)2 MViewColumn (org.adempiere.model.MViewColumn)2 MViewDefinition (org.adempiere.model.MViewDefinition)2 X_AD_Menu (org.compiere.model.X_AD_Menu)2 MBrowse (org.adempiere.model.MBrowse)1 X_AD_View (org.adempiere.model.X_AD_View)1 PackInHandler (org.adempiere.pipo.PackInHandler)1 MPackageExp (org.compiere.model.MPackageExp)1 X_AD_Element (org.compiere.model.X_AD_Element)1 X_AD_Field (org.compiere.model.X_AD_Field)1 X_AD_FieldGroup (org.compiere.model.X_AD_FieldGroup)1