Search in sources :

Example 1 with POSaveFailedException

use of org.adempiere.pipo2.exception.POSaveFailedException 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 2 with POSaveFailedException

use of org.adempiere.pipo2.exception.POSaveFailedException in project idempiere by idempiere.

the class RoleElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_Role.Table_Name);
    MRole mRole = findPO(ctx, element);
    if (mRole == null) {
        mRole = new MRole(ctx.ctx, 0, getTrxName(ctx));
    }
    PoFiller filler = new PoFiller(ctx, mRole, element, this);
    List<String> notfounds = filler.autoFill(excludes);
    if (notfounds.size() > 0) {
        element.defer = true;
        element.unresolved = notfounds.toString();
        return;
    }
    if (mRole.is_new() || mRole.is_Changed()) {
        X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Role.Table_Name, X_AD_Role.Table_ID);
        String action = null;
        if (!mRole.is_new()) {
            action = "Update";
        } else {
            action = "New";
        }
        if (mRole.save(getTrxName(ctx)) == true) {
            element.recordId = mRole.getAD_Role_ID();
            logImportDetail(ctx, impDetail, 1, mRole.getName(), mRole.get_ID(), action);
            element.requireRoleAccessUpdate = true;
        } else {
            logImportDetail(ctx, impDetail, 0, mRole.getName(), mRole.get_ID(), action);
            throw new POSaveFailedException("Failed to save Role " + mRole.getName());
        }
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MRole(org.compiere.model.MRole) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail)

Example 3 with POSaveFailedException

use of org.adempiere.pipo2.exception.POSaveFailedException 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)

Example 4 with POSaveFailedException

use of org.adempiere.pipo2.exception.POSaveFailedException in project idempiere by idempiere.

the class AdElementHandler method startElement.

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

Example 5 with POSaveFailedException

use of org.adempiere.pipo2.exception.POSaveFailedException in project idempiere by idempiere.

the class AttachmentElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String action = null;
    MAttachment mAttachment = findPO(ctx, element);
    if (mAttachment == null) {
        mAttachment = new MAttachment(ctx.ctx, 0, getTrxName(ctx));
    }
    List<String> excludes = defaultExcludeList(X_AD_Attachment.Table_Name);
    if (attachments.contains(mAttachment.getAD_Attachment_ID())) {
        element.skip = true;
        return;
    }
    PoFiller pf = new PoFiller(ctx, mAttachment, element, this);
    List<String> notfounds = pf.autoFill(excludes);
    if (notfounds.size() > 0) {
        element.defer = true;
        element.unresolved = notfounds.toString();
        return;
    }
    mAttachment.getEntries();
    if (mAttachment.is_new() || mAttachment.is_Changed()) {
        X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Attachment.Table_Name, X_AD_Attachment.Table_ID);
        if (!mAttachment.is_new()) {
            backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Attachment.Table_Name, mAttachment);
            action = "Update";
        } else {
            action = "New";
        }
        if (mAttachment.save(getTrxName(ctx)) == true) {
            logImportDetail(ctx, impDetail, 1, mAttachment.toString(), mAttachment.get_ID(), action);
            element.recordId = mAttachment.getAD_Attachment_ID();
            attachments.add(mAttachment.getAD_Attachment_ID());
        } else {
            logImportDetail(ctx, impDetail, 0, mAttachment.toString(), mAttachment.get_ID(), action);
            throw new POSaveFailedException("Failed to save Attachment " + mAttachment.toString());
        }
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MAttachment(org.compiere.model.MAttachment) 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)42 POSaveFailedException (org.adempiere.pipo2.exception.POSaveFailedException)42 X_AD_Package_Imp_Detail (org.compiere.model.X_AD_Package_Imp_Detail)42 Element (org.adempiere.pipo2.Element)2 MWorkflow (org.compiere.wf.MWorkflow)2 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 MIndexColumn (org.compiere.model.MIndexColumn)1 MMessage (org.compiere.model.MMessage)1 MPreference (org.compiere.model.MPreference)1 MReference (org.compiere.model.MReference)1 MReportView (org.compiere.model.MReportView)1 MRole (org.compiere.model.MRole)1 MTab (org.compiere.model.MTab)1 MTable (org.compiere.model.MTable)1 MTableIndex (org.compiere.model.MTableIndex)1 MTask (org.compiere.model.MTask)1