Search in sources :

Example 6 with PoFiller

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

the class ReferenceElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        MReference mReference = findPO(ctx, element);
        if (mReference == null) {
            mReference = new MReference(ctx.ctx, 0, getTrxName(ctx));
        }
        List<String> excludes = defaultExcludeList(MReference.Table_Name);
        PoFiller filler = new PoFiller(ctx, mReference, element, this);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        element.recordId = mReference.getAD_Reference_ID();
        if (mReference.is_new() || mReference.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MReference.Table_Name, MReference.Table_ID);
            String action = null;
            if (!mReference.is_new()) {
                if (references.contains(mReference.getAD_Reference_ID())) {
                    element.skip = true;
                    return;
                }
                backupRecord(ctx, impDetail.getAD_Package_Imp_ID(), MReference.Table_Name, mReference);
                action = "Update";
            } else {
                action = "New";
            }
            if (mReference.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mReference.getName(), mReference.get_ID(), action);
                references.add(mReference.getAD_Reference_ID());
                element.recordId = mReference.getAD_Reference_ID();
            } else {
                logImportDetail(ctx, impDetail, 0, mReference.getName(), mReference.get_ID(), action);
                throw new POSaveFailedException("Failed to save Reference " + mReference.getName());
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) MReference(org.compiere.model.MReference) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

Example 7 with PoFiller

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

the class TableIndexElementHandler method startElement.

@Override
public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        MTableIndex mTableIndex = findPO(ctx, element);
        if (mTableIndex == null) {
            mTableIndex = new MTableIndex(ctx.ctx, 0, getTrxName(ctx));
        }
        PoFiller filler = new PoFiller(ctx, mTableIndex, element, this);
        List<String> excludes = defaultExcludeList(MTableIndex.Table_Name);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mTableIndex.is_new() || mTableIndex.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MTableIndex.Table_Name, MTableIndex.Table_ID);
            String action = null;
            if (!mTableIndex.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), MTableIndex.Table_Name, mTableIndex);
                action = "Update";
            } else {
                action = "New";
            }
            if (mTableIndex.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mTableIndex.getName(), mTableIndex.get_ID(), action);
                element.recordId = mTableIndex.getAD_TableIndex_ID();
            } else {
                logImportDetail(ctx, impDetail, 0, mTableIndex.getName(), mTableIndex.get_ID(), action);
                throw new POSaveFailedException("Failed to save AD_TableIndex " + mTableIndex.getName());
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MTableIndex(org.compiere.model.MTableIndex) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

Example 8 with PoFiller

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

the class WindowAccessElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_Window_Access.Table_Name);
    X_AD_Window_Access po = findPO(ctx, element);
    if (po == null) {
        po = new X_AD_Window_Access(ctx.ctx, 0, getTrxName(ctx));
    }
    PoFiller filler = new PoFiller(ctx, po, element, this);
    List<String> notfounds = filler.autoFill(excludes);
    if (notfounds.size() > 0) {
        element.defer = true;
        element.unresolved = notfounds.toString();
        return;
    }
    po.saveEx();
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) X_AD_Window_Access(org.compiere.model.X_AD_Window_Access)

Example 9 with PoFiller

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

the class WorkflowAccessElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_Workflow_Access.Table_Name);
    MWorkflowAccess po = findPO(ctx, element);
    if (po == null) {
        po = new MWorkflowAccess(ctx.ctx, 0, getTrxName(ctx));
    }
    PoFiller filler = new PoFiller(ctx, po, element, this);
    List<String> notfounds = filler.autoFill(excludes);
    if (notfounds.size() > 0) {
        element.defer = true;
        element.unresolved = notfounds.toString();
        return;
    }
    po.saveEx();
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MWorkflowAccess(org.compiere.wf.MWorkflowAccess)

Example 10 with PoFiller

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

the class DynValRuleElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        X_AD_Val_Rule mValRule = findPO(ctx, element);
        if (mValRule == null) {
            mValRule = new X_AD_Val_Rule(ctx.ctx, 0, getTrxName(ctx));
        }
        List<String> excludes = defaultExcludeList(X_AD_Val_Rule.Table_Name);
        PoFiller filler = new PoFiller(ctx, mValRule, element, this);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mValRule.is_new() || mValRule.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Val_Rule.Table_Name, X_AD_Val_Rule.Table_ID);
            String action = null;
            if (!mValRule.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Val_Rule.Table_Name, mValRule);
                action = "Update";
            } else {
                action = "New";
            }
            if (mValRule.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mValRule.getName(), mValRule.get_ID(), action);
            } else {
                logImportDetail(ctx, impDetail, 0, mValRule.getName(), mValRule.get_ID(), action);
                throw new POSaveFailedException("Failed to save dynamic validation rule " + mValRule.getName());
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) X_AD_Val_Rule(org.compiere.model.X_AD_Val_Rule) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

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