Search in sources :

Example 46 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class DataElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    String sql = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_SQLStatement);
    int table_id = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Table_ID);
    Statement stmt = DB.createStatement();
    AttributesImpl atts = new AttributesImpl();
    document.startElement("", "", "data", atts);
    try {
        ResultSet rs = stmt.executeQuery(sql);
        ResultSetMetaData meta = rs.getMetaData();
        int columns = meta.getColumnCount();
        int i = 1;
        String col_Name = null;
        String sql1 = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
        String table_Name = DB.getSQLValueString(null, sql1, table_id);
        atts.clear();
        atts.addAttribute("", "", "name", "CDATA", table_Name);
        document.startElement("", "", "dtable", atts);
        while (rs.next()) {
            atts.clear();
            int key1 = 0;
            String nameatts = "";
            for (i = 1; i <= columns; i++) {
                col_Name = meta.getColumnName(i).toUpperCase();
                if (col_Name.equals("NAME") && rs.getObject("name") != null)
                    nameatts = "" + rs.getObject("name");
                String sql2 = "SELECT ColumnName FROM AD_Column " + "WHERE isKey = 'Y' AND " + "AD_Table_ID = ? AND " + "Upper(ColumnName)= '" + col_Name + "'";
                String cName = DB.getSQLValueString(null, sql2, table_id);
                if (cName != null) {
                    if (cName.toUpperCase().equals(col_Name) && key1 == 0) {
                        atts.addAttribute("", "", "key1name", "CDATA", cName);
                        atts.addAttribute("", "", "lookupkey1name", "CDATA", "" + rs.getObject(col_Name));
                        key1 = 1;
                    } else if (cName.toUpperCase().equals(col_Name) && key1 == 1) {
                        atts.addAttribute("", "", "key2name", "CDATA", cName);
                        atts.addAttribute("", "", "lookupkey2name", "CDATA", "" + rs.getObject(col_Name));
                        key1 = 2;
                    }
                }
            }
            atts.addAttribute("", "", "name", "CDATA", nameatts);
            if (key1 == 0) {
                atts.addAttribute("", "", "key1name", "CDATA", "");
                atts.addAttribute("", "", "lookupkey1name", "CDATA", "");
                key1 = 1;
            }
            if (key1 == 1) {
                atts.addAttribute("", "", "key2name", "CDATA", "");
                atts.addAttribute("", "", "lookupkey2name", "CDATA", "");
            }
            document.startElement("", "", "drow", atts);
            for (i = 1; i <= columns; i++) {
                atts.clear();
                col_Name = meta.getColumnName(i).toUpperCase();
                String sql2 = "Select A.ColumnName, B.Name " + "From AD_Column A, AD_Reference B " + "Where Upper(A.columnname) = ? and " + "A.AD_TABLE_ID = ? and " + "A.AD_Reference_ID = B.AD_Reference_ID";
                PreparedStatement pstmt = null;
                try {
                    pstmt = DB.prepareStatement(sql2, getTrxName(ctx));
                    pstmt.setString(1, col_Name);
                    pstmt.setInt(2, table_id);
                    ResultSet rs1 = pstmt.executeQuery();
                    while (rs1.next()) {
                        //added 9/3/05
                        atts.clear();
                        atts.addAttribute("", "", "name", "CDATA", rs1.getString("ColumnName"));
                        atts.addAttribute("", "", "class", "CDATA", rs1.getString("Name"));
                        if (rs1.getString("Name").equals("Date") || rs1.getString("Name").equals("Date+Time") || rs1.getString("Name").equals("Time"))
                            atts.addAttribute("", "", "value", "CDATA", "" + rs.getTimestamp(i));
                        else
                            atts.addAttribute("", "", "value", "CDATA", "" + rs.getObject(i));
                        if (!rs1.getString("ColumnName").equals("Created") && !rs1.getString("ColumnName").equals("CreatedBy") && !rs1.getString("ColumnName").equals("Updated") && !rs1.getString("ColumnName").equals("UpdatedBy")) {
                            document.startElement("", "", "dcolumn", atts);
                            document.endElement("", "", "dcolumn");
                        }
                    }
                    rs1.close();
                    pstmt.close();
                    pstmt = null;
                } catch (Exception e) {
                    log.log(Level.SEVERE, "getData", e);
                }
            }
            document.endElement("", "", "drow");
        }
        rs.close();
        stmt.close();
        stmt = null;
        document.endElement("", "", "dtable");
    } catch (Exception e) {
        log.log(Level.SEVERE, "getData", e);
    }
    document.endElement("", "", "data");
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) AttributesImpl(org.xml.sax.helpers.AttributesImpl) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SAXException(org.xml.sax.SAXException)

