Search in sources :

Example 16 with POSaveFailedException

use of org.adempiere.pipo.exception.POSaveFailedException 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 17 with POSaveFailedException

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

the class PrintPaperElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    final String elementValue = element.getElementValue();
    final Attributes atts = element.attributes;
    final String strIdentifier = atts.getValue(getIdentifierColumnName());
    final int id = get_IDWithColumn(ctx, getTableName(), getIdentifierColumnName(), strIdentifier);
    final PO po = getCreatePO(ctx, id, getTrxName(ctx));
    final String keyColumnName = getKeyColumnName();
    log.info(elementValue + " " + strIdentifier + "[" + id + "]");
    if (id <= 0 && keyColumnName != null && getIntValue(atts, keyColumnName, 0) <= PackOut.MAX_OFFICIAL_ID) {
        po.set_ValueOfColumn(keyColumnName, getIntValue(atts, keyColumnName, 0));
    }
    final int AD_Backup_ID;
    final String Object_Status;
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, getTableName(), po);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    for (String attributeName : getAttributeNames()) {
        loadAttribute(atts, attributeName, po);
    }
    if (po.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, strIdentifier, getTagName(), po.get_ID(), AD_Backup_ID, Object_Status, getTableName(), getTable_ID());
    } else {
        record_log(ctx, 0, strIdentifier, getTagName(), po.get_ID(), AD_Backup_ID, Object_Status, getTableName(), getTable_ID());
        throw new POSaveFailedException("Failed to save message.");
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) PO(org.compiere.model.PO)

Example 18 with POSaveFailedException

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

