Search in sources :

Example 26 with PoFiller

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

the class TaskAccessElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_Task_Access.Table_Name);
    X_AD_Task_Access po = findPO(ctx, element);
    if (po == null) {
        po = new X_AD_Task_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_Task_Access(org.compiere.model.X_AD_Task_Access)

Example 27 with PoFiller

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

the class TaskElementHandler method startElement.

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

Example 28 with PoFiller

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

the class UserRoleElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    List<String> excludes = defaultExcludeList(X_AD_User_Roles.Table_Name);
    X_AD_User_Roles po = findPO(ctx, element);
    if (po == null) {
        po = new X_AD_User_Roles(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 : X_AD_User_Roles(org.compiere.model.X_AD_User_Roles) PoFiller(org.adempiere.pipo2.PoFiller)

Example 29 with PoFiller

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

the class ViewColumnElementHandler method startElement.

@Override
public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        if (isParentDefer(element, MViewComponent.Table_Name)) {
            element.defer = true;
            return;
        }
        List<String> excludes = defaultExcludeList(MViewColumn.Table_Name);
        MViewColumn mViewColumn = findPO(ctx, element);
        if (mViewColumn == null) {
            int parentId = 0;
            if (getParentId(element, MViewComponent.Table_Name) > 0) {
                parentId = getParentId(element, MViewComponent.Table_Name);
            } else {
                Element pfElement = element.properties.get(MViewColumn.COLUMNNAME_AD_ViewComponent_ID);
                parentId = ReferenceUtils.resolveReference(ctx.ctx, pfElement, getTrxName(ctx));
            }
            if (parentId <= 0) {
                element.defer = true;
                element.unresolved = "AD_ViewComponent_ID";
                return;
            }
            mViewColumn = new MViewColumn(ctx.ctx, 0, getTrxName(ctx));
            mViewColumn.setAD_ViewComponent_ID(parentId);
            excludes.add(MViewColumn.COLUMNNAME_AD_ViewComponent_ID);
        }
        PoFiller filler = new PoFiller(ctx, mViewColumn, element, this);
        if (mViewColumn.getAD_ViewColumn_ID() == 0 && isOfficialId(element, "AD_ViewColumn_ID"))
            filler.setInteger("AD_ViewColumn_ID");
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mViewColumn.is_new() || mViewColumn.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MViewColumn.Table_Name, MViewColumn.Table_ID);
            String action = null;
            if (!mViewColumn.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), MViewColumn.Table_Name, mViewColumn);
                action = "Update";
            } else {
                action = "New";
            }
            if (mViewColumn.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mViewColumn.toString(), mViewColumn.get_ID(), action);
            } else {
                logImportDetail(ctx, impDetail, 0, mViewColumn.toString(), mViewColumn.get_ID(), action);
                throw new POSaveFailedException("Failed to save AD_ViewColumn " + mViewColumn.toString());
            }
        }
    } else {
        element.skip = true;
    }
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) Element(org.adempiere.pipo2.Element) POSaveFailedException(org.adempiere.pipo2.exception.POSaveFailedException) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail) MViewColumn(org.compiere.model.MViewColumn)

Example 30 with PoFiller

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

the class ViewComponentElementHandler method startElement.

@Override
public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String entitytype = getStringValue(element, "EntityType");
    if (isProcessElement(ctx.ctx, entitytype)) {
        MViewComponent mViewComponent = findPO(ctx, element);
        if (mViewComponent == null) {
            mViewComponent = new MViewComponent(ctx.ctx, 0, getTrxName(ctx));
        }
        PoFiller filler = new PoFiller(ctx, mViewComponent, element, this);
        List<String> excludes = defaultExcludeList(MViewComponent.Table_Name);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mViewComponent.is_new() || mViewComponent.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MViewComponent.Table_Name, MViewComponent.Table_ID);
            String action = null;
            if (!mViewComponent.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), MViewComponent.Table_Name, mViewComponent);
                action = "Update";
            } else {
                action = "New";
            }
            if (mViewComponent.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mViewComponent.getName(), mViewComponent.get_ID(), action);
                element.recordId = mViewComponent.getAD_ViewComponent_ID();
            } else {
                logImportDetail(ctx, impDetail, 0, mViewComponent.getName(), mViewComponent.get_ID(), action);
                throw new POSaveFailedException("Failed to save AD_ViewComponent " + mViewComponent.getName());
            }
        }
    } 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) MViewComponent(org.compiere.model.MViewComponent)

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