Search in sources :

Example 1 with X_AD_ModelValidator

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

the class ModelValidatorElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    final int AD_ModelValidator_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_ModelValidator_ID);
    if (validators.contains(AD_ModelValidator_ID))
        return;
    validators.add(AD_ModelValidator_ID);
    final X_AD_ModelValidator validator = new X_AD_ModelValidator(ctx, AD_ModelValidator_ID, null);
    AttributesImpl atts = new AttributesImpl();
    createMessageBinding(atts, validator);
    document.startElement("", "", TAG_Name, atts);
    document.endElement("", "", TAG_Name);
}
Also used : X_AD_ModelValidator(org.compiere.model.X_AD_ModelValidator) AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 2 with X_AD_ModelValidator

use of org.compiere.model.X_AD_ModelValidator 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)

Aggregations

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