the class ProcessElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Name"));
    int id = 0;
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String value = atts.getValue("Value");
        // Get New process.
        id = get_IDWithColumn(ctx, "AD_Process", "Value", value);
        X_AD_Process m_Process = null;
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id > 0) {
            m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
            AD_Backup_ID = copyRecord(ctx, "AD_Process", m_Process);
            Object_Status = "Update";
        } else {
            m_Process = new X_AD_Process(ctx, id, getTrxName(ctx));
            if (id <= 0 && atts.getValue("AD_Process_ID") != null && Integer.parseInt(atts.getValue("AD_Process_ID")) <= PackOut.MAX_OFFICIAL_ID)
                m_Process.setAD_Process_ID(Integer.parseInt(atts.getValue("AD_Process_ID")));
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        String name = atts.getValue("Name");
        m_Process.setName(name);
        name = atts.getValue("ADWorkflowNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Workflow", "Name", name);
            if (id <= 0) {
                if (element.pass == 1) {
                    element.defer = true;
                    element.unresolved = "AD_Workflow: " + name;
                    return;
                } else {
                    log.warning("AD_Workflow: " + name + " not found for Workflow: " + name);
                }
            }
            if (id > 0)
                m_Process.setAD_Workflow_ID(id);
        }
        name = atts.getValue("ADPrintFormatNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_PrintFormat", "Name", name);
            if (id <= 0) {
                if (element.pass == 1) {
                    element.defer = true;
                    element.unresolved = "AD_PrintFormat: " + name;
                    return;
                } else {
                    log.warning("AD_PrintFormat: " + name + " not found for Process: " + m_Process.getName());
                }
            }
            if (id > 0)
                m_Process.setAD_PrintFormat_ID(id);
        }
        name = atts.getValue("ADReportViewNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
            if (id <= 0) {
                if (element.pass == 1) {
                    element.defer = true;
                    element.unresolved = "AD_ReportView: " + name;
                    return;
                } else {
                    log.warning("AD_ReportView: " + name + " not found for Process: " + m_Process.getName());
                }
            }
            if (id > 0)
                m_Process.setAD_ReportView_ID(id);
        }
        name = atts.getValue("ADFormNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Form", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_Form: " + name;
                return;
            }
            m_Process.setAD_Form_ID(id);
        }
        name = atts.getValue("ADBrowseNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Browse", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_Browse: " + name;
                return;
            }
            m_Process.setAD_Browse_ID(id);
        }
        m_Process.setAccessLevel(atts.getValue("AccessLevel"));
        m_Process.setClassname(getStringValue(atts, "Classname"));
        m_Process.setDescription(getStringValue(atts, "Description"));
        m_Process.setEntityType(atts.getValue("EntityType"));
        m_Process.setHelp(getStringValue(atts, "Help"));
        m_Process.setIsBetaFunctionality(Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
        m_Process.setIsDirectPrint(Boolean.valueOf(atts.getValue("isDirectPrint")).booleanValue());
        m_Process.setIsReport(Boolean.valueOf(atts.getValue("isReport")).booleanValue());
        m_Process.setName(atts.getValue("Name"));
        m_Process.setProcedureName(getStringValue(atts, "ProcedureName"));
        m_Process.setStatistic_Count(0);
        m_Process.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Process.setStatistic_Seconds(0);
        m_Process.setValue(atts.getValue("Value"));
        m_Process.setWorkflowValue(atts.getValue("WorkflowValue"));
        m_Process.setShowHelp((getStringValue(atts, "ShowHelp")));
        m_Process.setJasperReport(getStringValue(atts, "JasperReport"));
        if (m_Process.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Process.getName(), "Process", m_Process.get_ID(), AD_Backup_ID, Object_Status, "AD_Process", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
            element.recordId = m_Process.getAD_Process_ID();
        } else {
            record_log(ctx, 0, m_Process.getName(), "Process", m_Process.get_ID(), AD_Backup_ID, Object_Status, "AD_Process", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process"));
            throw new POSaveFailedException("Process");
        }
    } else {
        element.skip = true;
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Process(org.compiere.model.X_AD_Process)

Example 19 with POSaveFailedException

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

the class PreferenceElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    log.info(elementValue);
    // TODO Add User_ID
    Attributes atts = element.attributes;
    int windowid = get_ID(ctx, "AD_Window", atts.getValue("ADWindowNameID"));
    if (windowid <= 0) {
        element.defer = true;
        return;
    }
    StringBuffer sqlB = new StringBuffer("select AD_Preference_ID from AD_Preference where ").append(" Attribute = '" + atts.getValue("Attribute") + "'").append(" and AD_Window_ID = ?");
    int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), windowid);
    MPreference m_Preference = new MPreference(ctx, id, getTrxName(ctx));
    int AD_Backup_ID = -1;
    String Object_Status = null;
    if (id <= 0 && atts.getValue("AD_Preference_ID") != null && Integer.parseInt(atts.getValue("AD_Preference_ID")) <= PackOut.MAX_OFFICIAL_ID)
        m_Preference.setAD_Preference_ID(Integer.parseInt(atts.getValue("AD_Preference_ID")));
    if (id > 0) {
        AD_Backup_ID = copyRecord(ctx, "AD_Preference", m_Preference);
        Object_Status = "Update";
    } else {
        Object_Status = "New";
        AD_Backup_ID = 0;
    }
    sqlB = null;
    m_Preference.setAD_Window_ID(windowid);
    m_Preference.setAttribute(atts.getValue("Attribute"));
    m_Preference.setValue(atts.getValue("Value"));
    if (m_Preference.save(getTrxName(ctx)) == true) {
        record_log(ctx, 1, m_Preference.getAttribute(), "Preference", m_Preference.get_ID(), AD_Backup_ID, Object_Status, "AD_Preference", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Preference"));
    } else {
        record_log(ctx, 0, m_Preference.getAttribute(), "Preference", m_Preference.get_ID(), AD_Backup_ID, Object_Status, "AD_Preference", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Preference"));
        throw new POSaveFailedException("Failed to save Preference");
    }
}
Also used : MPreference(org.compiere.model.MPreference) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 20 with POSaveFailedException

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

the class ReferenceTableElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    log.info(elementValue);
    Attributes atts = element.attributes;
    String entitytype = atts.getValue("EntityType");
    String name = atts.getValue("ADRefenceNameID");
    if (isProcessElement(ctx, entitytype)) {
        if (element.parent != null && element.parent.skip) {
            element.skip = true;
            return;
        }
        int AD_Reference_ID = 0;
        if (element.parent != null && element.parent.getElementValue().equals("reference") && element.parent.recordId > 0) {
            AD_Reference_ID = element.parent.recordId;
        } else {
            StringBuffer sqlB = new StringBuffer("SELECT AD_Reference_ID FROM AD_Reference WHERE Name= ?");
            AD_Reference_ID = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), name);
        }
        if (AD_Reference_ID <= 0 && atts.getValue("AD_Reference_ID") != null && Integer.parseInt(atts.getValue("AD_Reference_ID")) <= PackOut.MAX_OFFICIAL_ID)
            AD_Reference_ID = Integer.parseInt(atts.getValue("AD_Reference_ID"));
        int tableId = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
        if (tableId == 0) {
            MTable m_Table = new MTable(ctx, 0, getTrxName(ctx));
            m_Table.setAccessLevel("3");
            m_Table.setName(atts.getValue("ADTableNameID"));
            m_Table.setTableName(atts.getValue("ADTableNameID"));
            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"));
            }
            tableId = get_IDWithColumn(ctx, "AD_Table", "TableName", atts.getValue("ADTableNameID"));
        }
        name = atts.getValue("Key");
        int keyId = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", name, "AD_Table", tableId);
        if (keyId == 0)
            throw new AdempiereException("@AD_Column_ID@:" + name + "@NotFound@");
        int displayId = 0;
        name = atts.getValue("ADDisplay");
        displayId = get_IDWithMasterAndColumn(ctx, "AD_Column", "ColumnName", name, "AD_Table", tableId);
        String isDisplayIdentifier = atts.getValue("IsDisplayIdentifier");
        String isAlert = atts.getValue("IsAlert");
        String entityType = atts.getValue("EntityType");
        String isValueDisplayed = atts.getValue("IsValueDisplayed");
        String OrderByClause = "";
        String WhereClause = "";
        String displaySQL = "";
        if (DB.isOracle()) {
            OrderByClause = atts.getValue("OrderByClause");
            WhereClause = atts.getValue("WhereClause");
            displaySQL = atts.getValue("DisplaySQL");
        } else if (DB.isPostgreSQL()) {
            OrderByClause = atts.getValue("OrderByClause").replaceAll("''", "'");
            WhereClause = atts.getValue("WhereClause").replaceAll("''", "'");
            displaySQL = atts.getValue("DisplaySQL").replaceAll("''", "'");
            ;
        }
        MRefTable refTable = new Query(ctx, I_AD_Ref_Table.Table_Name, COLUMNNAME_AD_Reference_ID + "=?", getTrxName(ctx)).setParameters(AD_Reference_ID).firstOnly();
        if (refTable != null) {
            refTable.setAD_Table_ID(tableId);
            refTable.setAD_Display(displayId);
            refTable.setAD_Key(keyId);
            refTable.setIsValueDisplayed(isValueDisplayed.equals("Y"));
            refTable.setIsDisplayIdentifier(isDisplayIdentifier.equals("Y"));
            refTable.setIsAlert(isAlert.equals("Y"));
            refTable.setDisplaySQL(displaySQL);
            refTable.setOrderByClause(OrderByClause);
            refTable.setEntityType(entityType);
            refTable.setWhereClause(WhereClause);
            refTable.saveEx();
            if (refTable != null) {
                record_log(ctx, 1, atts.getValue("ADRefenceNameID"), "Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_Table"));
            } else {
                record_log(ctx, 0, atts.getValue("ADRefenceNameID"), "Reference Table", AD_Reference_ID, 0, "Update", "AD_Ref_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_Table"));
                throw new POSaveFailedException("ReferenceTable");
            }
        } else {
            refTable = new MRefTable(ctx, 0, getTrxName(ctx));
            refTable.setAD_Reference_ID(AD_Reference_ID);
            refTable.setAD_Table_ID(tableId);
            refTable.setAD_Display(displayId);
            refTable.setAD_Key(keyId);
            refTable.setIsValueDisplayed(isValueDisplayed.equals("Y"));
            refTable.setIsDisplayIdentifier(isDisplayIdentifier.equals("Y"));
            refTable.setIsAlert(isAlert.equals("Y"));
            refTable.setDisplaySQL(displaySQL);
            refTable.setOrderByClause(OrderByClause);
            refTable.setEntityType(entityType);
            refTable.setWhereClause(WhereClause);
            if (refTable.save())
                record_log(ctx, 1, atts.getValue("ADRefenceNameID"), "Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_Table"));
            else {
                record_log(ctx, 0, atts.getValue("ADRefenceNameID"), "Reference Table", AD_Reference_ID, 0, "New", "AD_Ref_Table", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_Table"));
                throw new POSaveFailedException("ReferenceTable");
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : MTable(org.compiere.model.MTable) Query(org.compiere.model.Query) AdempiereException(org.adempiere.exceptions.AdempiereException) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) MRefTable(org.compiere.model.MRefTable)

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