Search in sources :

Example 51 with PoFiller

use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.

the class ReferenceTableElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_Ref_Table.Table_Name);
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        if (isParentSkip(element, null)) {
            element.skip = true;
            return;
        }
        X_AD_Ref_Table refTable = findPO(ctx, element);
        if (refTable == null) {
            refTable = new X_AD_Ref_Table(ctx.ctx, 0, getTrxName(ctx));
        }
        String action = refTable.is_new() ? "New" : "Update";
        PoFiller filler = new PoFiller(ctx, refTable, element, this);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        Element displayElement = element.properties.get("AD_Display");
        int displayColumnId = ReferenceUtils.resolveReference(ctx.ctx, displayElement, getTrxName(ctx));
        refTable.setAD_Display(displayColumnId);
        Element keyElement = element.properties.get("AD_Key");
        int keyColumnId = ReferenceUtils.resolveReference(ctx.ctx, keyElement, getTrxName(ctx));
        refTable.setAD_Key(keyColumnId);
        if (refTable.is_new() || refTable.is_Changed()) {
            refTable.saveEx();
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Ref_Table.Table_Name, X_AD_Ref_Table.Table_ID);
            int AD_Reference_ID = refTable.getAD_Reference_ID();
            MReference adReference = new MReference(ctx.ctx, AD_Reference_ID, getTrxName(ctx));
            logImportDetail(ctx, impDetail, 1, adReference.getName(), refTable.getAD_Reference_ID(), action);
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) X_AD_Ref_Table(org.compiere.model.X_AD_Ref_Table) Element(org.adempiere.pipo2.Element) MReference(org.compiere.model.MReference) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

Example 52 with PoFiller

use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.

the class WorkflowNodeNextConditionElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_WF_NextCondition.Table_Name);
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        /* if (isParentSkip(element, null)) {
				element.skip = true;
				return;
			}*/
        MWFNextCondition mWFNodeNextCondition = findPO(ctx, element);
        if (mWFNodeNextCondition == null) {
            mWFNodeNextCondition = new MWFNextCondition(ctx.ctx, 0, getTrxName(ctx));
        }
        PoFiller filler = new PoFiller(ctx, mWFNodeNextCondition, element, this);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mWFNodeNextCondition.is_new() || mWFNodeNextCondition.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_WF_NextCondition.Table_Name, X_AD_WF_NextCondition.Table_ID);
            String action = null;
            if (!mWFNodeNextCondition.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_WF_NextCondition.Table_Name, mWFNodeNextCondition);
                action = "Update";
            } else {
                action = "New";
            }
            if (mWFNodeNextCondition.save(getTrxName(ctx)) == true) {
                log.info("m_WFNodeNextCondition save success");
                logImportDetail(ctx, impDetail, 1, String.valueOf(mWFNodeNextCondition.get_ID()), mWFNodeNextCondition.get_ID(), action);
            } else {
                log.info("m_WFNodeNextCondition save failure");
                logImportDetail(ctx, impDetail, 0, String.valueOf(mWFNodeNextCondition.get_ID()), mWFNodeNextCondition.get_ID(), action);
                throw new POSaveFailedException("Failed to save WorkflowNodeNextCondition");
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MWFNextCondition(org.compiere.wf.MWFNextCondition) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

Example 53 with PoFiller

use of org.adempiere.pipo2.PoFiller in project idempiere by idempiere.

the class WorkflowNodeNextElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(MWFNodeNext.Table_Name);
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        /*if (isParentSkip(element, null)) {
				element.skip = true;
				return;
			}*/
        MWFNodeNext mWFNodeNext = findPO(ctx, element);
        if (mWFNodeNext == null) {
            mWFNodeNext = new MWFNodeNext(ctx.ctx, 0, getTrxName(ctx));
        }
        PoFiller filler = new PoFiller(ctx, mWFNodeNext, element, this);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mWFNodeNext.is_new() || mWFNodeNext.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_WF_NodeNext.Table_Name, X_AD_WF_NodeNext.Table_ID);
            String action = null;
            if (!mWFNodeNext.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_WF_NodeNext.Table_Name, mWFNodeNext);
                action = "Update";
            } else {
                action = "New";
            }
            if (mWFNodeNext.save(getTrxName(ctx)) == true) {
                log.info("m_WFNodeNext save success");
                logImportDetail(ctx, impDetail, 1, String.valueOf(mWFNodeNext.get_ID()), mWFNodeNext.get_ID(), action);
            } else {
                log.info("m_WFNodeNext save failure");
                logImportDetail(ctx, impDetail, 0, String.valueOf(mWFNodeNext.get_ID()), mWFNodeNext.get_ID(), action);
                throw new POSaveFailedException("Failed to save WorkflowNodeNext");
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail) MWFNodeNext(org.compiere.wf.MWFNodeNext)

Aggregations

PoFiller (org.adempiere.pipo2.PoFiller)53 X_AD_Package_Imp_Detail (org.compiere.model.X_AD_Package_Imp_Detail)45 POSaveFailedException (org.adempiere.pipo2.exception.POSaveFailedException)42 Element (org.adempiere.pipo2.Element)4 MReference (org.compiere.model.MReference)2 MTable (org.compiere.model.MTable)2 MWorkflow (org.compiere.wf.MWorkflow)2 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 SQLException (java.sql.SQLException)1 DBException (org.adempiere.exceptions.DBException)1 GenericPO (org.adempiere.model.GenericPO)1 PackIn (org.adempiere.pipo2.PackIn)1 MAttachment (org.compiere.model.MAttachment)1 MColumn (org.compiere.model.MColumn)1 MField (org.compiere.model.MField)1 MForm (org.compiere.model.MForm)1 MFormAccess (org.compiere.model.MFormAccess)1 MIndexColumn (org.compiere.model.MIndexColumn)1