Search in sources :

Example 1 with DatabaseTypeMappingFunction

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;
//				}
//			});
//		}
}
Also used : SQLException(java.sql.SQLException) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) GargoyleFileAlreadyExistException(com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException) SQLException(java.sql.SQLException) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)

Example 2 with DatabaseTypeMappingFunction

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));
    }
}
Also used : SimpleSQLResultView(com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView) Arrays(java.util.Arrays) Menus(com.kyj.fx.voeditor.visual.component.Menus) DbUtil(com.kyj.fx.voeditor.visual.util.DbUtil) NumberingCellValueFactory(com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory) LoggerFactory(org.slf4j.LoggerFactory) NullExpresion(com.kyj.fx.voeditor.visual.util.NullExpresion) MeerketAbstractVoOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ContextMenu(javafx.scene.control.ContextMenu) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) Path(java.nio.file.Path) EditorUtil(com.kyj.fx.voeditor.util.EditorUtil) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction) ClassTypeResourceLoader(com.kyj.fx.voeditor.visual.momory.ClassTypeResourceLoader) TableMasterDVO(kyj.Fx.dao.wizard.core.model.vo.TableMasterDVO) SqlKeywords(com.kyj.fx.voeditor.visual.component.text.SqlKeywords) TextField(javafx.scene.control.TextField) Pair(javafx.util.Pair) MenuItem(javafx.scene.control.MenuItem) QuerygenUtil(kyj.Fx.dao.wizard.core.util.QuerygenUtil) TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) DatabaseTableView(com.kyj.fx.voeditor.visual.component.popup.DatabaseTableView) FxDAOReadFunction(com.kyj.fx.voeditor.visual.functions.FxDAOReadFunction) ConfigResourceLoader(com.kyj.fx.voeditor.visual.momory.ConfigResourceLoader) TableDVO(kyj.Fx.dao.wizard.core.model.vo.TableDVO) Collectors(java.util.stream.Collectors) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) ResourceLoader(com.kyj.fx.voeditor.visual.momory.ResourceLoader) Stream(java.util.stream.Stream) Optional(java.util.Optional) ChoiceBoxTableCell(javafx.scene.control.cell.ChoiceBoxTableCell) DateUtil(com.kyj.fx.voeditor.visual.util.DateUtil) CommonsContextMenu(com.kyj.fx.voeditor.visual.component.CommonsContextMenu) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) BaseOpenClassResourceView(com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView) TextArea(javafx.scene.control.TextArea) MouseEvent(javafx.scene.input.MouseEvent) CommonContextMenuEvent(com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) Function(java.util.function.Function) TbmSysDaoDVO(kyj.Fx.dao.wizard.core.model.vo.TbmSysDaoDVO) TableColumn(javafx.scene.control.TableColumn) Wizardtype(com.kyj.fx.voeditor.visual.framework.daowizard.GargoyleDaoWizardFactory.Wizardtype) FXMLLoader(javafx.fxml.FXMLLoader) FxCollectors(com.kyj.fx.voeditor.visual.util.FxCollectors) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) DaoWizard(kyj.Fx.dao.wizard.DaoWizard) LinkedHashSet(java.util.LinkedHashSet) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FxDAOSaveFunction(com.kyj.fx.voeditor.visual.functions.FxDAOSaveFunction) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) DaoWizardConverter(com.kyj.fx.voeditor.visual.util.DaoWizardConverter) Label(javafx.scene.control.Label) Iterator(java.util.Iterator) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) DatabaseTypeMappingResourceLoader(kyj.Fx.dao.wizard.memory.DatabaseTypeMappingResourceLoader) IOException(java.io.IOException) LockImagedYnColumn(com.kyj.fx.voeditor.visual.component.LockImagedYnColumn) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO) StringConverter(javafx.util.StringConverter) File(java.io.File) ActionEvent(javafx.event.ActionEvent) SelectionMode(javafx.scene.control.SelectionMode) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) ResultDialog(com.kyj.fx.voeditor.visual.component.ResultDialog) Collections(java.util.Collections) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) BorderPane(javafx.scene.layout.BorderPane) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) IOException(java.io.IOException) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) FXMLLoader(javafx.fxml.FXMLLoader) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)

Aggregations

DatabaseTypeMappingFunction (com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)2 TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)2 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)1 FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)1 EditorUtil (com.kyj.fx.voeditor.util.EditorUtil)1 CommonsContextMenu (com.kyj.fx.voeditor.visual.component.CommonsContextMenu)1 LockImagedYnColumn (com.kyj.fx.voeditor.visual.component.LockImagedYnColumn)1 Menus (com.kyj.fx.voeditor.visual.component.Menus)1 NumberingCellValueFactory (com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory)1 ResultDialog (com.kyj.fx.voeditor.visual.component.ResultDialog)1 BaseOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView)1 DatabaseTableView (com.kyj.fx.voeditor.visual.component.popup.DatabaseTableView)1 JavaTextView (com.kyj.fx.voeditor.visual.component.popup.JavaTextView)1 MeerketAbstractVoOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView)1 SimpleSQLResultView (com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView)1 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)1 CommonContextMenuEvent (com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent)1 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)1 Wizardtype (com.kyj.fx.voeditor.visual.framework.daowizard.GargoyleDaoWizardFactory.Wizardtype)1 FxDAOReadFunction (com.kyj.fx.voeditor.visual.functions.FxDAOReadFunction)1