use of com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView 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 com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView in project Gargoyle by callakrsos.
the class SimpleSQLResultViewExam method start.
@Override
public void start(Stage primaryStage) throws Exception {
try {
SharedMemory.setPrimaryStage(primaryStage);
BorderPane mainParent = new BorderPane();
Scene scene = new Scene(mainParent, 1280, 900);
primaryStage.setScene(scene);
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("userId", new String[] { "kyjun.kim", "zz" });
String sql = "SELECT * FROM sos.tbm_sm_user WHERE 1=1 " + " #if($userId) " + " AND USER_ID = :userId " + " #end ";
SimpleSQLResultView simpleSQLResultView = new SimpleSQLResultView(sql, param);
simpleSQLResultView.show();
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations