Search in sources :

Example 1 with X_AD_ReportView_Col

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

the class ReportViewColElementHandler 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("ADReportViewColID"));
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String name = atts.getValue("ADReportviewNameID");
        int AD_ReportView_ID = 0;
        if (element.parent != null && element.parent.getElementValue().equals("reportview") && element.parent.recordId > 0) {
            AD_ReportView_ID = element.parent.recordId;
        } else {
            AD_ReportView_ID = get_IDWithColumn(ctx, "AD_ReportView", "Name", name);
        }
        if (AD_ReportView_ID <= 0) {
            element.defer = true;
            return;
        }
        name = atts.getValue("ADColumnNameID");
        int AD_Column_ID = 0;
        if (name != null && name.trim().length() > 0) {
            AD_Column_ID = get_IDWithColumn(ctx, "AD_Column", "Name", name);
            if (AD_Column_ID <= 0) {
                element.defer = true;
                return;
            }
        }
        String functionColumn = getStringValue(atts, "FunctionColumn");
        StringBuffer sql = new StringBuffer("SELECT AD_Reportview_Col_ID FROM AD_Reportview_Col ").append(" WHERE AD_Column_ID ");
        if (AD_Column_ID > 0)
            sql.append(" = " + AD_Column_ID);
        else
            sql.append(" IS NULL ");
        sql.append(" AND FunctionColumn = ?");
        int id = DB.getSQLValue(getTrxName(ctx), sql.toString(), functionColumn);
        if (id < 0)
            id = 0;
        X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_ReportView_Col_ID") != null && Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Reportview_Col.setAD_ReportView_Col_ID(Integer.parseInt(atts.getValue("AD_ReportView_Col_ID")));
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Reportview_Col", m_Reportview_Col);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        boolean isGroupFunction = Boolean.valueOf(atts.getValue("isGroupFunction")).booleanValue();
        m_Reportview_Col.setAD_ReportView_ID(AD_ReportView_ID);
        if (AD_Column_ID > 0) {
            m_Reportview_Col.setAD_Column_ID(id);
        }
        m_Reportview_Col.setFunctionColumn(functionColumn);
        m_Reportview_Col.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Reportview_Col.setIsGroupFunction(isGroupFunction);
        if (m_Reportview_Col.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, "" + m_Reportview_Col.getAD_ReportView_ID(), "Reportview_Col", m_Reportview_Col.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview_Col", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview_Col"));
        } else {
            record_log(ctx, 0, "" + m_Reportview_Col.getAD_ReportView_ID(), "Reportview_Col", m_Reportview_Col.get_ID(), AD_Backup_ID, Object_Status, "AD_Reportview_Col", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Reportview_Col"));
            throw new POSaveFailedException("ReportViewCol");
        }
    } else {
        element.skip = true;
    }
}
Also used : X_AD_ReportView_Col(org.compiere.model.X_AD_ReportView_Col) Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException)

Example 2 with X_AD_ReportView_Col

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

the class ReportViewColElementHandler method create.

public void create(Properties ctx, TransformerHandler document) throws SAXException {
    int AD_ReportView_Col_ID = Env.getContextAsInt(ctx, X_AD_ReportView_Col.COLUMNNAME_AD_ReportView_Col_ID);
    X_AD_ReportView_Col m_Reportview_Col = new X_AD_ReportView_Col(ctx, AD_ReportView_Col_ID, getTrxName(ctx));
    AttributesImpl atts = new AttributesImpl();
    createReportViewColBinding(atts, m_Reportview_Col);
    document.startElement("", "", "reportviewcol", atts);
    document.endElement("", "", "reportviewcol");
}
Also used : AttributesImpl(org.xml.sax.helpers.AttributesImpl) X_AD_ReportView_Col(org.compiere.model.X_AD_ReportView_Col)

Aggregations

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