Search in sources :

Example 1 with TableModelDVO

use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO in project Gargoyle by callakrsos.

the class FieldMetaFunction method apply.

@Override
public List<FieldMeta> apply(List<TableModelDVO> models) {
    List<FieldMeta> fileMetaList = new ArrayList<>(models.size());
    for (TableModelDVO tableModel : models) {
        try {
            String fieldName = tableModel.getName();
            String type = tableModel.getType();
            FieldMeta fieldMeta = ClassTypeResourceLoader.getInstance().get(type);
            fieldMeta.setName(fieldName);
            fieldMeta.setModifier(Modifier.PRIVATE);
            if ("Y".equals(tableModel.getPk())) {
                fieldMeta.setPrimarykey(true);
            }
            fileMetaList.add(fieldMeta);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return fileMetaList;
}
Also used : FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) ArrayList(java.util.ArrayList) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)

Example 2 with TableModelDVO

use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO in project Gargoyle by callakrsos.

the class ExcelUtilTest method testToXlsxExcelSVO.

/**
	 * Test method for
	 * {@link com.kyj.fx.voeditor.visual.util.ExcelUtil#toXlsxExcelSVO(java.io.File)}
	 * .
	 * 
	 * @throws Exception
	 */
@Test
public final void testToXlsxExcelSVO() throws Exception {
    ExcelSVO xlsxExcelSVO = ExcelUtil.toK(createExcelFile, new BiFunction<File, Workbook, ExcelSVO>() {

        @Override
        public ExcelSVO apply(File file, Workbook xlsx) {
            ExcelSVO svo = new ExcelSVO();
            svo.setFile(file);
            int numberOfSheets = xlsx.getNumberOfSheets();
            for (int i = 0; i < numberOfSheets; i++) {
                Sheet sheetAt = xlsx.getSheetAt(i);
                String sheetName = xlsx.getSheetName(i);
                // 헤더부 처리
                {
                    Row columnRow = sheetAt.getRow(2);
                    short lastCellNum = columnRow.getLastCellNum();
                    ArrayList<ExcelColDVO> colList = new ArrayList<>();
                    for (int _cell = 0; _cell < lastCellNum; _cell++) {
                        Cell cell = columnRow.getCell(_cell);
                        String stringCellValue = cell.getStringCellValue();
                        ExcelColDVO excelColDVO = new ExcelColDVO();
                        excelColDVO.setColSeq(_cell);
                        excelColDVO.setColName(stringCellValue);
                        colList.add(excelColDVO);
                    }
                    svo.setColDvoList(sheetName, colList);
                }
                // 데이터부 처리
                for (int _row = 3; _row < sheetAt.getLastRowNum(); _row++) {
                    Row row = sheetAt.getRow(_row);
                    short lastCellNum = row.getLastCellNum();
                    for (int _cell = 0; _cell < lastCellNum; _cell++) {
                        Cell cell = row.getCell(_cell);
                        String value = cell.getStringCellValue();
                        svo.addSheetExcelDVO(sheetName, new ExcelDataDVO(_row, _cell, value));
                    }
                }
            }
            return svo;
        }
    });
    List<TableModelDVO> list = ExcelUtil.toK(createExcelFile, new BiFunction<File, Workbook, List<TableModelDVO>>() {

        @Override
        public List<TableModelDVO> apply(File file, Workbook xlsx) {
            List<TableModelDVO> llist = new ArrayList<>();
            Sheet sheetAt = xlsx.getSheetAt(0);
            // 헤더부 처리
            Row columnRow = sheetAt.getRow(2);
            ArrayList<ExcelColDVO> colList = new ArrayList<>();
            Cell _column = columnRow.getCell(0);
            Cell _type = columnRow.getCell(1);
            Cell _size = columnRow.getCell(2);
            Cell _comment = columnRow.getCell(3);
            // 데이터부 처리
            for (int _row = 3; _row < sheetAt.getLastRowNum(); _row++) {
                Row row = sheetAt.getRow(_row);
                Cell column = row.getCell(0);
                Cell type = row.getCell(1);
                Cell size = row.getCell(2);
                Cell comment = row.getCell(3);
                TableModelDVO modelDVO = new TableModelDVO();
                modelDVO.setName(column.getStringCellValue());
                modelDVO.setDabaseTypeName(type.getStringCellValue());
                modelDVO.setSize(size.getStringCellValue());
                modelDVO.setDesc(comment.getStringCellValue());
                llist.add(modelDVO);
            }
            return llist;
        }
    });
    System.out.println(list);
}
Also used : ExcelDataDVO(com.kyj.fx.voeditor.visual.excels.base.ExcelDataDVO) ArrayList(java.util.ArrayList) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) Workbook(org.apache.poi.ss.usermodel.Workbook) ExcelColDVO(com.kyj.fx.voeditor.visual.excels.base.ExcelColDVO) ArrayList(java.util.ArrayList) List(java.util.List) ExcelSVO(com.kyj.fx.voeditor.visual.excels.base.ExcelSVO) Row(org.apache.poi.ss.usermodel.Row) File(java.io.File) Sheet(org.apache.poi.ss.usermodel.Sheet) Cell(org.apache.poi.ss.usermodel.Cell) Test(org.junit.Test)

