Search in sources :

Example 1 with PoFiller

use of org.adempiere.pipo.PoFiller in project adempiere by adempiere.

the class FieldGroupElementHandler 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_IDWithColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
        X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_FieldGroup_ID") != null && Integer.parseInt(atts.getValue("AD_FieldGroup_ID")) <= PackOut.MAX_OFFICIAL_ID)
            fieldGroup.setAD_FieldGroup_ID(Integer.parseInt(atts.getValue("AD_FieldGroup_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, X_AD_FieldGroup.Table_Name, fieldGroup);
            Object_Status = "Update";
            if (processedFieldGroups.contains(id)) {
                element.skip = true;
                return;
            }
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        PoFiller pf = new PoFiller(fieldGroup, atts);
        pf.setBoolean(X_AD_FieldGroup.COLUMNNAME_IsActive);
        pf.setString(X_AD_FieldGroup.COLUMNNAME_Name);
        pf.setString(X_AD_FieldGroup.COLUMNNAME_EntityType);
        pf.setString(X_AD_FieldGroup.COLUMNNAME_FieldGroupType);
        pf.setBoolean(X_AD_FieldGroup.COLUMNNAME_IsCollapsedByDefault);
        if (fieldGroup.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, fieldGroup.getName(), "FieldGroup", fieldGroup.get_ID(), AD_Backup_ID, Object_Status, X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table", "TableName", X_AD_FieldGroup.Table_Name));
            element.recordId = fieldGroup.getAD_FieldGroup_ID();
            processedFieldGroups.add(fieldGroup.getAD_FieldGroup_ID());
        } else {
            record_log(ctx, 0, fieldGroup.getName(), "FieldGroup", fieldGroup.get_ID(), AD_Backup_ID, Object_Status, X_AD_FieldGroup.Table_Name, get_IDWithColumn(ctx, "AD_Table", "TableName", X_AD_FieldGroup.Table_Name));
            throw new POSaveFailedException("Reference");
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo.PoFiller) X_AD_FieldGroup(org.compiere.model.X_AD_FieldGroup) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 2 with PoFiller

use of org.adempiere.pipo.PoFiller 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)

Aggregations

PoFiller (org.adempiere.pipo.PoFiller)2 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)2 Attributes (org.xml.sax.Attributes)2 X_AD_Element (org.compiere.model.X_AD_Element)1 X_AD_FieldGroup (org.compiere.model.X_AD_FieldGroup)1