use of com.kyj.fx.voeditor.visual.framework.BigDataDVO in project Gargoyle by callakrsos.
the class ResultSetToMapConverter method apply.
@Override
public List<Map<String, Object>> apply(ResultSetMetaData t, ResultSet u) {
List<Map<String, Object>> arrayList = Collections.emptyList();
try {
if (startRow != -1)
u.absolute(startRow);
ResultSetMetaData metaData = u.getMetaData();
int columnCount = metaData.getColumnCount();
arrayList = new ArrayList<Map<String, Object>>();
boolean firstRow = true;
while (u.next()) {
Map<String, Object> map = new LinkedHashMap<String, Object>();
for (int c = 1; c <= columnCount; c++) {
int columnType = metaData.getColumnType(c);
// 컬럼 크기가 큰 경우 데이터 맵핑을 생략할건지 유무
String value = u.getString(c);
boolean isEmptyValue = value == null || value.isEmpty();
// String tmpColumnLabel = metaData.getColumnLabel(c);
String columnLabel = metaData.getColumnLabel(c);
//2016-08-04 중복되는 컬럼이 씹혀 없어지지않도록 컬럼이름이 중복되면 인덱스를 붙임.
int nextNameIdx = 1;
while (map.containsKey(columnLabel) && /*무한루핑 방지*/
nextNameIdx < 1000) {
columnLabel = String.format("%s_%d", metaData.getColumnLabel(c), nextNameIdx);
nextNameIdx++;
}
if (isBigDataColumnSkip) {
switch(columnType) {
case Types.BLOB:
// map.put(metaData.getColumnLabel(c), new
// BigDataDVO("BLOB", value));
map.put(columnLabel, isEmptyValue ? new BigDataDVO("{data.blob}", "") : new BigDataDVO("{DATA.BLOB}", value));
break;
case Types.CLOB:
// map.put(metaData.getColumnLabel(c), new
// BigDataDVO("CLOB", value));
map.put(columnLabel, isEmptyValue ? new BigDataDVO("{data.clob}", value) : new BigDataDVO("{DATA.CLOB}", value));
break;
default:
String columnTypeName = metaData.getColumnTypeName(c);
// mysql big data type.
if ("text".equals(columnTypeName)) {
// map.put(metaData.getColumnLabel(c), new
// BigDataDVO("TEXT", value));
map.put(columnLabel, isEmptyValue ? new BigDataDVO("{data.text}", value) : new BigDataDVO("{DATA.TEXT}", value));
break;
} else // postgre big data type.
if ("bytea".equals(columnTypeName)) {
// map.put(metaData.getColumnLabel(c), new
// BigDataDVO("BYTEA", value));
map.put(columnLabel, isEmptyValue ? new BigDataDVO("{data.bytea}", value) : new BigDataDVO("{DATA.BYTEA}", value));
break;
}
map.put(columnLabel, value);
break;
}
if (firstRow) {
LOGGER.debug(String.format("column : %s type %s", columnLabel, metaData.getColumnTypeName(c)));
}
} else {
map.put(columnLabel, value);
}
}
arrayList.add(map);
firstRow = false;
}
} catch (SQLException e) {
LOGGER.error(ValueUtil.toString(e));
}
return arrayList;
}
Aggregations