@Transactional @Override public Map<String, Object> updateDatatableEntryOneToMany( final String datatable, final Long appTableId, final Long datatableId, final JsonCommand command) { final GenericResultsetData grs = retrieveDataTableGenericResultSet(datatable, appTableId, null, datatableId); if (grs.getData().size() == 0) throw new DatatableNotFoundException(datatable, appTableId); final Type typeOfMap = new TypeToken<Map<String, String>>() {}.getType(); final Map<String, String> dataParams = this.fromJsonHelper.extractDataMap(typeOfMap, command.json()); final Map<String, Object> changes = getAffectedAndChangedColumns(grs, dataParams, "id"); if (changes.size() == 0) return changes; final String sql = getUpdateSql(datatable, "id", datatableId, changes); if (StringUtils.isNotBlank(sql)) { this.jdbcTemplate.update(sql); } else { logger.info("No Changes"); } return changes; }
private boolean columnChanged( final String key, final String keyValue, final String colType, final GenericResultsetData grs) { List<String> columnValues = grs.getData().get(0).getRow(); String columnValue = null; for (int i = 0; i < grs.getColumnHeaders().size(); i++) { if (key.equals(grs.getColumnHeaders().get(i).getColumnName())) { columnValue = columnValues.get(i); if (notTheSame(columnValue, keyValue, colType)) { return true; } return false; } } throw new PlatformDataIntegrityException( "error.msg.invalid.columnName", "Parameter Column Name: " + key + " not found"); }