Search in sources :

Example 1 with X_AD_Ref_List

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

the class ReferenceListElementHandler 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"));
    // TODO: Solve for date issues with valuefrom valueto
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        if (element.parent != null && element.parent.skip) {
            element.skip = true;
            return;
        }
        String name = atts.getValue("Name");
        String value = atts.getValue("Value");
        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 {
            AD_Reference_ID = get_IDWithColumn(ctx, "AD_Reference", "Name", atts.getValue("ADRefenceNameID"));
        }
        int AD_Ref_List_ID = get_IDWithMasterAndColumn(ctx, "AD_Ref_List", "Value", value, "AD_Reference", AD_Reference_ID);
        X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID, getTrxName(ctx));
        if (AD_Ref_List_ID <= 0 && atts.getValue("AD_Ref_List_ID") != null && Integer.parseInt(atts.getValue("AD_Ref_List_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Ref_List.setAD_Ref_List_ID(Integer.parseInt(atts.getValue("AD_Ref_List_ID")));
        if (AD_Ref_List_ID > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Ref_List", m_Ref_List);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Ref_List.setAD_Reference_ID(AD_Reference_ID);
        m_Ref_List.setDescription(getStringValue(atts, "Description"));
        m_Ref_List.setEntityType(atts.getValue("EntityType"));
        m_Ref_List.setName(atts.getValue("Name"));
        m_Ref_List.setValue(value);
        m_Ref_List.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        if (m_Ref_List.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Ref_List.getName(), "Reference List", m_Ref_List.get_ID(), AD_Backup_ID, Object_Status, "AD_Ref_List", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_List"));
        } else {
            record_log(ctx, 0, m_Ref_List.getName(), "Reference List", m_Ref_List.get_ID(), AD_Backup_ID, Object_Status, "AD_Ref_List", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Ref_List"));
            throw new POSaveFailedException("ReferenceList");
        }
    } else {
        element.skip = true;
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) X_AD_Ref_List(org.compiere.model.X_AD_Ref_List)

Example 2 with X_AD_Ref_List

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

the class ReferenceListElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_Ref_List_ID = Env.getContextAsInt(ctx, X_AD_Ref_List.COLUMNNAME_AD_Ref_List_ID);
    X_AD_Ref_List m_Ref_List = new X_AD_Ref_List(ctx, AD_Ref_List_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createRefListBinding(atts, m_Ref_List);
    document.startElement("", "", "referencelist", atts);
    document.endElement("", "", "referencelist");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_Ref_List(org.compiere.model.X_AD_Ref_List)

Aggregations

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