Search in sources :

Example 1 with X_AD_Ref_Table

use of org.compiere.model.X_AD_Ref_Table 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)

Aggregations

Element (org.adempiere.pipo2.Element)1 PoFiller (org.adempiere.pipo2.PoFiller)1 MReference (org.compiere.model.MReference)1 X_AD_Package_Imp_Detail (org.compiere.model.X_AD_Package_Imp_Detail)1 X_AD_Ref_Table (org.compiere.model.X_AD_Ref_Table)1