Search in sources :

Example 1 with X_AD_ImpFormat

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

the class ImpFormatElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    int AD_Backup_ID = -1;
    String Object_Status = null;
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Name"));
    int id = get_ID(ctx, "AD_ImpFormat", atts.getValue("Name"));
    X_AD_ImpFormat m_ImpFormat = new X_AD_ImpFormat(ctx, id, getTrxName(ctx));
    if (id <= 0 && atts.getValue("AD_ImpFormat_ID") != null && Integer.parseInt(atts.getValue("AD_ImpFormat_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_ImpFormat.setAD_ImpFormat_ID(Integer.parseInt(atts.getValue("AD_ImpFormat_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_ImpFormat", m_ImpFormat);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    m_ImpFormat.setName(atts.getValue("Name"));
    String name = atts.getValue("ADTableNameID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_ImpFormat.setAD_Table_ID(id);
    }
    m_ImpFormat.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
    m_ImpFormat.setProcessing(atts.getValue("isProcessing") != null ? Boolean.valueOf(atts.getValue("isProcessing")).booleanValue() : true);
    m_ImpFormat.setName(atts.getValue("Name"));
    m_ImpFormat.setDescription(getStringValue(atts, "Description"));
    m_ImpFormat.setFormatType(atts.getValue("FormatType"));
    if (m_ImpFormat.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_ImpFormat.getName(), "ImpFormat", m_ImpFormat.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_ImpFormat"));
    } else {
        record_log(ctx, 0, m_ImpFormat.getName(), "ImpFormat", m_ImpFormat.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_ImpFormat"));
        throw new POSaveFailedException("Failed to save Import Format.");
    }
}
Also used : X_AD_ImpFormat(org.compiere.model.X_AD_ImpFormat) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 2 with X_AD_ImpFormat

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

the class ImpFormatElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int import_id = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_ImpFormat_ID);
    if (formats.contains(import_id))
        return;
    formats.add(import_id);
    AttributesImpl atts = new AttributesImpl();
    X_AD_ImpFormat m_ImpFormat = new X_AD_ImpFormat(ctx, import_id, null);
    atts = createImpFormatBinding(atts, m_ImpFormat);
    document.startElement("", "", "impformat", atts);
    String sql = "SELECT * FROM AD_ImpFormat_Row WHERE AD_ImpFormat_ID= " + import_id + " ORDER BY " + X_AD_ImpFormat_Row.COLUMNNAME_AD_ImpFormat_Row_ID;
    PreparedStatement pstmt = null;
    pstmt = DB.prepareStatement(sql, getTrxName(ctx));
    try {
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()) {
            createImpFormatRow(ctx, document, rs.getInt("AD_ImpFormat_Row_ID"));
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, "ImpFormat", e);
        throw new DatabaseAccessException("Failed to export Import Format.", e);
    } finally {
        try {
            if (pstmt != null)
                pstmt.close();
        } catch (Exception e) {
        }
        pstmt = null;
    }
    document.endElement("", "", "impformat");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_ImpFormat(org.compiere.model.X_AD_ImpFormat) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException) SAXException(org.xml.sax.SAXException) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException)

Aggregations

POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)2 X_AD_ImpFormat (org.compiere.model.X_AD_ImpFormat)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)1 Attributes (org.xml.sax.Attributes)1 SAXException (org.xml.sax.SAXException)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1