Example 47 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class DynValRuleElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Val_Rule_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
    if (rules.contains(AD_Val_Rule_ID))
        return;
    rules.add(AD_Val_Rule_ID);
    String sql = "SELECT Name FROM AD_Val_Rule WHERE  AD_Val_Rule_ID= " + AD_Val_Rule_ID;
    AttributesImpl atts = new AttributesImpl();
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        rs = pstmt.executeQuery();
        while (rs.next()) {
            X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule(ctx, AD_Val_Rule_ID, null);
            createDynamicValidationRuleBinding(atts, m_ValRule);
            document.startElement("", "", "dynvalrule", atts);
            document.endElement("", "", "dynvalrule");
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "getProcess", e);
    } finally {
        DB.close(rs, pstmt);
        rs = null;
        pstmt = null;
    }
}
Also used : X_AD_Val_Rule(org.compiere.model.X_AD_Val_Rule) AttributesImpl(org.xml.sax.helpers.AttributesImpl) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) SAXException(org.xml.sax.SAXException)

Example 48 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class FormElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Form_ID = Env.getContextAsInt(ctx, "AD_Form_ID");
    if (forms.contains(AD_Form_ID))
        return;
    forms.add(AD_Form_ID);
    X_AD_Form m_Form = new X_AD_Form(ctx, AD_Form_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createFormBinding(atts, m_Form);
    document.startElement("", "", "form", atts);
    document.endElement("", "", "form");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Form(org.compiere.model.X_AD_Form)

Example 49 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class PrintPaperElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    final int id = getExportItem_ID(ctx);
    if (list.contains(id))
        return;
    list.add(id);
    final PO po = getCreatePO(ctx, id, null);
    final AttributesImpl atts = new AttributesImpl();
    createMessageBinding(atts, po);
    document.startElement("", "", getTagName(), atts);
    document.endElement("", "", getTagName());
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) PO(org.compiere.model.PO)

Example 50 with AttributesImpl

use of org.xml.sax.helpers.AttributesImpl in project adempiere by adempiere.

the class PrintFormatItemElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_PrintFormatItem_ID = Env.getContextAsInt(ctx, X_AD_PrintFormatItem.COLUMNNAME_AD_PrintFormatItem_ID);
    X_AD_PrintFormatItem m_PrintFormatItem = new X_AD_PrintFormatItem(ctx, AD_PrintFormatItem_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createPrintFormatItemBinding(atts, m_PrintFormatItem);
    document.startElement("", "", "printformatitem", atts);
    document.endElement("", "", "printformatitem");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_PrintFormatItem(org.compiere.model.X_AD_PrintFormatItem)

Aggregations

AttributesImpl (org.xml.sax.helpers.AttributesImpl)310 SAXException (org.xml.sax.SAXException)53 Test (org.junit.Test)34 DiskWriteAttributesImpl (org.apache.geode.internal.cache.DiskWriteAttributesImpl)23 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)23 ContentHandler (org.xml.sax.ContentHandler)21 Attributes (org.xml.sax.Attributes)17 PreparedStatement (java.sql.PreparedStatement)16 ResultSet (java.sql.ResultSet)16 Map (java.util.Map)16 PackOut (org.adempiere.pipo.PackOut)16 IOException (java.io.IOException)15 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)12 Iterator (java.util.Iterator)11 TransformerHandler (javax.xml.transform.sax.TransformerHandler)11 StreamResult (javax.xml.transform.stream.StreamResult)11 Metadata (org.apache.tika.metadata.Metadata)11 File (java.io.File)9 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)9 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)9