Search in sources :

Example 11 with PoFiller

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

the class FormAccessElementHandler method startElement.

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

Example 12 with PoFiller

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

the class FormElementHandler method startElement.

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

Example 13 with PoFiller

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

the class GenericPOElementHandler method startElement.

public void startElement(PIPOContext ctx, Element element) throws SAXException {
    String tableName = element.getElementValue();
    PO po = findPO(ctx, element);
    if (po == null) {
        MTable table = MTable.get(ctx.ctx, tableName);
        po = table.getPO(0, getTrxName(ctx));
    }
    PoFiller filler = new PoFiller(ctx, po, element, this);
    List<String> excludes = defaultExcludeList(tableName);
    List<String> notfounds = filler.autoFill(excludes);
    /* Verify if the table has entitytype and check dictionary maintenance */
    int idxet = po.get_ColumnIndex("EntityType");
    if (idxet >= 0) {
        String entityType = (String) po.get_Value(idxet);
        if (!isProcessElement(ctx.ctx, entityType)) {
            if (log.isLoggable(Level.INFO))
                log.info("Generic PO not processed as it's official " + po.toString());
            element.skip = true;
            return;
        }
    }
    if (notfounds.size() > 0) {
        element.defer = true;
        element.unresolved = notfounds.toString();
        return;
    }
    String action = po.is_new() ? "New" : "Update";
    po.saveEx();
    element.recordId = po.get_ID();
    X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, po.get_TableName(), po.get_Table_ID());
    logImportDetail(ctx, impDetail, 1, po.toString(), element.recordId, action);
    if (I_AD_Window.Table_Name.equals(tableName) || I_AD_Process.Table_Name.equals(tableName) || I_AD_Role.Table_Name.equals(tableName) || I_AD_Form.Table_Name.equals(tableName) || I_C_DocType.Table_Name.equals(tableName) || I_AD_InfoWindow.Table_Name.equals(tableName))
        element.requireRoleAccessUpdate = true;
}
Also used : PoFiller(org.adempiere.pipo2.PoFiller) MTable(org.compiere.model.MTable) X_AD_Package_Imp_Detail(org.compiere.model.X_AD_Package_Imp_Detail) GenericPO(org.adempiere.model.GenericPO) PO(org.compiere.model.PO)

Example 14 with PoFiller

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

the class IndexColumnElementHandler 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, MTableIndex.Table_Name)) {
            element.defer = true;
            return;
        }
        List<String> excludes = defaultExcludeList(MIndexColumn.Table_Name);
        MIndexColumn mIndexColumn = findPO(ctx, element);
        if (mIndexColumn == null) {
            int parentId = 0;
            if (getParentId(element, MTableIndex.Table_Name) > 0) {
                parentId = getParentId(element, MTableIndex.Table_Name);
            } else {
                Element pfElement = element.properties.get(MIndexColumn.COLUMNNAME_AD_TableIndex_ID);
                parentId = ReferenceUtils.resolveReference(ctx.ctx, pfElement, getTrxName(ctx));
            }
            if (parentId <= 0) {
                element.defer = true;
                element.unresolved = "AD_TableIndex_ID";
                return;
            }
            mIndexColumn = new MIndexColumn(ctx.ctx, 0, getTrxName(ctx));
            mIndexColumn.setAD_TableIndex_ID(parentId);
            excludes.add(MIndexColumn.COLUMNNAME_AD_TableIndex_ID);
        }
        PoFiller filler = new PoFiller(ctx, mIndexColumn, element, this);
        if (mIndexColumn.getAD_IndexColumn_ID() == 0 && isOfficialId(element, "AD_IndexColumn_ID"))
            filler.setInteger("AD_IndexColumn_ID");
        excludes.add("AD_Column_ID");
        int columnId = 0;
        Element columnElement = element.properties.get("AD_Column_ID");
        if (ReferenceUtils.isIDLookup(columnElement) || ReferenceUtils.isUUIDLookup(columnElement)) {
            columnId = ReferenceUtils.resolveReference(ctx.ctx, columnElement, getTrxName(ctx));
        }
        if (columnId > 0)
            mIndexColumn.setAD_Column_ID(columnId);
        List<String> notfounds = filler.autoFill(excludes);
        if (notfounds.size() > 0) {
            element.defer = true;
            element.unresolved = notfounds.toString();
            return;
        }
        if (mIndexColumn.is_new() || mIndexColumn.is_Changed()) {
            X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, MIndexColumn.Table_Name, MIndexColumn.Table_ID);
            String action = null;
            if (!mIndexColumn.is_new()) {
                backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), MIndexColumn.Table_Name, mIndexColumn);
                action = "Update";
            } else {
                action = "New";
            }
            if (mIndexColumn.save(getTrxName(ctx)) == true) {
                logImportDetail(ctx, impDetail, 1, mIndexColumn.toString(), mIndexColumn.get_ID(), action);
            } else {
                logImportDetail(ctx, impDetail, 0, mIndexColumn.toString(), mIndexColumn.get_ID(), action);
                throw new POSaveFailedException("Failed to save AD_IndexColumn " + mIndexColumn.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) MIndexColumn(org.compiere.model.MIndexColumn)

Example 15 with PoFiller

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

the class InfoColumnElementHandler method startElement.

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

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