use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO in project Gargoyle by callakrsos.
the class FxDAOSaveFunction method updateTbmSysDaoMethods.
@SuppressWarnings("unchecked")
private void updateTbmSysDaoMethods(TbmSysDaoDVO t, NamedParameterJdbcTemplate u, boolean existsSchemaDatabase) throws Exception {
List<TbpSysDaoMethodsDVO> tbpSysDaoMethodsDVOList = t.getTbpSysDaoMethodsDVOList();
if (tbpSysDaoMethodsDVOList == null || tbpSysDaoMethodsDVOList.isEmpty())
return;
StringBuffer deleteFieldSQLBuf;
StringBuffer deleteColumnSQLBuf;
StringBuffer deleteMethodSQLBuf;
StringBuffer insertMethodSql;
StringBuffer insertMethodHistSql;
StringBuffer insertColumnsSql;
StringBuffer insertFieldsSql;
deleteFieldSQLBuf = new StringBuffer();
deleteFieldSQLBuf.append("DELETE FROM \n");
if (existsSchemaDatabase)
deleteFieldSQLBuf.append(" meerkat.TBP_SYS_DAO_FIELDS \n");
else
deleteFieldSQLBuf.append(" TBP_SYS_DAO_FIELDS \n");
deleteFieldSQLBuf.append(" WHERE 1=1 \n");
deleteFieldSQLBuf.append("AND PACKAGE_NAME = :packageName \n");
deleteFieldSQLBuf.append("AND CLASS_NAME = :className \n");
// deleteFieldSQLBuf.append("AND METHOD_NAME = :methodName\n");
deleteColumnSQLBuf = new StringBuffer();
deleteColumnSQLBuf.append("DELETE FROM \n");
if (existsSchemaDatabase)
deleteColumnSQLBuf.append(" meerkat.TBP_SYS_DAO_COLUMNS WHERE 1=1 \n");
else
deleteColumnSQLBuf.append(" TBP_SYS_DAO_COLUMNS WHERE 1=1 \n");
deleteColumnSQLBuf.append("AND PACKAGE_NAME = :packageName \n");
deleteColumnSQLBuf.append("AND CLASS_NAME = :className \n");
// deleteColumnSQLBuf.append("AND METHOD_NAME = :methodName\n");
deleteMethodSQLBuf = new StringBuffer();
deleteMethodSQLBuf.append("DELETE FROM \n");
if (existsSchemaDatabase)
deleteMethodSQLBuf.append("meerkat.TBP_SYS_DAO_METHODS WHERE 1=1 \n");
else
deleteMethodSQLBuf.append("TBP_SYS_DAO_METHODS WHERE 1=1 \n");
deleteMethodSQLBuf.append("AND PACKAGE_NAME = :packageName \n");
deleteMethodSQLBuf.append("AND CLASS_NAME = :className \n");
// deleteMethodSQLBuf.append("AND METHOD_NAME = :methodName \n");
insertMethodSql = new StringBuffer();
insertMethodSql.append("INSERT INTO \n");
if (existsSchemaDatabase)
insertMethodSql.append("meerkat.TBP_SYS_DAO_METHODS \n");
else
insertMethodSql.append("TBP_SYS_DAO_METHODS \n");
insertMethodSql.append("(PACKAGE_NAME,\n");
insertMethodSql.append("CLASS_NAME,\n");
insertMethodSql.append("METHOD_NAME,\n");
insertMethodSql.append("RESULT_VO_CLASS,\n");
insertMethodSql.append("SQL_BODY,\n");
insertMethodSql.append("METHOD_DESC )\n");
insertMethodSql.append("VALUES (\n");
insertMethodSql.append(":packageName, \n");
insertMethodSql.append(":className , \n");
insertMethodSql.append(":methodName, \n");
insertMethodSql.append(":resultVoClass,\n");
insertMethodSql.append(":sqlBody,\n");
insertMethodSql.append(":methodDesc ) ");
insertMethodHistSql = new StringBuffer();
insertMethodHistSql.append("INSERT INTO \n");
if (existsSchemaDatabase)
insertMethodHistSql.append("meerkat.TBP_SYS_DAO_METHODS_H \n");
else
insertMethodHistSql.append("TBP_SYS_DAO_METHODS_H \n");
insertMethodHistSql.append("(HIST_TSP,\n");
insertMethodHistSql.append("PACKAGE_NAME,\n");
insertMethodHistSql.append("CLASS_NAME,\n");
insertMethodHistSql.append("METHOD_NAME,\n");
insertMethodHistSql.append("RESULT_VO_CLASS,\n");
insertMethodHistSql.append("SQL_BODY,\n");
insertMethodHistSql.append("DML_TYPE,\n");
insertMethodHistSql.append("FST_REG_DT,\n");
insertMethodHistSql.append("METHOD_DESC )\n");
insertMethodHistSql.append("VALUES (\n");
insertMethodHistSql.append(":histTsp, \n");
insertMethodHistSql.append(":packageName, \n");
insertMethodHistSql.append(":className , \n");
insertMethodHistSql.append(":methodName, \n");
insertMethodHistSql.append(":resultVoClass,\n");
insertMethodHistSql.append(":sqlBody,\n");
insertMethodHistSql.append(":dmlType,\n");
insertMethodHistSql.append(":fstRegDt,\n");
insertMethodHistSql.append(":methodDesc ) ");
insertColumnsSql = new StringBuffer();
insertColumnsSql.append("INSERT INTO \n");
if (existsSchemaDatabase)
insertColumnsSql.append("meerkat.TBP_SYS_DAO_COLUMNS ( \n");
else
insertColumnsSql.append("TBP_SYS_DAO_COLUMNS ( \n");
insertColumnsSql.append("PACKAGE_NAME,\n");
insertColumnsSql.append("CLASS_NAME,\n");
insertColumnsSql.append("METHOD_NAME,\n");
insertColumnsSql.append("COLUMN_NAME,\n");
insertColumnsSql.append("COLUMN_TYPE, \n");
insertColumnsSql.append("PROGRAM_TYPE, \n");
insertColumnsSql.append("LOCK_YN ) \n");
insertColumnsSql.append("VALUES (\n");
insertColumnsSql.append(":packageName, \n");
insertColumnsSql.append(":className , \n");
insertColumnsSql.append(":methodName , \n");
insertColumnsSql.append(":columnName, \n");
insertColumnsSql.append(":columnType, \n");
insertColumnsSql.append(":programType, \n");
insertColumnsSql.append(":lockYn ) \n");
insertFieldsSql = new StringBuffer();
insertFieldsSql.append("INSERT INTO \n");
if (existsSchemaDatabase)
insertFieldsSql.append("meerkat.TBP_SYS_DAO_FIELDS ( \n");
else
insertFieldsSql.append("TBP_SYS_DAO_FIELDS ( \n");
insertFieldsSql.append("PACKAGE_NAME,\n");
insertFieldsSql.append("CLASS_NAME,\n");
insertFieldsSql.append("METHOD_NAME,\n");
insertFieldsSql.append("FIELD_NAME,\n");
insertFieldsSql.append("TYPE , \n");
insertFieldsSql.append("TEST_VALUE ) \n");
insertFieldsSql.append("VALUES (\n");
insertFieldsSql.append(":packageName, \n");
insertFieldsSql.append(":className , \n");
insertFieldsSql.append(":methodName , \n");
insertFieldsSql.append(":fieldName, \n");
insertFieldsSql.append(":type, \n");
insertFieldsSql.append(":testValue ) \n");
// List<Map<String, Object>> updateMethodList = new ArrayList<>();
List<Map<String, Object>> insertMethodList = new ArrayList<>();
List<Map<String, Object>> deleteMethodList = new ArrayList<>();
List<Map<String, Object>> columnsInsertList = new ArrayList<>();
List<Map<String, Object>> fieldsInsertList = new ArrayList<>();
for (TbpSysDaoMethodsDVO methodDVO : tbpSysDaoMethodsDVOList) {
{
Map<String, Object> methodMap = supplyMethodMap(t, methodDVO);
// if ("Y".equals(methodDVO.getDelYn())) {
// LOGGER.debug("삭제요청 ... 요청된 정보");
LOGGER.debug(String.format("package : %s class : %s method :%s", t.getPackageName(), t.getClassName(), methodDVO.getMethodName()));
LOGGER.debug(String.format("히스토리 ID : %s", methodMap.get("histTsp").toString()));
methodMap.put("dmlType", "D");
deleteMethodList.add(new LinkedHashMap<>(methodMap));
// continue;
// }
}
/*
* UI에서는 삭제처리를 해버리면 데이터베이스에 삭제처리된 내용을 처리할 방법이 없으므로 모두 삭제하고 저장하는 방법으로
* 변경한다.
*/
// if (checkExists(SQL_CHECK_EXISTS_TBM_SYS_DAO_METHOD, methodMap,
// u)) {
// methodMap.put("dmlType", "U");
// updateMethodList.add(methodMap);
// }
// else
// {
// methodMap.put("dmlType", "I");
// insertMethodList.add(methodMap);
// }
Map<String, Object> methodMap = supplyMethodMap(t, methodDVO);
methodMap.put("dmlType", "I");
insertMethodList.add(methodMap);
// if("D".equals(methodMap.get("dmlType")))
// continue;
// columnsForDelList.add(methodMap);
columnsInsertList.addAll(supplyColumnMap(t, methodDVO));
fieldsInsertList.addAll(supplyFieldMap(t, methodDVO));
}
try {
// 컬럼메타 삭제
if (!columnsInsertList.isEmpty()) {
int update = update(deleteColumnSQLBuf.toString(), columnsInsertList.get(0), u);
LOGGER.debug("DELETE COLUMN META DML RESULT : " + update);
}
// 필드 메타 삭제
if (!fieldsInsertList.isEmpty()) {
int update = update(deleteFieldSQLBuf.toString(), fieldsInsertList.get(0), u);
LOGGER.debug("DELETE COLUMN META DML RESULT : " + update);
}
// int usize = updateMethodList.size();
int isize = insertMethodList.size();
int dsize = deleteMethodList.size();
if (dsize != 0) {
Map<String, Object>[] array = deleteMethodList.toArray(new LinkedHashMap[dsize]);
batchUpdate(deleteMethodSQLBuf.toString(), array, u);
batchUpdate(insertMethodHistSql.toString(), array, u);
}
if (isize != 0) {
Map<String, Object>[] array = insertMethodList.toArray(new LinkedHashMap[isize]);
batchUpdate(insertMethodSql.toString(), array, u);
batchUpdate(insertMethodHistSql.toString(), array, u);
}
// column insert batch
if (!columnsInsertList.isEmpty())
batchUpdate(insertColumnsSql.toString(), columnsInsertList.toArray(new LinkedHashMap[columnsInsertList.size()]), u);
// field insert batch
if (!fieldsInsertList.isEmpty())
batchUpdate(insertFieldsSql.toString(), fieldsInsertList.toArray(new LinkedHashMap[fieldsInsertList.size()]), u);
} catch (Exception e) {
throw e;
}
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO 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.TbpSysDaoMethodsDVO in project Gargoyle by callakrsos.
the class FxDAOReadFunction method getMethod.
private List<TbpSysDaoMethodsDVO> getMethod(DataSource dataSource, TbmSysDaoDVO daoDVO, boolean existsSchemaDatabase) throws Exception {
Map<String, Object> map = ValueUtil.toMap(daoDVO);
StringBuffer sb = new StringBuffer();
sb.append("SELECT \n");
sb.append("PACKAGE_NAME , \n");
sb.append("CLASS_NAME , \n");
sb.append("METHOD_NAME , \n");
sb.append("RESULT_VO_CLASS , \n");
sb.append("SQL_BODY , \n");
sb.append("METHOD_DESC \n");
if (existsSchemaDatabase)
sb.append(" FROM meerkat.TBP_SYS_DAO_METHODS \n");
else
sb.append(" FROM TBP_SYS_DAO_METHODS \n");
sb.append(" WHERE 1=1 \n");
sb.append("AND PACKAGE_NAME = :packageName\n");
sb.append("AND CLASS_NAME = :className\n");
List<TbpSysDaoMethodsDVO> select = DbUtil.select(dataSource, sb.toString(), map, new RowMapper<TbpSysDaoMethodsDVO>() {
@Override
public TbpSysDaoMethodsDVO mapRow(ResultSet rs, int rowNum) throws SQLException {
TbpSysDaoMethodsDVO dvo = new TbpSysDaoMethodsDVO(daoDVO);
dvo.setResultVoClass(rs.getString("RESULT_VO_CLASS"));
dvo.setSqlBody(rs.getString("SQL_BODY"));
dvo.setMethodName(rs.getString("METHOD_NAME"));
dvo.setMethodDesc(rs.getString("METHOD_DESC"));
return dvo;
}
});
return select;
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO in project Gargoyle by callakrsos.
the class DaoWizardViewController method initialize.
@FXML
public void initialize() {
tbParams.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
// this.colProgramTypeLock.setCellValueFactory(v ->
// v.getValue().lockYnProperty());
// this.colProgramTypeLock.setCellFactory(v ->{
// return
// });
tbmSysDaoDVOProperty = new SimpleObjectProperty<>(new TbmSysDaoDVO());
colParamTestValue.setCellFactory(TextFieldTableCell.forTableColumn());
methodDesc.setCellFactory(TextFieldTableCell.forTableColumn());
methodName.setCellFactory(TextFieldTableCell.forTableColumn());
// [시작] 넘버링 컬럼
colMethodNo.setCellValueFactory(new NumberingCellValueFactory<>(tbMethods.getItems()));
/*
* 2015-11-02 기존에 사용하던 NumberingCellValueFactory을 적용할 수 없음.
* colParamNo컬럼같은경우는 method에 따라 데이터의 주소값이 바뀌는 타입이라 주소값이 바뀌는 상태에선 적절한 넘버링
* 데이터가 화면에 보여주지않음. 하여 주소값을 계속 유지시킬 수 있도록 tbMethods에서 선택된 메소드정보에서 값을
* 참조하여 넘버링을 시킴.
*
* 2016-04-19 파람의 아이템을 삭제하고 다시 호출했을때 인덱스 순서가 맞지않던 버그 fix
*/
colParamNo.setCellValueFactory(param -> {
return new ReadOnlyObjectWrapper<Integer>(tbParams.getItems().indexOf(param.getValue()) + 1);
});
// [끝] 넘버링 컬럼
colParamTypes.setCellFactory(ChoiceBoxTableCell.forTableColumn("Nomal", "Arrays"));
// 텍스트의 내용이 변경되면 메모리에 적재시키기 위한 이벤트 함수.
// 2015.11.17 키 이벤트가 눌릴때 처리되지않게함, 타이밍 문제가 있어, 저장시에 문제가 있음.
// txtSql.getCodeArea().setOnKeyPressed();
txtSql.getCodeArea().setOnKeyReleased(event -> {
if (!event.isShortcutDown()) {
TbpSysDaoMethodsDVO selectedMethodItem = getSelectedMethodItem();
if (selectedMethodItem != null)
selectedMethodItem.setSqlBody(txtSql.getText());
}
});
StringConverter<String> classConverter = new StringConverter<String>() {
@Override
public String toString(String clazz) {
if (clazz == null || clazz.isEmpty())
return "";
String result = clazz;
int lastIndexOf = clazz.lastIndexOf('.');
if (lastIndexOf >= 0) {
result = clazz.substring(lastIndexOf + 1);
}
return result;
}
@Override
public String fromString(String clazz) {
return clazz;
}
};
// 메소드 컬럼에서 Result Vo Class를 더블클릭한경우 VO참조를 걸 수 있도록 팝업창을 뜨는 로직 포함되있음.
colResultVoClass.setCellFactory(param -> {
TextFieldTableCell<TbpSysDaoMethodsDVO, String> textFieldTableCell = new TextFieldTableCell<>();
textFieldTableCell.setOnMouseClicked(event -> {
if (event.getClickCount() == 2) {
String clazz = textFieldTableCell.getItem();
try {
BaseOpenClassResourceView view = null;
if (ValueUtil.isNotEmpty(clazz)) {
view = new MeerketAbstractVoOpenClassResourceView(clazz);
} else {
view = new MeerketAbstractVoOpenClassResourceView();
}
view.setConsumer(str -> {
if (str == null || str.isEmpty())
return;
try {
int selectedItem = tbMethods.getSelectionModel().getSelectedIndex();
tbMethods.getItems().get(selectedItem).setResultVoClass(str);
} catch (Exception e) {
DialogUtil.showExceptionDailog(e, "로드할 수 없는 클래스 유형입니다.");
return;
}
});
ResultDialog<String> show = view.show();
show.consume();
} catch (Exception e) {
e.printStackTrace();
}
}
});
textFieldTableCell.setConverter(classConverter);
return textFieldTableCell;
});
colResultVoClass.setCellValueFactory(param -> param.getValue().resultVoClassProperty());
// SQL 에디터 마우스 클릭이벤트, 선택한 메소드 항목이 없다면 Editable을 활성화 시키지않는다.
txtSql.getCodeArea().setOnMouseClicked(event -> {
if (!event.isShortcutDown()) {
int selectedMethodIndex = getSelectedMethodIndex();
if (selectedMethodIndex == -1) {
txtSql.getCodeArea().setEditable(false);
} else {
txtSql.getCodeArea().setEditable(true);
}
}
});
// 2016-08-27 custom 항목 추가. 이 항목추가시 typeMapping.properties 파일의 항목도 추가야함.
ObservableList<String> collect = DatabaseTypeMappingResourceLoader.getInstance().getEntry().stream().map(v -> v.getValue().toString()).distinct().collect(FxCollectors.toObservableList());
collect.addAll(Arrays.asList("Integer", "Long", "Double"));
colProgramType.setCellFactory(ChoiceBoxTableCell.forTableColumn(collect));
lblMessage.setText(MSG_NO_WARNNING);
// 메뉴등록작업
applyContextMenu();
}
use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO in project Gargoyle by callakrsos.
the class DaoWizardViewController method menuItemExtractFromQueryOnAction.
/**
* 쿼리문에서 Velocity 변수값을 찾는다.
*
* @작성자 : KYJ
* @작성일 : 2015. 10. 21.
* @param e
*/
public void menuItemExtractFromQueryOnAction(ActionEvent e) {
/// 2016.4.7 모두 삭제후 등록하는게 아닌 기존에 있는 변수는 유지.
// tbParams.getItems().clear();
String velocitySQL = txtSql.getText().trim();
if (velocitySQL == null || velocitySQL.isEmpty())
return;
final List<String> velocityKeys = ValueUtil.getVelocityKeys(velocitySQL);
ObservableList<TbpSysDaoFieldsDVO> fields = FXCollections.observableArrayList();
Set<String> keys = new LinkedHashSet<String>(velocityKeys);
// 기존에 존재했던 값이 있으면 먼저 바인드.
ObservableList<TbpSysDaoFieldsDVO> oldFieldList = tbParams.getItems();
for (TbpSysDaoFieldsDVO vo : oldFieldList) {
String fieldName = vo.getFieldName();
if (keys.contains(fieldName)) {
fields.add(vo);
keys.remove(fieldName);
}
}
/* 구버젼 */
Iterator<String> iterator = keys.iterator();
while (iterator.hasNext()) {
String key = iterator.next();
/* 2016.4.7 이미 존재하는 데이터는 유지한다. */
// Optional<TbpSysDaoFieldsDVO> findAny =
// tbParams.getItems().stream().filter(v ->
// key.equals(v.getFieldName())).findAny();
// if (findAny.isPresent()) {
// continue;
// }
TbpSysDaoFieldsDVO dvo = new TbpSysDaoFieldsDVO();
dvo.setFieldName(key);
fields.add(dvo);
}
/* 구버젼 */
/* 메소드항목에 생성된 다이나픽 필드변수를 메모리에 저장한다. */
TbpSysDaoMethodsDVO tbpSysDaoMethodsDVO = getSelectedMethodItem();
if (tbpSysDaoMethodsDVO != null) {
tbpSysDaoMethodsDVO.setTbpSysDaoFieldsDVOList(fields);
tbParams.getItems().clear();
tbParams.getItems().addAll(fields);
}
}
Aggregations