Search in sources :

Example 1 with TbpSysDaoFieldsDVO

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

the class DaoBaseResultSetStatement method convert.

public String convert() {
    // 결과
    StringBuffer resultPart = new StringBuffer();
    // resultSet파트
    StringBuffer returnPart = new StringBuffer();
    // query 파트
    StringBuffer resultSetMappingPart = new StringBuffer();
    String stringBufferVarName = mapper.getStringBufferVarName();
    String parameterMapVarName = mapper.getParameterMapVarName();
    String resultSetVarName = mapper.getResultSetVarName();
    String rowNumVarName = mapper.getRowNumVarName();
    List<TbpSysDaoFieldsDVO> inputFields = mapper.getT().getTbpSysDaoFieldsDVOList();
    List<TbpSysDaoColumnsDVO> columns = mapper.getT().getTbpSysDaoColumnsDVOList();
    String resultVoClass = mapper.getT().getResultVoClass();
    String type = getType(resultVoClass);
    /* 람다 expression */
    /* parameter part */
    returnPart.append(stringBufferVarName).append(".toString()").append(",");
    returnPart.append(parameterMapVarName).append(",(").append(resultSetVarName).append(",").append(rowNumVarName).append(")");
    returnPart.append("->{\n");
    /* [시작] Vo생성 statement */
    addImport(mapper.getFxDao(), resultVoClass);
    String varName = getVarName(resultVoClass);
    resultSetMappingPart.append(type).append(" ").append(varName).append(" = new ").append(type).append("();\n");
    /* [끝] Vo생성 statement */
    IResultSetConverter resultSetConverter = resultSetConverter();
    for (TbpSysDaoColumnsDVO col : columns) {
        String statement = resultSetConverter.convert(varName, resultSetVarName, col);
        resultSetMappingPart.append(statement).append("\n");
    }
    returnPart.append(applyedTabKeys(resultSetMappingPart.toString(), 1));
    returnPart.append(applyedTabKeys("return " + varName + ";", 1));
    returnPart.append("}\n");
    /* return문 베이스 */
    //.append(" query(").append(returnPart.toString()).append(");");
    resultPart.append(baseReturnStatement.returnKeyword()).append(baseReturnStatement.getReturnStatement(returnPart.toString()));
    return applyedTabKeys(resultPart.toString(), this.appendTabKeyCount);
}
Also used : TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)

Example 2 with TbpSysDaoFieldsDVO

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

the class DaoWizardTest method test.

/********************************
	 * 작성일 : 2016. 4. 16. 작성자 : KYJ
	 *
	 *
	 * DAO Wizard Test Case
	 *
	 * @throws Exception
	 ********************************/
@Test
public void test() throws Exception {
    // *******클래스 정보
    ClassMeta classMeta = new ClassMeta("Hello");
    // ******메소드 정보
    TbpSysDaoMethodsDVO methodMeta = new TbpSysDaoMethodsDVO(classMeta);
    // 메소드명
    methodMeta.setMethodName("simple");
    // SQL문
    methodMeta.setSqlBody("select 1 as ss from dual where name = :name");
    // 데이터베이스 타입에 대한정보
    TbpSysDaoColumnsDVO tbpSysDaoColumnsDVO = new TbpSysDaoColumnsDVO();
    tbpSysDaoColumnsDVO.setColumnName("name");
    tbpSysDaoColumnsDVO.setColumnType("VARCHAR");
    methodMeta.setTbpSysDaoColumnsDVOList(Arrays.asList(tbpSysDaoColumnsDVO));
    // 테스트 필드에 대한정보.. (이부분은 크게 중요치는않음.)
    TbpSysDaoFieldsDVO tbpSysDaoFieldsDVO = new TbpSysDaoFieldsDVO();
    tbpSysDaoFieldsDVO.setFieldName("name");
    tbpSysDaoFieldsDVO.setTestValue("kyj");
    tbpSysDaoFieldsDVO.setType("java.lang.String");
    methodMeta.setTbpSysDaoFieldsDVOList(Arrays.asList(tbpSysDaoFieldsDVO));
    // 리턴타입에 대한정보
    methodMeta.setResultVoClass("com.sample.Hello");
    // DAO생성을 위한준비
    DaoWizard<ClassMeta, TbpSysDaoMethodsDVO, FieldMeta> wizard = new DaoWizard(classMeta, Arrays.asList(methodMeta));
    // 반드시호출.
    wizard.build();
    // 확인
    System.out.println(wizard.toText());
    Assert.assertNotNull(wizard.toText());
}
Also used : TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) DaoWizard(kyj.Fx.dao.wizard.DaoWizard) ClassMeta(com.kyj.fx.voeditor.core.model.meta.ClassMeta) FieldMeta(com.kyj.fx.voeditor.core.model.meta.FieldMeta) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO) Test(org.junit.Test)

Example 3 with TbpSysDaoFieldsDVO

use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO 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 4 with TbpSysDaoFieldsDVO

use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO 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);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)

Example 5 with TbpSysDaoFieldsDVO

use of kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO 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));
    }
}
Also used : TbpSysDaoMethodsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO) FXML(javafx.fxml.FXML)

Aggregations

TbpSysDaoFieldsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)10 TbpSysDaoColumnsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO)6 TbpSysDaoMethodsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO)5 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)2 FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 FXML (javafx.fxml.FXML)2 DaoWizard (kyj.Fx.dao.wizard.DaoWizard)2 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