Search in sources :

Example 1 with X_AD_Process_Para

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

the class ProcessParaElementHandler 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)) {
        if (element.parent != null && element.parent.getElementValue().equals("process") && element.parent.defer) {
            element.defer = true;
            return;
        }
        String name = atts.getValue("Name");
        int id = 0;
        int masterId = 0;
        String processValue = "";
        if (element.parent != null && element.parent.getElementValue().equals("process") && element.parent.recordId > 0) {
            masterId = element.parent.recordId;
        } else {
            processValue = atts.getValue("ADProcessValueID");
            if (processValue != null && processValue.trim().length() > 0) {
                masterId = get_IDWithColumn(ctx, "AD_Process", "Value", processValue);
            } else {
                //for backward compatibility
                processValue = atts.getValue("ADProcessNameID");
                masterId = get_IDWithColumn(ctx, "AD_Process", "Name", processValue);
            }
        }
        if (masterId <= 0) {
            element.defer = true;
            element.unresolved = "AD_Process: " + processValue;
            return;
        }
        id = get_IDWithMasterAndColumn(ctx, "AD_Process_Para", "Name", name, "AD_Process", masterId);
        X_AD_Process_Para m_Process_para = new X_AD_Process_Para(ctx, id, getTrxName(ctx));
        int AD_Backup_ID = -1;
        String Object_Status = null;
        if (id <= 0 && atts.getValue("AD_Process_Para_ID") != null && Integer.parseInt(atts.getValue("AD_Process_Para_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Process_para.setAD_Process_Para_ID(Integer.parseInt(atts.getValue("AD_Process_Para_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Process_Para", m_Process_para);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Process_para.setName(atts.getValue("Name"));
        m_Process_para.setAD_Process_ID(masterId);
        m_Process_para.setColumnName(atts.getValue("ColumnName"));
        m_Process_para.setEntityType(atts.getValue("EntityType"));
        name = atts.getValue("ADElementNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", name);
            if (id <= 0) /** Check Packout version - 005 */
            {
                id = get_IDWithColumn(ctx, "AD_Element", "Name", name);
            }
            // Setup Element
            X_AD_Element adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
            if (adElement.getAD_Element_ID() == 0) {
                String columnName = m_Process_para.getColumnName();
                id = get_IDWithColumn(ctx, "AD_Element", "ColumnName", columnName);
                if (id > 0) {
                    adElement = new X_AD_Element(ctx, id, getTrxName(ctx));
                } else {
                    adElement.setColumnName(columnName);
                    adElement.setEntityType(m_Process_para.getEntityType());
                    adElement.setPrintName(name);
                    adElement.setName(m_Process_para.getName());
                    if (adElement.save(getTrxName(ctx)) == true) {
                        record_log(ctx, 1, m_Process_para.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_Process_para.getName(), "Element", adElement.getAD_Element_ID(), AD_Backup_ID, "New", "AD_Element", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Element"));
                    }
                }
            }
            m_Process_para.setAD_Element_ID(adElement.getAD_Element_ID());
        }
        name = atts.getValue("ADReferenceNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Reference", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_Reference: " + name;
                return;
            }
            m_Process_para.setAD_Reference_ID(id);
        }
        name = atts.getValue("ADReferenceValueNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Reference", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_Reference: " + name;
                return;
            }
            m_Process_para.setAD_Reference_Value_ID(id);
        }
        name = atts.getValue("ADValRuleNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Val_Rule", "Name", name);
            if (id <= 0) {
                element.defer = true;
                element.unresolved = "AD_Val_Rule: " + name;
                return;
            }
            m_Process_para.setAD_Val_Rule_ID(id);
        }
        m_Process_para.setDefaultValue(getStringValue(atts, "DefaultValue"));
        m_Process_para.setDefaultValue2(getStringValue(atts, "DefaultValue2"));
        m_Process_para.setDescription(getStringValue(atts, "Description"));
        m_Process_para.setHelp(getStringValue(atts, "Help"));
        m_Process_para.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Process_para.setReadOnlyLogic(getStringValue(atts, "ReadOnlyLogic"));
        m_Process_para.setDisplayLogic(getStringValue(atts, "DisplayLogic"));
        m_Process_para.setVFormat(getStringValue(atts, "VFormat"));
        m_Process_para.setValueMax(getStringValue(atts, "ValueMax"));
        m_Process_para.setValueMin(getStringValue(atts, "ValueMin"));
        m_Process_para.setSeqNo(Integer.parseInt(atts.getValue("SeqNo")));
        m_Process_para.setFieldLength(Integer.parseInt(atts.getValue("FieldLength")));
        m_Process_para.setIsCentrallyMaintained(Boolean.valueOf(atts.getValue("isCentrallyMaintained")).booleanValue());
        m_Process_para.setIsMandatory(Boolean.valueOf(atts.getValue("isMandatory")).booleanValue());
        m_Process_para.setIsRange(Boolean.valueOf(atts.getValue("isRange")).booleanValue());
        if (m_Process_para.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Process_para.getName(), "Process_para", m_Process_para.get_ID(), AD_Backup_ID, Object_Status, "AD_Process_para", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process_para"));
        } else {
            record_log(ctx, 0, m_Process_para.getName(), "Process_para", m_Process_para.get_ID(), AD_Backup_ID, Object_Status, "AD_Process_para", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Process_para"));
            throw new POSaveFailedException("ProcessPara");
        }
    } else {
        element.skip = true;
    }
}
Also used : X_AD_Process_Para(org.compiere.model.X_AD_Process_Para) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Element(org.compiere.model.X_AD_Element)

Example 2 with X_AD_Process_Para

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

the class ProcessParaElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Process_Para_ID = Env.getContextAsInt(ctx, X_AD_Process_Para.COLUMNNAME_AD_Process_Para_ID);
    X_AD_Process_Para m_Processpara = new X_AD_Process_Para(ctx, AD_Process_Para_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createProcessParaBinding(atts, m_Processpara);
    document.startElement("", "", "processpara", atts);
    document.endElement("", "", "processpara");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Process_Para(org.compiere.model.X_AD_Process_Para)

Aggregations

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