Search in sources :

Example 26 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class ReferenceElementHandler 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"));
    String entitytype = atts.getValue("EntityType");
    String name = atts.getValue("name");
    if (isProcessElement(ctx, entitytype)) {
        int id = get_ID(ctx, "AD_Reference", name);
        X_AD_Reference m_Reference = new X_AD_Reference(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Reference_ID") != null && Integer.parseInt(atts.getValue("AD_Reference_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Reference.setAD_Reference_ID(Integer.parseInt(atts.getValue("AD_Reference_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Reference", m_Reference);
            Object_Status = "Update";
            if (references.contains(id)) {
                element.skip = true;
                return;
            }
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Reference.setDescription(getStringValue(atts, "Description"));
        m_Reference.setEntityType(atts.getValue("EntityType"));
        m_Reference.setHelp(getStringValue(atts, "Help"));
        m_Reference.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Reference.setName(atts.getValue("name"));
        // m_Reference.setVFormat(atts.getValue("VFormat"));
        m_Reference.setValidationType(atts.getValue("ValidationType"));
        if (m_Reference.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Reference.getName(), "Reference", m_Reference.get_ID(), AD_Backup_ID, Object_Status, "AD_Reference", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reference"));
            references.add(m_Reference.getAD_Reference_ID());
            element.recordId = m_Reference.getAD_Reference_ID();
        } else {
            record_log(ctx, 0, m_Reference.getName(), "Reference", m_Reference.get_ID(), AD_Backup_ID, Object_Status, "AD_Reference", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reference"));
            throw new POSaveFailedException("Reference");
        }
    } else {
        element.skip = true;
    }
}
Also used : X_AD_Reference(org.compiere.model.X_AD_Reference) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 27 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class ColumnElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    PackIn packIn = (PackIn) ctx.get("PackInProcess");
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("ColumnName"));
    int success = 0;
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        if (element.parent != null && element.parent.getElementValue().equals("table") && element.parent.defer) {
            element.defer = true;
            return;
        }
        String columnName = atts.getValue("ColumnName");
        String tableName = atts.getValue("ADTableNameID");
        int tableid = 0;
        if (element.parent != null && element.parent.getElementValue().equals("table") && element.parent.recordId > 0) {
            tableid = element.parent.recordId;
        } else {
            tableid = packIn.getTableId(tableName);
        }
        if (tableid <= 0) {
            tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", tableName);
            if (tableid > 0)
                packIn.addTable(tableName, tableid);
        }
        int id = packIn.getColumnId(tableName, columnName);
        if (id <= 0) {
            id = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid);
            if (id > 0) {
                packIn.addColumn(tableName, columnName, id);
            }
        }
        MColumn m_Column = new MColumn(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Column_ID") != null && Integer.parseInt(atts.getValue("AD_Column_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Column.setAD_Column_ID(Integer.parseInt(atts.getValue("AD_Column_ID")));
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Column", m_Column);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Column.setColumnName(columnName);
        // Process
        String processName = atts.getValue("ADProcessNameID");
        int AD_Process_ID = get_IDWithColumn(ctx, "AD_Process", "Value", processName);
        if (AD_Process_ID <= 0) /** TODO PackOut version check 005 */
        {
            AD_Process_ID = get_IDWithColumn(ctx, "AD_Process", "Name", processName);
        }
        m_Column.setAD_Process_ID(AD_Process_ID);
        //
        String Name = atts.getValue("ADReferenceNameID");
        int referenceId = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
        m_Column.setAD_Reference_ID(referenceId);
        // log.info("Column ID ->"+id);
        Name = atts.getValue("ADTableNameID");
        id = get_IDWithColumn(ctx, "AD_Table", "TableName", Name);
        m_Column.setAD_Table_ID(id);
        Name = atts.getValue("ADValRuleNameID");
        id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", Name);
        m_Column.setAD_Val_Rule_ID(id);
        //Validate that reference id is for Table or List
        if (DisplayType.Table == referenceId || DisplayType.List == referenceId || DisplayType.Search == referenceId) {
            Name = atts.getValue("ADReferenceNameValueID");
            id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
            m_Column.setAD_Reference_Value_ID(id);
        }
        m_Column.setCallout(getStringValue(atts, "Callout"));
        m_Column.setColumnSQL(getStringValue(atts, "ColumnSQL"));
        m_Column.setColumnName(atts.getValue("ColumnName"));
        m_Column.setDefaultValue(getStringValue(atts, "DefaultValue"));
        m_Column.setDescription(getStringValue(atts, "Description"));
        m_Column.setEntityType(atts.getValue("EntityType"));
        if (Integer.parseInt(atts.getValue("FieldLength")) > 0)
            m_Column.setFieldLength(Integer.parseInt(atts.getValue("FieldLength")));
        m_Column.setHelp(getStringValue(atts, "Help"));
        m_Column.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Column.setIsAlwaysUpdateable((Boolean.valueOf(atts.getValue("isAlwaysUpdateable")).booleanValue()));
        // m_Column.setIsEncrypted(atts.getValue("isEncrypted"));
        m_Column.setIsIdentifier((Boolean.valueOf(atts.getValue("isIdentifier")).booleanValue()));
        m_Column.setIsKey((Boolean.valueOf(atts.getValue("isKey")).booleanValue()));
        m_Column.setIsMandatory((Boolean.valueOf(atts.getValue("isMandatory")).booleanValue()));
        m_Column.setIsParent((Boolean.valueOf(atts.getValue("isParent")).booleanValue()));
        m_Column.setIsSelectionColumn((Boolean.valueOf(atts.getValue("isSelectionColumn")).booleanValue()));
        m_Column.setIsSyncDatabase(atts.getValue("getIsSyncDatabase"));
        m_Column.setIsTranslated((Boolean.valueOf(atts.getValue("isTranslated")).booleanValue()));
        m_Column.setIsUpdateable((Boolean.valueOf(atts.getValue("isUpdateable")).booleanValue()));
        m_Column.setName(atts.getValue("Name"));
        m_Column.setReadOnlyLogic(getStringValue(atts, "ReadOnlyLogic"));
        if (Integer.parseInt(atts.getValue("SeqNo")) > 0)
            m_Column.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
        m_Column.setVFormat(getStringValue(atts, "VFormat"));
        if (getStringValue(atts, "ValueMax") != null)
            m_Column.setValueMax(atts.getValue("ValueMax"));
        if (getStringValue(atts, "ValueMin") != null)
            m_Column.setValueMin(atts.getValue("ValueMin"));
        if (getStringValue(atts, "Version") != null)
            m_Column.setVersion(new BigDecimal(atts.getValue("Version")));
        m_Column.setInfoFactoryClass(getStringValue(atts, "InfoFactoryClass"));
        // Setup Element.
        id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", m_Column.getColumnName());
        X_AD_Element adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
        String Object_Status_col = Object_Status;
        if (adElement.getAD_Element_ID() == 0) {
            // Object_Status = "New";
            adElement.setColumnName(m_Column.getColumnName());
            adElement.setEntityType(m_Column.getEntityType());
            adElement.setPrintName(m_Column.getColumnName());
            adElement.setName(m_Column.getColumnName());
            if (adElement.save(getTrxName(ctx)) == true) {
                record_log(ctx, 1, m_Column.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
            } else {
                record_log(ctx, 0, m_Column.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
            }
        }
        Object_Status = Object_Status_col;
        m_Column.setAD_Element_ID(adElement.getAD_Element_ID());
        boolean recreateColumn = (m_Column.is_new() || m_Column.is_ValueChanged("AD_Reference_ID") || m_Column.is_ValueChanged("FieldLength") || m_Column.is_ValueChanged("ColumnName") || m_Column.is_ValueChanged("IsMandatory"));
        //ignore fieldlength change for clob and lob
        if (!m_Column.is_ValueChanged("AD_Reference_ID") && m_Column.is_ValueChanged("FieldLength")) {
            if (DisplayType.isLOB(m_Column.getAD_Reference_ID())) {
                recreateColumn = false;
            }
        }
        // nulls
        if (!recreateColumn) {
            String oldDefault = (String) m_Column.get_ValueOld("DefaultValue");
            String newDefault = m_Column.getDefaultValue();
            if (oldDefault != null && oldDefault.length() == 0)
                oldDefault = null;
            if (newDefault != null && newDefault.length() == 0)
                newDefault = null;
            if ((oldDefault == null && newDefault != null) || (oldDefault != null && newDefault == null)) {
                recreateColumn = true;
            } else if (oldDefault != null && newDefault != null) {
                if (!oldDefault.equals(newDefault))
                    recreateColumn = true;
            }
        }
        // Don't create database column for virtual columns
        boolean syncDatabase = "Y".equalsIgnoreCase(atts.getValue("getIsSyncDatabase"));
        if (recreateColumn) {
            if (m_Column.isVirtualColumn() || !syncDatabase)
                recreateColumn = false;
        }
        if (m_Column.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Column.getName(), "Column", m_Column.get_ID(), AD_Backup_ID, Object_Status, "AD_Column", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Column"));
            element.recordId = m_Column.getAD_Column_ID();
        } else {
            record_log(ctx, 0, m_Column.getName(), "Column", m_Column.get_ID(), AD_Backup_ID, Object_Status, "AD_Column", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Column"));
            throw new POSaveFailedException("Failed to import column.");
        }
        if (recreateColumn || syncDatabase) {
            MTable table = new MTable(ctx, m_Column.getAD_Table_ID(), getTrxName(ctx));
            if (!table.isView() && !m_Column.isVirtualColumn()) {
                success = createColumn(ctx, table, m_Column, recreateColumn);
                if (success == 1) {
                    record_log(ctx, 1, m_Column.getColumnName(), "dbColumn", m_Column.get_ID(), 0, Object_Status, atts.getValue("ADTableNameID").toUpperCase(), get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID").toUpperCase()));
                } else {
                    record_log(ctx, 0, m_Column.getColumnName(), "dbColumn", m_Column.get_ID(), 0, Object_Status, atts.getValue("ADTableNameID").toUpperCase(), get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID").toUpperCase()));
                    throw new DatabaseAccessException("Failed to create column or related constraint for " + m_Column.getColumnName());
                }
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : MColumn(org.compiere.model.MColumn) MTable(org.compiere.model.MTable) PackIn(org.adempiere.pipo.PackIn) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Element(org.compiere.model.X_AD_Element) BigDecimal(java.math.BigDecimal) DatabaseAccessException(org.adempiere.pipo.exception.DatabaseAccessException)

Example 28 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class AdElementHandler 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("ColumnName"));
    String entitytype = atts.getValue("EntityType");
    String ColumnName = atts.getValue("ColumnName");
    if (isProcessElement(ctx, entitytype)) {
        int id = get_IDWithColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName);
        X_AD_Element m_AdElement = new X_AD_Element(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Element_ID") != null && Integer.parseInt(atts.getValue("AD_Element_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_AdElement.setAD_Element_ID(Integer.parseInt(atts.getValue("AD_Element_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, AD_ELEMENT, m_AdElement);
            Object_Status = "Update";
            if (processedElements.contains(id)) {
                element.skip = true;
                return;
            }
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        PoFiller pf = new PoFiller(m_AdElement, atts);
        pf.setBoolean("IsActive");
        pf.setString(X_AD_Element.COLUMNNAME_ColumnName);
        pf.setString(X_AD_Element.COLUMNNAME_Description);
        pf.setString(X_AD_Element.COLUMNNAME_EntityType);
        pf.setString(X_AD_Element.COLUMNNAME_Help);
        pf.setString(X_AD_Element.COLUMNNAME_Name);
        pf.setString(X_AD_Element.COLUMNNAME_PrintName);
        pf.setString(X_AD_Element.COLUMNNAME_PO_Description);
        pf.setString(X_AD_Element.COLUMNNAME_PO_Name);
        pf.setString(X_AD_Element.COLUMNNAME_PO_Help);
        pf.setString(X_AD_Element.COLUMNNAME_PO_PrintName);
        String Name = atts.getValue("ADReferenceNameID");
        id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
        m_AdElement.setAD_Reference_ID(id);
        Name = atts.getValue("ADReferenceNameValueID");
        id = get_IDWithColumn(ctx, "AD_Reference", "Name", Name);
        m_AdElement.setAD_Reference_Value_ID(id);
        if (m_AdElement.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_AdElement.getName(), "Element", m_AdElement.get_ID(), AD_Backup_ID, Object_Status, AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table", "TableName", AD_ELEMENT));
            element.recordId = m_AdElement.getAD_Element_ID();
            processedElements.add(m_AdElement.getAD_Element_ID());
        } else {
            record_log(ctx, 0, m_AdElement.getName(), "Element", m_AdElement.get_ID(), AD_Backup_ID, Object_Status, AD_ELEMENT, get_IDWithColumn(ctx, "AD_Table", "TableName", AD_ELEMENT));
            throw new POSaveFailedException("Reference");
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo.PoFiller) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Element(org.compiere.model.X_AD_Element)

Example 29 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class PrintFormatElementHandler 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"));
    String name = atts.getValue("Name");
    int id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
    X_AD_PrintFormat m_PrintFormat = new X_AD_PrintFormat(ctx, id, getTrxName(ctx));
    if (id <= 0 && atts.getValue("AD_PrintFormat_ID") != null && Integer.parseInt(atts.getValue("AD_PrintFormat_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_PrintFormat.setAD_PrintFormat_ID(Integer.parseInt(atts.getValue("AD_PrintFormat_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_PrintFormat", m_PrintFormat);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    name = atts.getValue("ADReportviewnameID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_PrintFormat.setAD_ReportView_ID(id);
    }
    name = atts.getValue("ADTableNameID");
    id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
    if (id == 0) {
        MTable m_Table = new MTable(ctx, 0, getTrxName(ctx));
        m_Table.setAccessLevel("3");
        m_Table.setName(name);
        m_Table.setTableName(name);
        if (m_Table.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Table.getName(), "Table", m_Table.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
        } else {
            record_log(ctx, 0, m_Table.getName(), "Table", m_Table.get_ID(), 0, "New", "AD_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Table"));
        }
        id = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
    }
    m_PrintFormat.setAD_Table_ID(id);
    name = atts.getValue("ADPrintTableFormatID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintTableFormat", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_PrintFormat.setAD_PrintTableFormat_ID(id);
    }
    name = atts.getValue("ADPrintColorID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_PrintFormat.setAD_PrintColor_ID(id);
    }
    name = atts.getValue("ADPrintFontID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_PrintFormat.setAD_PrintFont_ID(id);
    }
    name = atts.getValue("ADPrintPaperID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintPaper", "Name", name);
        if (id <= 0) {
            element.defer = true;
            return;
        }
        m_PrintFormat.setAD_PrintPaper_ID(id);
    }
    m_PrintFormat.setDescription(getStringValue(atts, "Description"));
    m_PrintFormat.setName(atts.getValue("Name"));
    m_PrintFormat.setPrinterName(getStringValue(atts, "PrinterName"));
    m_PrintFormat.setFooterMargin(Integer.parseInt(atts.getValue("FooterMargin")));
    m_PrintFormat.setHeaderMargin(Integer.parseInt(atts.getValue("HeaderMargin")));
    m_PrintFormat.setCreateCopy(atts.getValue("CreateCopy"));
    m_PrintFormat.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
    m_PrintFormat.setIsTableBased(Boolean.valueOf(atts.getValue("isTableBased")).booleanValue());
    m_PrintFormat.setIsForm(Boolean.valueOf(atts.getValue("isForm")).booleanValue());
    m_PrintFormat.setIsStandardHeaderFooter(Boolean.valueOf(atts.getValue("isStandardHeader")).booleanValue());
    m_PrintFormat.setIsDefault(Boolean.valueOf(atts.getValue("isDefault")).booleanValue());
    if (m_PrintFormat.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_PrintFormat.getName(), "PrintFormat", m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status, "AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormat"));
        element.recordId = m_PrintFormat.getAD_PrintFormat_ID();
    } else {
        record_log(ctx, 0, m_PrintFormat.getName(), "PrintFormat", m_PrintFormat.get_ID(), AD_Backup_ID, Object_Status, "AD_PrintFormat", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormat"));
        throw new POSaveFailedException("Failed to save Print Format");
    }
}
Also used : MTable(org.compiere.model.MTable) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_PrintFormat(org.compiere.model.X_AD_PrintFormat)

Example 30 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException in project adempiere by adempiere.

the class PrintFormatItemElementHandler 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"));
    if (element.parent != null && element.parent.getElementValue().equals("printformat") && element.parent.defer) {
        element.defer = true;
        return;
    }
    String name = atts.getValue("Name");
    int id = get_IDWithMaster(ctx, "AD_PrintFormatItem", name, "AD_PrintFormat", atts.getValue("ADPrintFormatNameID"));
    X_AD_PrintFormatItem m_PrintFormatItem = new X_AD_PrintFormatItem(ctx, id, getTrxName(ctx));
    if (id <= 0 && atts.getValue("AD_PrintFormatItem_ID") != null && Integer.parseInt(atts.getValue("AD_PrintFormatItem_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_PrintFormatItem.setAD_PrintFormatItem_ID(Integer.parseInt(atts.getValue("AD_PrintFormatItem_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_PrintFormatItem", m_PrintFormatItem);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    m_PrintFormatItem.setName(name);
    name = atts.getValue("ADPrintFormatNameID");
    if (element.parent != null && element.parent.getElementValue().equals("printformat") && element.parent.recordId != 0) {
        id = element.parent.recordId;
    } else {
        id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
        if (element.parent != null && element.parent.getElementValue().equals("printformat") && id > 0) {
            element.parent.recordId = id;
        }
    }
    if (id <= 0) {
        element.defer = true;
        return;
    }
    m_PrintFormatItem.setAD_PrintFormat_ID(id);
    name = atts.getValue("ADTableNameID");
    int tableid = get_IDWithColumn(ctx, "AD_Table", "TableName", name);
    name = atts.getValue("ADColumnNameID");
    id = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", name, "AD_Table", tableid);
    if (id > 0)
        m_PrintFormatItem.setAD_Column_ID(id);
    name = atts.getValue("ADPrintFormatChildNameID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
        if (id <= 0) {
            element.defer = true;
            element.unresolved = "AD_PrintFormat: " + name;
            return;
        }
        m_PrintFormatItem.setAD_PrintFormatChild_ID(id);
    }
    name = atts.getValue("ADPrintGraphID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintGraph", "Name", name);
        /*
			if (id <= 0) {
				element.defer = true;
				return;
			}*/
        if (id > 0)
            m_PrintFormatItem.setAD_PrintGraph_ID(id);
    }
    name = atts.getValue("ADPrintColorID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintColor", "Name", name);
        /*
			if (id <= 0) {
				element.defer = true;
				return;
			}*/
        if (id > 0)
            m_PrintFormatItem.setAD_PrintColor_ID(id);
    }
    name = atts.getValue("ADPrintFontID");
    if (name != null && name.trim().length() > 0) {
        id = get_IDWithColumn(ctx, "AD_PrintFont", "Name", name);
        /*
			if (id <= 0) {
				element.defer = true;
				return;
			}*/
        if (id > 0)
            m_PrintFormatItem.setAD_PrintFont_ID(id);
    }
    m_PrintFormatItem.setPrintName(getStringValue(atts, "PrintName"));
    m_PrintFormatItem.setName(atts.getValue("Name"));
    m_PrintFormatItem.setPrintAreaType(getStringValue(atts, "PrintAreaType"));
    m_PrintFormatItem.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
    m_PrintFormatItem.setPrintFormatType(getStringValue(atts, "PrintFormatType"));
    m_PrintFormatItem.setXSpace(Integer.parseInt(atts.getValue("XSpace")));
    m_PrintFormatItem.setYSpace(Integer.parseInt(atts.getValue("YSpace")));
    m_PrintFormatItem.setXPosition(Integer.parseInt(atts.getValue("Xposition")));
    m_PrintFormatItem.setYPosition(Integer.parseInt(atts.getValue("Yposition")));
    m_PrintFormatItem.setMaxWidth(Integer.parseInt(atts.getValue("MaxWidth")));
    m_PrintFormatItem.setMaxHeight(Integer.parseInt(atts.getValue("MaxHieght")));
    m_PrintFormatItem.setSortNo(Integer.parseInt(atts.getValue("SortNo")));
    m_PrintFormatItem.setFieldAlignmentType(getStringValue(atts, "FieldAlignmentType"));
    m_PrintFormatItem.setLineAlignmentType(getStringValue(atts, "LineAlignmentType"));
    m_PrintFormatItem.setImageURL(getStringValue(atts, "ImageURL"));
    m_PrintFormatItem.setArcDiameter(Integer.parseInt(atts.getValue("ArcDiameter")));
    m_PrintFormatItem.setLineWidth(Integer.parseInt(atts.getValue("LineWidth")));
    m_PrintFormatItem.setShapeType(getStringValue(atts, "ShapeType"));
    m_PrintFormatItem.setBelowColumn(Integer.parseInt(atts.getValue("BelowColumn")));
    m_PrintFormatItem.setPrintNameSuffix(getStringValue(atts, "PrintNameSuffix"));
    m_PrintFormatItem.setRunningTotalLines(Integer.parseInt(atts.getValue("RunningTotalLines")));
    m_PrintFormatItem.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
    m_PrintFormatItem.setIsPrinted(Boolean.valueOf(atts.getValue("isPrinted")).booleanValue());
    m_PrintFormatItem.setIsRelativePosition(Boolean.valueOf(atts.getValue("isRelativePosition")).booleanValue());
    m_PrintFormatItem.setIsNextLine(Boolean.valueOf(atts.getValue("isNextLine")).booleanValue());
    m_PrintFormatItem.setIsHeightOneLine(Boolean.valueOf(atts.getValue("isHeightOneLine")).booleanValue());
    m_PrintFormatItem.setIsOrderBy(Boolean.valueOf(atts.getValue("isOrderBy")).booleanValue());
    m_PrintFormatItem.setIsGroupBy(Boolean.valueOf(atts.getValue("isGroupBy")).booleanValue());
    m_PrintFormatItem.setIsPageBreak(Boolean.valueOf(atts.getValue("isPageBreak")).booleanValue());
    m_PrintFormatItem.setIsSummarized(Boolean.valueOf(atts.getValue("isSummarized")).booleanValue());
    m_PrintFormatItem.setImageIsAttached(Boolean.valueOf(atts.getValue("isImageIsAttached")).booleanValue());
    m_PrintFormatItem.setIsAveraged(Boolean.valueOf(atts.getValue("isAveraged")).booleanValue());
    m_PrintFormatItem.setIsCounted(Boolean.valueOf(atts.getValue("isCounted")).booleanValue());
    m_PrintFormatItem.setIsSetNLPosition(Boolean.valueOf(atts.getValue("isSetNLPosition")).booleanValue());
    m_PrintFormatItem.setIsSuppressNull(Boolean.valueOf(atts.getValue("isSuppressNull")).booleanValue());
    m_PrintFormatItem.setIsFixedWidth(Boolean.valueOf(atts.getValue("isFixedWidth")).booleanValue());
    m_PrintFormatItem.setIsNextPage(Boolean.valueOf(atts.getValue("isNextPage")).booleanValue());
    m_PrintFormatItem.setIsMaxCalc(Boolean.valueOf(atts.getValue("isMaxCalc")).booleanValue());
    m_PrintFormatItem.setIsMinCalc(Boolean.valueOf(atts.getValue("isMinCalc")).booleanValue());
    m_PrintFormatItem.setIsRunningTotal(Boolean.valueOf(atts.getValue("isRunningTotal")).booleanValue());
    m_PrintFormatItem.setIsVarianceCalc(Boolean.valueOf(atts.getValue("isVarianceCalc")).booleanValue());
    m_PrintFormatItem.setIsDeviationCalc(Boolean.valueOf(atts.getValue("isDeviationCalc")).booleanValue());
    // BarCode Type
    String barCodeType = atts.getValue(X_AD_PrintFormatItem.COLUMNNAME_BarcodeType);
    m_PrintFormatItem.setBarcodeType(barCodeType);
    if (m_PrintFormatItem.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_PrintFormatItem.getName(), "PrintFormatItem", m_PrintFormatItem.get_ID(), AD_Backup_ID, Object_Status, "AD_PrintFormatItem", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormatItem"));
    } else {
        record_log(ctx, 0, m_PrintFormatItem.getName(), "PrintFormatItem", m_PrintFormatItem.get_ID(), AD_Backup_ID, Object_Status, "AD_PrintFormatItem", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_PrintFormatItem"));
        throw new POSaveFailedException("PrintFormatItem");
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_PrintFormatItem(org.compiere.model.X_AD_PrintFormatItem)

Aggregations

POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)38 Attributes (org.xml.sax.Attributes)37 BigDecimal (java.math.BigDecimal)5 MTable (org.compiere.model.MTable)5 PackIn (org.adempiere.pipo.PackIn)4 X_AD_Element (org.compiere.model.X_AD_Element)4 PoFiller (org.adempiere.pipo.PoFiller)2 MWorkflow (org.compiere.wf.MWorkflow)2 AdempiereException (org.adempiere.exceptions.AdempiereException)1 MBrowse (org.adempiere.model.MBrowse)1 MBrowseField (org.adempiere.model.MBrowseField)1 MView (org.adempiere.model.MView)1 MViewColumn (org.adempiere.model.MViewColumn)1 MViewDefinition (org.adempiere.model.MViewDefinition)1 DatabaseAccessException (org.adempiere.pipo.exception.DatabaseAccessException)1 MColumn (org.compiere.model.MColumn)1 MEntityType (org.compiere.model.MEntityType)1 MField (org.compiere.model.MField)1 MForm (org.compiere.model.MForm)1 MMessage (org.compiere.model.MMessage)1