Search in sources :

Example 6 with PackOut

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

the class ReportViewElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    int AD_ReportView_ID = Env.getContextAsInt(ctx, "AD_ReportView_ID");
    if (views.contains(AD_ReportView_ID))
        return;
    views.add(AD_ReportView_ID);
    String sql = "SELECT * FROM AD_ReportView WHERE AD_ReportView_ID= " + AD_ReportView_ID;
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            X_AD_ReportView m_Reportview = new X_AD_ReportView(ctx, rs.getInt("AD_Reportview_ID"), null);
            atts = createReportViewBinding(atts, m_Reportview);
            document.startElement("", "", "reportview", atts);
            document.endElement("", "", "reportview");
            String sql1 = "SELECT * FROM AD_Printformat WHERE AD_Reportview_ID=" + AD_ReportView_ID + " AND AD_Client_ID=" + Env.getAD_Client_ID(ctx) + " ORDER BY " + X_AD_PrintFormat.COLUMNNAME_AD_PrintFormat_ID;
            PreparedStatement pstmt1 = null;
            pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
            try {
                ResultSet rs1 = pstmt1.executeQuery();
                while (rs1.next()) {
                    // Export Table if neccessary
                    packOut.createTable(rs1.getInt("AD_Table_ID"), document);
                    packOut.createPrintFormat(rs1.getInt("AD_Printformat_ID"), document);
                }
                rs1.close();
                pstmt1.close();
                pstmt1 = null;
            } finally {
                try {
                    if (pstmt1 != null)
                        pstmt1.close();
                } catch (Exception e) {
                }
                pstmt1 = null;
            }
            atts.clear();
            sql1 = "SELECT * FROM AD_ReportView_Col WHERE AD_Reportview_ID= " + AD_ReportView_ID;
            pstmt1 = null;
            pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
            try {
                ResultSet rs1 = pstmt1.executeQuery();
                while (rs1.next()) {
                    createReportViewCol(ctx, document, rs1.getInt("AD_ReportView_Col_ID"));
                }
                rs1.close();
                pstmt1.close();
                pstmt1 = null;
            } finally {
                try {
                    if (pstmt1 != null)
                        pstmt1.close();
                } catch (Exception e) {
                }
                pstmt1 = null;
            }
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "reportview", e);
        if (e instanceof SAXException)
            throw (SAXException) e;
        else if (e instanceof SQLException)
            throw new DatabaseAccessException("Failed to export report view.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export report view.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
}
Also used : X_AD_ReportView(org.compiere.model.X_AD_ReportView) AttributesImpl(org.xml.sax.helpers.AttributesImpl) SQLException(java.sql.SQLException) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) 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 7 with PackOut

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

the class ViewColumnElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_View_Column_ID = Env.getContextAsInt(ctx, X_AD_View_Column.COLUMNNAME_AD_View_Column_ID);
    MViewColumn m_ColumnView = new MViewColumn(ctx, AD_View_Column_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createViewColumnBinding(atts, m_ColumnView);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    document.startElement("", "", "viewcolumn", atts);
    document.endElement("", "", "viewcolumn");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) PackOut(org.adempiere.pipo.PackOut) MViewColumn(org.adempiere.model.MViewColumn)

Example 8 with PackOut

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

the class ViewElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_View_ID = Env.getContextAsInt(ctx, "AD_View_ID");
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    X_AD_View m_View = new X_AD_View(ctx, AD_View_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createViewBinding(atts, m_View);
    document.startElement("", "", "view", atts);
    // Tab Tag
    StringBuilder whereClause = new StringBuilder(I_AD_View.COLUMNNAME_AD_View_ID).append("=?");
    List<MViewDefinition> viewDefinitions = new Query(ctx, I_AD_View_Definition.Table_Name, whereClause.toString(), getTrxName(ctx)).setParameters(m_View.getAD_View_ID()).setOrderBy(X_AD_View_Definition.COLUMNNAME_SeqNo + "," + X_AD_View_Definition.COLUMNNAME_AD_View_Definition_ID).list();
    for (MViewDefinition vd : viewDefinitions) {
        //Is not export table definition because maybe cause changes in tables
        //So that of tables should are created before to import Browser
        //packOut.createTable(vd.getAD_Table_ID(), document);
        createViewDefinition(ctx, document, vd.getAD_View_Definition_ID());
    }
    // Loop tags.
    document.endElement("", "", "view");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) Query(org.compiere.model.Query) PackOut(org.adempiere.pipo.PackOut) MViewDefinition(org.adempiere.model.MViewDefinition) X_AD_View(org.adempiere.model.X_AD_View)

