@Override protected DalCallResult batchInsertOrUpdate( List<IColumnToVOMapping<? extends Object>> columns, Collection<EntityObjectVO> colDalVO, boolean failAfterBatch) { DalCallResult dcr = new DalCallResult(); for (EntityObjectVO dalVO : colDalVO) { Map<String, Object> columnValueMap = getColumnValuesMap(valueColumnsUpdate, dalVO, false); Map<String, Object> columnConditionMap = getColumnValuesMap(conditionColumns, dalVO, false); DbTableStatement stmt = null; try { boolean updated = false; if (importStructure.isUpdate()) { columnValueMap.put("INTVERSION", DbIncrement.INCREMENT); stmt = new DbUpdateStatement(getDbSourceForDML(), columnValueMap, columnConditionMap); updated = dataBaseHelper.getDbAccess().execute(stmt) > 0; if (updated) this.updated++; } dalVO.setId(DalUtils.getNextId()); columnValueMap = getColumnValuesMap(valueColumnsInsert, dalVO, false); if (importStructure.isInsert() && !updated) { stmt = new DbInsertStatement(getDbSourceForDML(), columnValueMap); dataBaseHelper.getDbAccess().execute(stmt); inserted++; } if (eMeta.isStateModel() && !updated) { EOGenericObjectVO eogo = new EOGenericObjectVO(); eogo.setId(dalVO.getId()); eogo.setCreatedBy(dalVO.getCreatedBy()); eogo.setCreatedAt(dalVO.getCreatedAt()); eogo.setChangedBy(dalVO.getChangedBy()); eogo.setChangedAt(dalVO.getChangedAt()); eogo.setModuleId(eMeta.getId()); eogo.setVersion(1); eogo.flagNew(); NucletDalProvider.getInstance().getEOGenericObjectProcessor().insertOrUpdate(eogo); } } catch (DbException ex) { if (!failAfterBatch) { throw ex; } ex.setIdIfNull(dalVO.getId()); dcr.addBusinessException(ex); } } return dcr; }
public ImportObjectProcessor(ProcessorConfiguration config, ImportStructure structure) { super(config); this.importStructure = structure; for (IColumnToVOMapping<? extends Object> column : allColumns) { valueColumnsInsert.add(column); if (structure.getItems().containsKey(column.getField())) { valueColumnsUpdate.add(column); } else if (systemFieldsForUpdate.contains(column.getColumn())) { valueColumnsUpdate.add(column); } if (structure.getIdentifiers().contains(column.getField())) { conditionColumns.add(column); } } }