Search in sources :

Example 1 with X_AD_Table

use of org.compiere.model.X_AD_Table 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

PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 PackOut (org.adempiere.pipo.PackOut)1 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)1 X_AD_Table (org.compiere.model.X_AD_Table)1 SAXException (org.xml.sax.SAXException)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1