Search in sources :

Example 1 with X_AD_ImpFormat_Row

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

the class ImpFormatRowElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_ImpFormat_Row_ID = Env.getContextAsInt(ctx, X_AD_ImpFormat_Row.COLUMNNAME_AD_ImpFormat_Row_ID);
    X_AD_ImpFormat_Row m_ImpFormat_Row = new X_AD_ImpFormat_Row(ctx, AD_ImpFormat_Row_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createImpFormatRowBinding(atts, m_ImpFormat_Row);
    document.startElement("", "", "impformatrow", atts);
    document.endElement("", "", "impformatrow");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_ImpFormat_Row(org.compiere.model.X_AD_ImpFormat_Row)

Example 2 with X_AD_ImpFormat_Row

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

the class ImpFormatRowElementHandler 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 impformid = get_ID(ctx, "AD_ImpFormat", atts.getValue("ADImpFormatNameID"));
    if (impformid <= 0) {
        element.defer = true;
        return;
    }
    String name = atts.getValue("ADTableNameID");
    int tableid = 0;
    if (name != null && name.trim().length() > 0) {
        tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
        if (tableid <= 0) {
            element.defer = true;
            return;
        }
    }
    name = atts.getValue("ADColumnNameID");
    int columnid = 0;
    if (name != null && name.trim().length() > 0) {
        columnid = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", name, "AD_Table", tableid);
        if (columnid <= 0) {
            element.defer = true;
            return;
        }
    }
    StringBuffer sqlB = new StringBuffer("SELECT AD_ImpFormat_Row_ID FROM AD_ImpFormat_Row WHERE AD_Column_ID=? and AD_ImpFormat_ID=?");
    int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), columnid, impformid);
    X_AD_ImpFormat_Row m_ImpFormat_row = new X_AD_ImpFormat_Row(ctx, id, getTrxName(ctx));
    if (id <= 0 && atts.getValue("AD_ImpFormat_Row_ID") != null && Integer.parseInt(atts.getValue("AD_ImpFormat_Row_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_ImpFormat_row.setAD_ImpFormat_Row_ID(Integer.parseInt(atts.getValue("AD_ImpFormat_Row_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_ImpFormat", m_ImpFormat_row);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    m_ImpFormat_row.setName(atts.getValue("Name"));
    m_ImpFormat_row.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
    if (columnid > 0)
        m_ImpFormat_row.setAD_Column_ID(columnid);
    m_ImpFormat_row.setAD_ImpFormat_ID(impformid);
    m_ImpFormat_row.setDataFormat(atts.getValue("DataFormat"));
    m_ImpFormat_row.setDataType(atts.getValue("DataType"));
    m_ImpFormat_row.setDecimalPoint(atts.getValue("DecimalPoint"));
    m_ImpFormat_row.setDivideBy100(atts.getValue("isDivideBy100") != null ? Boolean.valueOf(atts.getValue("isDivideBy100")).booleanValue() : true);
    m_ImpFormat_row.setConstantValue(atts.getValue("ConstantValue"));
    m_ImpFormat_row.setCallout(atts.getValue("Callout"));
    m_ImpFormat_row.setEndNo(Integer.parseInt(atts.getValue("EndNo")));
    m_ImpFormat_row.setScript(atts.getValue("Script"));
    m_ImpFormat_row.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
    m_ImpFormat_row.setStartNo(Integer.parseInt(atts.getValue("StartNo")));
    if (m_ImpFormat_row.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_ImpFormat_row.getName(), "ImpFormatRow", m_ImpFormat_row.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
    } else {
        record_log(ctx, 0, m_ImpFormat_row.getName(), "ImpFormatRow", m_ImpFormat_row.get_ID(), AD_Backup_ID, Object_Status, "AD_ImpFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "m_ImpFormat_row"));
        throw new POSaveFailedException("Failed to import Import Format Row.");
    }
}
Also used : Attributes(org.xml.sax.Attributes) X_AD_ImpFormat_Row(org.compiere.model.X_AD_ImpFormat_Row) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Aggregations

X_AD_ImpFormat_Row (org.compiere.model.X_AD_ImpFormat_Row)2 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)1 Attributes (org.xml.sax.Attributes)1 AttributesImpl (org.xml.sax.helpers.AttributesImpl)1