use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO in project Gargoyle by callakrsos.
the class FxDAOSaveFunction method supplyColumnMap.
private List<Map<String, Object>> supplyColumnMap(TbmSysDaoDVO t, final TbpSysDaoMethodsDVO methodDVO) {
List<Map<String, Object>> supplyer = new ArrayList<>();
List<TbpSysDaoColumnsDVO> tbpSysDaoColumnsDVOList = methodDVO.getTbpSysDaoColumnsDVOList();
for (TbpSysDaoColumnsDVO dvo : tbpSysDaoColumnsDVOList) {
Map<String, Object> map = ValueUtil.toMap(dvo);
map.put(METHOD_NAME, methodDVO.getMethodName());
applyClassMeta(t, map);
supplyer.add(map);
}
return supplyer;
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO in project Gargoyle by callakrsos.
the class FxDAOReadFunction method getColumns.
List<TbpSysDaoColumnsDVO> getColumns(DataSource dataSource, TbmSysDaoDVO daoDVO, boolean existsSchemaDatabase) throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("SELECT \n");
sb.append("METHOD_NAME , \n");
sb.append("COLUMN_NAME , \n");
sb.append("COLUMN_TYPE, \n");
sb.append("PROGRAM_TYPE, \n");
sb.append("LOCK_YN \n");
if (existsSchemaDatabase)
sb.append(" FROM meerkat.tbp_sys_dao_columns \n");
else
sb.append(" FROM tbp_sys_dao_columns \n");
sb.append(" WHERE 1=1 \n");
sb.append("AND PACKAGE_NAME = :packageName\n");
sb.append("AND CLASS_NAME = :className\n");
// sb.append("#if($methodName)\n");
// sb.append(" and method_name = :methodName\n");
// sb.append("#end\n");
Map<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("packageName", daoDVO.getPackageName());
hashMap.put("className", daoDVO.getClassName());
return DbUtil.select(dataSource, sb.toString(), hashMap, new RowMapper<TbpSysDaoColumnsDVO>() {
@Override
public TbpSysDaoColumnsDVO mapRow(ResultSet rs, int rowNum) throws SQLException {
TbpSysDaoColumnsDVO dvo = new TbpSysDaoColumnsDVO();
dvo.setMethodName(rs.getString("METHOD_NAME"));
dvo.setColumnType(rs.getString("COLUMN_TYPE"));
dvo.setColumnName(rs.getString("COLUMN_NAME"));
dvo.setProgramType(rs.getString("PROGRAM_TYPE"));
dvo.setLockYn(rs.getString("LOCK_YN"));
return dvo;
}
});
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO in project Gargoyle by callakrsos.
the class FxDAOReadFunction method apply.
@Override
public TbmSysDaoDVO apply(TbmSysDaoDVO t) {
DataSource dataSource = null;
try {
dataSource = DbUtil.getDataSource();
boolean existsSchemaDatabase = DbUtil.isExistsSchemaDatabase();
List<TbpSysDaoMethodsDVO> methods = getMethod(dataSource, t, existsSchemaDatabase);
List<TbpSysDaoColumnsDVO> columns = getColumns(dataSource, t, existsSchemaDatabase);
List<TbpSysDaoFieldsDVO> fields = getField(dataSource, t, existsSchemaDatabase);
for (TbpSysDaoMethodsDVO m : methods) {
m.setTbpSysDaoColumnsDVOList(columns.stream().filter(col -> m.getMethodName().equals(col.getMethodName())).collect(Collectors.toList()));
m.setTbpSysDaoFieldsDVOList(fields.stream().filter(col -> m.getMethodName().equals(col.getMethodName())).collect(Collectors.toList()));
}
t.setTbpSysDaoMethodsDVOList(methods);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
DbUtil.close(dataSource);
} catch (Exception e) {
}
}
return t;
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO in project Gargoyle by callakrsos.
the class DaoWizardViewController method btnExecOnMouseClick.
/**
* 텍스트에 기술된 SQL문을 실행한다. 기본적으로 ROWNUM 기술문을 100개를 감싸서 SQL을 조회한다.
*
* @작성자 : KYJ
* @작성일 : 2015. 10. 21.
*/
@FXML
public void btnExecOnMouseClick(MouseEvent e) {
LOGGER.debug("event] btnExecOnMouseClick");
String velocitySQL = txtSql.getText().trim();
if (velocitySQL == null || velocitySQL.isEmpty())
return;
LOGGER.debug(String.format("velocitySQL : %s", velocitySQL));
// 파라미터 컬럼값 반환받는다.
ObservableList<TbpSysDaoFieldsDVO> items = tbParams.getItems();
Map<String, TbpSysDaoColumnsDVO> unmapping = this.tbMappings.getItems().stream().filter(v -> {
String lockYn = v.getLockYn();
if ("Y".equals(lockYn))
return true;
return false;
}).collect(Collectors.toMap(TbpSysDaoColumnsDVO::getColumnName, v -> v));
Map<String, Object> paramMap = items.stream().filter(vo -> vo.getTestValue() != null && !vo.getTestValue().isEmpty()).collect(Collectors.toMap(TbpSysDaoFieldsDVO::getFieldName, new Function<TbpSysDaoFieldsDVO, Object>() {
@Override
public Object apply(TbpSysDaoFieldsDVO t) {
if ("Arrays".equals(t.getType())) {
String pattern = "'[^']{0,}'";
List<String> regexMatchs = ValueUtil.regexMatchs(pattern, t.getTestValue(), str -> {
return str.substring(1, str.length() - 1);
});
return regexMatchs;
}
return t.getTestValue();
}
}));
SimpleSQLResultView simpleSQLResultView = new SimpleSQLResultView(velocitySQL, paramMap);
try {
simpleSQLResultView.show();
List<TableModelDVO> columns = simpleSQLResultView.getColumns();
List<TbpSysDaoColumnsDVO> resultList = columns.stream().map(vo -> {
TbpSysDaoColumnsDVO dvo = new TbpSysDaoColumnsDVO();
dvo.setColumnName(vo.getDatabaseColumnName());
String databaseTypeName = vo.getDatabaseTypeName();
dvo.setColumnType(databaseTypeName);
if (unmapping.containsKey(vo.getDatabaseColumnName())) {
TbpSysDaoColumnsDVO tmp = unmapping.get(vo.getDatabaseColumnName());
dvo.setProgramType(tmp.getProgramType());
dvo.setLockYn(tmp.getLockYn());
} else {
String programType = DatabaseTypeMappingResourceLoader.getInstance().get(databaseTypeName);
dvo.setProgramType(programType);
}
return dvo;
}).collect(Collectors.toList());
// if (!this.tbMappings.getItems().isEmpty())
if (!resultList.isEmpty()) {
try {
this.tbMappings.getItems().clear();
getSelectedMethodItem().getTbpSysDaoColumnsDVOList().clear();
this.tbMappings.getItems().addAll(resultList);
getSelectedMethodItem().getTbpSysDaoColumnsDVOList().addAll(resultList);
} catch (NullPointerException n) {
DialogUtil.showMessageDialog("메소드를 선택해주세요.");
}
}
} catch (IOException e1) {
LOGGER.error(ValueUtil.toString(e1));
DialogUtil.showExceptionDailog(e1);
}
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO in project Gargoyle by callakrsos.
the class DaoWizardViewController method tbMethodsOnMouseClick.
/**
* 메소드 테이블 로우 더블클릭 이벤트처리.
*
* 저장되어있는 SQL을 UI에 보여주는 기능을한다.
*
* @작성자 : KYJ
* @작성일 : 2015. 10. 21.
* @param e
*/
@FXML
public void tbMethodsOnMouseClick(MouseEvent e) {
if (e.getClickCount() == 2) {
// tbParams.getItems().clear();
List<TbpSysDaoFieldsDVO> selectedFieldItems = getSelectedFieldItems();
TbpSysDaoMethodsDVO selectedMethodItem = getSelectedMethodItem();
if (selectedMethodItem != null) {
String sqlBody = selectedMethodItem.getSqlBody();
txtSql.setContent(sqlBody);
List<TbpSysDaoColumnsDVO> tbpSysDaoColumnsDVOList = selectedMethodItem.getTbpSysDaoColumnsDVOList();
tbMappings.setItems(FXCollections.observableArrayList(tbpSysDaoColumnsDVOList));
}
if (selectedFieldItems != null)
tbParams.setItems(FXCollections.observableList(selectedFieldItems));
}
}
Aggregations