use of com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction in project Gargoyle by callakrsos.
the class VoWizardUtil method listColumns.
/**
* 테이블컬럼모델생성
*
* @param selectedItem
* @return
* @throws Exception
*/
public static List<TableModelDVO> listColumns(TableMasterDVO selectedItem) throws Exception {
DatabaseTypeMappingFunction databaseTypeMappingFunction = new DatabaseTypeMappingFunction();
String tableName = selectedItem.getTableName();
List<String> pks = DbUtil.pks(tableName, rs -> {
try {
return rs.getString(4).toLowerCase();
} catch (SQLException e) {
LOGGER.error(ValueUtil.toString(e));
}
return "";
});
return DbUtil.columns(tableName, rs -> {
TableModelDVO dvo = new TableModelDVO();
try {
String columnName = rs.getString(4);
String dataType = rs.getString(5);
String typeName = rs.getString(6);
String size = rs.getString(7);
String remark = rs.getString(12);
dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(columnName));
dvo.setDatabaseColumnName(columnName);
dvo.setDabaseTypeName(typeName);
dvo.setType(databaseTypeMappingFunction.apply(typeName));
dvo.setPk(pks.contains(columnName.toLowerCase()) ? "Y" : "N");
dvo.setDesc(remark);
dvo.setSize(size);
} catch (Exception e) {
LOGGER.error(ValueUtil.toString(e));
}
return dvo;
});
//
// String tableName = selectedItem.getTableName();
// String sql = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.SQL_COLUMN);
//
// /*
// * 2016-08-11 by kyj.
// *
// * 설정에 대한 sql항목이 없는경우 순수 jdbc 라이브러리를 이용하는 방안으로 구성.
// */
// if (sql == null || sql.isEmpty()) {
//
// List<String> pks = DbUtil.pks(tableName, rs -> {
//
// try {
// return rs.getString(4).toLowerCase();
// } catch (SQLException e) {
// LOGGER.error(ValueUtil.toString(e));
// }
// return "";
// });
//
// return DbUtil.columns(tableName, rs -> {
//
// TableModelDVO dvo = new TableModelDVO();
// try {
//
// String columnName = rs.getString(4);
// String dataType = rs.getString(5);
// String typeName = rs.getString(6);
// String size = rs.getString(7);
// String remark = rs.getString(12);
// dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(columnName));
// dvo.setDatabaseColumnName(columnName);
// dvo.setDabaseTypeName(typeName);
//
// dvo.setType(databaseTypeMappingFunction.apply(typeName));
//
// dvo.setPk(pks.contains(columnName.toLowerCase()) ? "Y" : "N");
// dvo.setDesc(remark);
// dvo.setSize(size);
//
// } catch (Exception e) {
// LOGGER.error(ValueUtil.toString(e));
// }
//
// return dvo;
// });
//
// } else {
//
// Map<String, Object> hashMap = new HashMap<String, Object>();
// hashMap.put("tableName", tableName);
//
// String convertedSql = ValueUtil.getVelocityToText(sql, hashMap);
// return DbUtil.select(convertedSql, hashMap, new RowMapper<TableModelDVO>() {
//
// @Override
// public TableModelDVO mapRow(ResultSet rs, int rowNum) throws SQLException {
// TableModelDVO dvo = new TableModelDVO();
//
// String columnName = rs.getString(COLUMN_NAME);
// dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(columnName));
// dvo.setDatabaseColumnName(columnName);
//
// String typeName = rs.getString(TYPE);
// dvo.setDabaseTypeName(typeName);
//
// // rs.getInt(columnLabel)
// // rs.getMetaData().getColumnTypeName()
// dvo.setType(databaseTypeMappingFunction.apply(typeName));
// dvo.setPk(rs.getString(PK));
// dvo.setDesc(rs.getString(COMMENTS));
// dvo.setSize(rs.getString(DATA_LENGTH));
// return dvo;
// }
// });
// }
}
use of com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction in project Gargoyle by callakrsos.
the class DaoWizardViewController method menuToVoEditorOnAction.
/********************************
* 작성일 : 2016. 2. 27. 작성자 : KYJ
*
* 내용 : VO에티터로 결과내용을 전달처리한다.
*******************************/
public void menuToVoEditorOnAction(ActionEvent e) {
ObservableList<TbpSysDaoColumnsDVO> items = tbMappings.getItems();
if (items.isEmpty())
return;
DatabaseTypeMappingFunction typeConverter = new DatabaseTypeMappingFunction();
try {
FXMLLoader loader = FxUtil.createNewFxmlLoader();
loader.setLocation(getClass().getResource("VoEditorView.fxml"));
BorderPane root = loader.load();
VoEditorController controller = loader.getController();
List<TableModelDVO> resultItems = items.stream().map(m -> {
TableModelDVO dvo = new TableModelDVO();
dvo.setName(ValueUtil.getPrefixLowerTextMyEdit(m.getColumnName()));
String programType = m.getProgramType();
if (programType == null || programType.isEmpty()) {
programType = typeConverter.apply(m.getColumnType());
}
dvo.setType(programType);
return dvo;
}).collect(Collectors.toList());
controller.addItem(resultItems);
SharedMemory.getSystemLayoutViewController().loadNewSystemTab("New VO", root);
} catch (IOException e1) {
LOGGER.error(ValueUtil.toString(e1));
}
}
Aggregations