Search in sources :

Example 31 with POSaveFailedException

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

the class DynValRuleElementHandler 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"));
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String name = atts.getValue("Name");
        int id = get_IDWithColumn(ctx, "AD_Val_Rule", "name", name);
        X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Val_Rule_ID") != null && Integer.parseInt(atts.getValue("AD_Val_Rule_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_ValRule.setAD_Val_Rule_ID(Integer.parseInt(atts.getValue("AD_Val_Rule_ID")));
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Val_Rule", m_ValRule);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_ValRule.setDescription(getStringValue(atts, "Description"));
        m_ValRule.setEntityType(atts.getValue("EntityType"));
        m_ValRule.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_ValRule.setName(name);
        m_ValRule.setType(atts.getValue("Type"));
        m_ValRule.setCode(atts.getValue("Code"));
        if (m_ValRule.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_ValRule.getName(), "ValRule", m_ValRule.get_ID(), AD_Backup_ID, Object_Status, "AD_Val_Rule", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
        } else {
            record_log(ctx, 0, m_ValRule.getName(), "ValRule", m_ValRule.get_ID(), AD_Backup_ID, Object_Status, "AD_Val_Rule", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Val_Rule"));
            throw new POSaveFailedException("Failed to save dynamic validation rule.");
        }
    } else {
        element.skip = true;
    }
}
Also used : X_AD_Val_Rule(org.compiere.model.X_AD_Val_Rule) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 32 with POSaveFailedException

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

the class FormElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("ADFormNameID"));
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String name = atts.getValue("ADFormNameID");
        int id = get_ID(ctx, "AD_Form", name);
        MForm m_Form = new MForm(ctx, id, getTrxName(ctx));
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id <= 0 && atts.getValue("AD_Form_ID") != null && Integer.parseInt(atts.getValue("AD_Form_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Form.setAD_Form_ID(Integer.parseInt(atts.getValue("AD_Form_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Form", m_Form);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Form.setClassname(atts.getValue("Classname"));
        m_Form.setIsBetaFunctionality(Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
        m_Form.setAccessLevel(atts.getValue("AccessLevel"));
        m_Form.setDescription(getStringValue(atts, "Description"));
        m_Form.setEntityType(atts.getValue("EntityType"));
        m_Form.setHelp(getStringValue(atts, "Help"));
        m_Form.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Form.setName(atts.getValue("Name"));
        if (m_Form.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Form.getName(), "Form", m_Form.get_ID(), AD_Backup_ID, Object_Status, "AD_Form", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
        } else {
            record_log(ctx, 0, m_Form.getName(), "Form", m_Form.get_ID(), AD_Backup_ID, Object_Status, "AD_Form", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Form"));
            throw new POSaveFailedException("Failed to save form definition");
        }
    } else {
        element.skip = true;
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) MForm(org.compiere.model.MForm)

Example 33 with POSaveFailedException

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

the class MessageElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Value"));
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String value = atts.getValue("Value");
        int id = get_IDWithColumn(ctx, "AD_Message", "value", value);
        MMessage m_Message = new MMessage(ctx, id, getTrxName(ctx));
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id <= 0 && atts.getValue("AD_Message_ID") != null && Integer.parseInt(atts.getValue("AD_Message_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Message.setAD_Message_ID(Integer.parseInt(atts.getValue("AD_Message_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Message", m_Message);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Message.setMsgText(getStringValue(atts, "MsgText"));
        m_Message.setMsgTip(getStringValue(atts, "MsgTip"));
        m_Message.setEntityType(atts.getValue("EntityType"));
        m_Message.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Message.setValue(value);
        m_Message.setMsgType(atts.getValue("MsgType"));
        if (m_Message.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Message.getValue(), "Message", m_Message.get_ID(), AD_Backup_ID, Object_Status, "AD_Message", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
        } else {
            record_log(ctx, 0, m_Message.getValue(), "Message", m_Message.get_ID(), AD_Backup_ID, Object_Status, "AD_Message", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Message"));
            throw new POSaveFailedException("Failed to save message.");
        }
    } else {
        element.skip = true;
    }
}
Also used : MMessage(org.compiere.model.MMessage) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 34 with POSaveFailedException

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

the class ModelValidatorElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue(I_AD_ModelValidator.COLUMNNAME_Name));
    String entitytype = atts.getValue(I_AD_ModelValidator.COLUMNNAME_EntityType);
    if (isProcessElement(ctx, entitytype)) {
        String name = atts.getValue(I_AD_ModelValidator.COLUMNNAME_Name);
        int id = get_IDWithColumn(ctx, I_AD_ModelValidator.Table_Name, I_AD_ModelValidator.COLUMNNAME_Name, name);
        final X_AD_ModelValidator validator = new X_AD_ModelValidator(ctx, id, getTrxName(ctx));
        final int AD_Backup_ID;
        final String Object_Status;
        if (id <= 0 && getIntValue(atts, I_AD_ModelValidator.COLUMNNAME_AD_ModelValidator_ID, 0) <= PackOut.MAX_OFFICIAL_ID) {
            validator.setAD_ModelValidator_ID(getIntValue(atts, I_AD_ModelValidator.COLUMNNAME_AD_ModelValidator_ID, 0));
        }
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, I_AD_ModelValidator.Table_Name, validator);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        validator.setName(name);
        validator.setDescription(getStringValue(atts, I_AD_ModelValidator.COLUMNNAME_Description));
        validator.setHelp(getStringValue(atts, I_AD_ModelValidator.COLUMNNAME_Help));
        validator.setEntityType(atts.getValue(I_AD_ModelValidator.COLUMNNAME_EntityType));
        validator.setModelValidationClass(atts.getValue(I_AD_ModelValidator.COLUMNNAME_ModelValidationClass));
        validator.setIsActive(getBooleanValue(atts, I_AD_ModelValidator.COLUMNNAME_IsActive, true));
        validator.setSeqNo(getIntValue(atts, I_AD_ModelValidator.COLUMNNAME_SeqNo, 0));
        if (validator.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, validator.getName(), TAG_Name, validator.get_ID(), AD_Backup_ID, Object_Status, I_AD_ModelValidator.Table_Name, I_AD_ModelValidator.Table_ID);
        } else {
            record_log(ctx, 0, validator.getName(), TAG_Name, validator.get_ID(), AD_Backup_ID, Object_Status, I_AD_ModelValidator.Table_Name, I_AD_ModelValidator.Table_ID);
            throw new POSaveFailedException("Failed to save message.");
        }
    } else {
        element.skip = true;
    }
}
Also used : X_AD_ModelValidator(org.compiere.model.X_AD_ModelValidator) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 35 with POSaveFailedException

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

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