Search in sources :

Example 1 with X_AD_Window

use of org.compiere.model.X_AD_Window in project adempiere by adempiere.

the class WindowElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Window_ID = Env.getContextAsInt(ctx, "AD_Window_ID");
    PackOut packOut = (PackOut) ctx.get("PackOutProcess");
    X_AD_Window m_Window = new X_AD_Window(ctx, AD_Window_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createWindowBinding(atts, m_Window);
    document.startElement("", "", "window", atts);
    // Tab Tag
    String sql = "SELECT * FROM AD_TAB WHERE AD_WINDOW_ID = " + AD_Window_ID + " ORDER BY " + X_AD_Tab.COLUMNNAME_SeqNo + "," + X_AD_Tab.COLUMNNAME_AD_Tab_ID;
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            packOut.createTable(rs.getInt("AD_Table_ID"), document);
            createTab(ctx, document, rs.getInt("AD_Tab_ID"));
        }
        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 window.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export window.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
    //TODO: export of ad_image and ad_color use
    // Loop tags.
    document.endElement("", "", "window");
    // Preference Tag
    sql = "SELECT * FROM AD_PREFERENCE WHERE AD_WINDOW_ID = " + AD_Window_ID + " ORDER BY " + X_AD_Preference.COLUMNNAME_AD_Preference_ID;
    pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createPreference(ctx, document, rs.getInt("AD_Preference_ID"));
        }
        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 window preference.", e);
        else if (e instanceof RuntimeException)
            throw (RuntimeException) e;
        else
            throw new RuntimeException("Failed to export window preference.", 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) X_AD_Window(org.compiere.model.X_AD_Window) 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)

Aggregations

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