Example 3 with TableModelDVO

use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO in project Gargoyle by callakrsos.

the class SimpleSQLResultView method createColumns.

private void createColumns(List<TableModelDVO> columns) {
    ObservableList<TableColumn<Map<String, Object>, ?>> tableColumns = tbResult.getColumns();
    for (TableModelDVO column : columns) {
        String databaseColumnName = column.getDatabaseColumnName();
        TableColumn e = new TableColumn(databaseColumnName);
        e.setCellValueFactory(new MapValueFactory<Object>(databaseColumnName));
        tableColumns.add(e);
    }
}
Also used : TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) TableColumn(javafx.scene.control.TableColumn)

Example 4 with TableModelDVO

use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO 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);
    }
}
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) SimpleSQLResultView(com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) IOException(java.io.IOException) DatabaseTypeMappingFunction(com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction) FxDAOReadFunction(com.kyj.fx.voeditor.visual.functions.FxDAOReadFunction) Function(java.util.function.Function) FxDAOSaveFunction(com.kyj.fx.voeditor.visual.functions.FxDAOSaveFunction) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO) FXML(javafx.fxml.FXML)

Example 5 with TableModelDVO

use of kyj.Fx.dao.wizard.core.model.vo.TableModelDVO in project Gargoyle by callakrsos.

the class VoEditorController method btnGenerateOnMouseClick.

/********************************
	 * 작성일 : 2016. 6. 6. 작성자 : KYJ
	 *
	 * 생성 마우스 클릭
	 *
	 * @param me
	 ********************************/
public void btnGenerateOnMouseClick(MouseEvent me) {
    try {
        checkValidation();
        String className = txtClassName.getText();
        String location = txtLocation.getText();
        String packageName = txtPackageName.getText();
        String extendsBaseClass = ConfigResourceLoader.getInstance().get(ConfigResourceLoader.VOEDITOR_DEFAULT_EXTENDS_CLASS);
        ObservableList<TableModelDVO> items = tbVoEditor.getItems();
        ClassMeta classMeta = EditorUtil.extractedClassMeta(className, packageName, extendsBaseClass);
        VoEditorConverter converter = new VoEditorConverter(classMeta, items);
        VoEditor voEditor = converter.convert();
        if (location != null && !location.isEmpty()) {
            Optional<Pair<String, String>> showYesOrNoDialog = DialogUtil.showYesOrNoDialog("파일생성여부", "파일도 만드시겠습니까? ");
            showYesOrNoDialog.ifPresent(string -> {
                if ("Y".equals(string.getValue())) {
                    try {
                        voEditor.toFile(location);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        JavaTextView simpleTextView = new JavaTextView(voEditor.toText());
        simpleTextView.show();
    } catch (Exception e) {
        DialogUtil.showExceptionDailog(e);
        return;
    }
}
Also used : VoEditorConverter(com.kyj.fx.voeditor.visual.util.VoEditorConverter) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) TableModelDVO(kyj.Fx.dao.wizard.core.model.vo.TableModelDVO) FileNotFoundException(java.io.FileNotFoundException) GargoyleFileAlreadyExistException(com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException) ParseException(com.github.javaparser.ParseException) IOException(java.io.IOException) VoEditor(com.kyj.fx.voeditor.core.VoEditor) Pair(javafx.util.Pair)

Aggregations

TableModelDVO (kyj.Fx.dao.wizard.core.model.vo.TableModelDVO)16 List (java.util.List)7 File (java.io.File)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 TableMasterDVO (kyj.Fx.dao.wizard.core.model.vo.TableMasterDVO)5 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)4 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)4 DatabaseTypeMappingFunction (com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)4 ObservableList (javafx.collections.ObservableList)4 FXML (javafx.fxml.FXML)4 ParseException (com.github.javaparser.ParseException)3 FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)3 DatabaseTableView (com.kyj.fx.voeditor.visual.component.popup.DatabaseTableView)3 JavaTextView (com.kyj.fx.voeditor.visual.component.popup.JavaTextView)3 CommonContextMenuEvent (com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent)3 SQLException (java.sql.SQLException)3 TableDVO (kyj.Fx.dao.wizard.core.model.vo.TableDVO)3 VoEditor (com.kyj.fx.voeditor.core.VoEditor)2 EditorUtil (com.kyj.fx.voeditor.util.EditorUtil)2