Example 9 with PackOut

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

the class TabElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    int AD_Tab_ID = Env.getContextAsInt(ctx, X_AD_Tab.COLUMNNAME_AD_Tab_ID);
    X_AD_Tab m_Tab = new X_AD_Tab(ctx, AD_Tab_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createTabBinding(atts, m_Tab);
    document.startElement("", "", "tab", atts);
    //Fields tags.
    String sql = "SELECT * FROM AD_FIELD WHERE AD_TAB_ID = " + AD_Tab_ID + "ORDER BY SEQNO asc, " + X_AD_Field.COLUMNNAME_AD_Field_ID;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    try {
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        rs = pstmt.executeQuery();
        while (rs.next()) {
            createField(ctx, document, rs.getInt("AD_Field_ID"));
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        throw new DatabaseAccessException("Failed to export window tab", e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
    document.endElement("", "", "tab");
    if (m_Tab.getAD_Process_ID() > 0) {
        packOut.createProcess(m_Tab.getAD_Process_ID(), document);
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) X_AD_Tab(org.compiere.model.X_AD_Tab) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException)

Example 10 with PackOut

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

the class TableElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Table_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    boolean exported = isTableProcess(ctx, AD_Table_ID);
    AttributesImpl atts = new AttributesImpl();
    //Export table if not already done so
    if (!exported) {
        String sql = "SELECT Name FROM AD_Table WHERE AD_Table_ID= " + AD_Table_ID;
        PreparedStatement pstmt = null;
        pstmt = DB.prepareStatement(sql, getTrxName(ctx));
        try {
            ResultSet rs = pstmt.executeQuery();
            while (rs.next()) {
                X_AD_Table m_Table = new X_AD_Table(ctx, AD_Table_ID, null);
                createTableBinding(atts, m_Table);
                document.startElement("", "", "table", atts);
                String sql1 = "SELECT * FROM AD_Column WHERE AD_Table_ID = " + AD_Table_ID + // Export key column as the first one				
                " ORDER BY IsKey DESC, AD_Column_ID";
                PreparedStatement pstmt1 = null;
                pstmt1 = DB.prepareStatement(sql1, getTrxName(ctx));
                try {
                    ResultSet rs1 = pstmt1.executeQuery();
                    while (rs1.next()) {
                        packOut.createAdElement(rs1.getInt("AD_Element_ID"), document);
                        if (rs1.getInt("AD_Reference_ID") > 0)
                            packOut.createReference(rs1.getInt("AD_Reference_ID"), document);
                        if (rs1.getInt("AD_Reference_Value_ID") > 0)
                            packOut.createReference(rs1.getInt("AD_Reference_Value_ID"), document);
                        if (rs1.getInt("AD_Process_ID") > 0)
                            packOut.createProcess(rs1.getInt("AD_Process_ID"), document);
                        if (rs1.getInt("AD_Val_Rule_ID") > 0)
                            packOut.createDynamicRuleValidation(rs1.getInt("AD_Val_Rule_ID"), document);
                        createColumn(ctx, document, rs1.getInt("AD_Column_ID"));
                    }
                    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;
                }
                document.endElement("", "", "table");
            }
            rs.close();
            pstmt.close();
            pstmt = null;
        } catch (Exception e) {
            log.log(Level.SEVERE, "getProcess", e);
        } finally {
            try {
                if (pstmt != null)
                    pstmt.close();
            } catch (Exception e) {
            }
            pstmt = null;
        }
    }
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) PackOut(org.adempiere.pipo.PackOut) ResultSet(java.sql.ResultSet) X_AD_Table(org.compiere.model.X_AD_Table) PreparedStatement(java.sql.PreparedStatement) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SAXException(org.xml.sax.SAXException)

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