Search in sources :

Example 6 with TbpSysDaoColumnsDVO

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

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

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

the class GargoyleDaoBaseFxExtractDaoMethod method resultSetConverter.

/* (non-Javadoc)
	 * @see kyj.Fx.dao.wizard.core.DaoBaseResultSetStatement#resultSetConverter()
	 */
@Override
protected IResultSetConverter resultSetConverter() {
    return new FxDaoResultSetConverter() {

        @Override
        public String convert(String varName, String resultSetVarName, TbpSysDaoColumnsDVO col) {
            StringBuffer sb = new StringBuffer();
            String columnName = col.getColumnName();
            String columnType = col.getColumnType();
            String programType = col.getProgramType();
            sb.append(varName).append(".").append(setStatement(columnName)).append("(").append(getStatement(resultSetVarName, columnType, programType, columnName)).append(");");
            return sb.toString();
        }

        @Override
        public String getTypeTo(String columnType) {
            return DatabaseTypeMappingResourceLoader.getInstance().get(columnType);
        }

        private String setStatement(String dbColumnName) {
            String setter = "set" + getSetterStatement(dbColumnName);
            return setter;
        }

        private String getStatement(String resultSetVarName, String columnType, String programType, String dbColumnName) {
            String typeTo = getTypeTo(columnType);
            if (programType != null && !programType.isEmpty()) {
                typeTo = programType;
            }
            //ResultSet에서 getInteger라는 함수는 존재하지않으며, 대신 getInt라는 함수가 존재함.
            if ("Integer".equals(typeTo)) {
                typeTo = "Int";
            } else if ("Long".equals(typeTo)) {
                typeTo = "Long";
            } else if ("Double".equals(typeTo)) {
                typeTo = "Double";
            }
            return resultSetVarName + "." + "get" + typeTo + "(\"" + dbColumnName + "\")";
        }

        private String getSetterStatement(String str) {
            StringTokenizer stringTokenizer = new StringTokenizer(str, "_");
            String nextElement = null;
            char[] charArray = null;
            String temp = "";
            while (stringTokenizer.hasMoreElements()) {
                nextElement = (String) stringTokenizer.nextElement();
                charArray = nextElement.toCharArray();
                charArray[0] = Character.toUpperCase(charArray[0]);
                for (int i = 1; i < charArray.length; i++) {
                    charArray[i] = Character.toLowerCase(charArray[i]);
                }
                temp += String.valueOf(charArray);
            }
            return temp;
        }
    };
}
Also used : StringTokenizer(java.util.StringTokenizer) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) FxDaoResultSetConverter(kyj.Fx.dao.wizard.core.FxDaoResultSetConverter)

Example 9 with TbpSysDaoColumnsDVO

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

the class GargoyleDbUtilBaseFxExtractDaoMethod method resultSetConverter.

/* (non-Javadoc)
	 * @see kyj.Fx.dao.wizard.core.DaoBaseResultSetStatement#resultSetConverter()
	 */
@Override
protected IResultSetConverter resultSetConverter() {
    return new FxDaoResultSetConverter() {

        @Override
        public String convert(String varName, String resultSetVarName, TbpSysDaoColumnsDVO col) {
            StringBuffer sb = new StringBuffer();
            String columnName = col.getColumnName();
            String columnType = col.getColumnType();
            String programType = col.getProgramType();
            sb.append(varName).append(".").append(setStatement(columnName)).append("(").append(getStatement(resultSetVarName, columnType, programType, columnName)).append(");");
            return sb.toString();
        }

        @Override
        public String getTypeTo(String columnType) {
            return DatabaseTypeMappingResourceLoader.getInstance().get(columnType);
        }

        private String setStatement(String dbColumnName) {
            String setter = "set" + getSetterStatement(dbColumnName);
            return setter;
        }

        private String getStatement(String resultSetVarName, String columnType, String programType, String dbColumnName) {
            String typeTo = getTypeTo(columnType);
            if (programType != null && !programType.isEmpty()) {
                typeTo = programType;
            }
            //ResultSet에서 getInteger라는 함수는 존재하지않으며, 대신 getInt라는 함수가 존재함.
            if ("Integer".equals(typeTo)) {
                typeTo = "Int";
            } else if ("Long".equals(typeTo)) {
                typeTo = "Long";
            } else if ("Double".equals(typeTo)) {
                typeTo = "Double";
            }
            return resultSetVarName + "." + "get" + typeTo + "(\"" + dbColumnName + "\")";
        }

        private String getSetterStatement(String str) {
            StringTokenizer stringTokenizer = new StringTokenizer(str, "_");
            String nextElement = null;
            char[] charArray = null;
            String temp = "";
            while (stringTokenizer.hasMoreElements()) {
                nextElement = (String) stringTokenizer.nextElement();
                charArray = nextElement.toCharArray();
                charArray[0] = Character.toUpperCase(charArray[0]);
                for (int i = 1; i < charArray.length; i++) {
                    charArray[i] = Character.toLowerCase(charArray[i]);
                }
                temp += String.valueOf(charArray);
            }
            return temp;
        }
    };
}
Also used : StringTokenizer(java.util.StringTokenizer) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) FxDaoResultSetConverter(kyj.Fx.dao.wizard.core.FxDaoResultSetConverter)

Example 10 with TbpSysDaoColumnsDVO

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

the class GargoyleDbUtilBaseFxExtractDaoMethod method convert.

/* (non-Javadoc)
	 * @see kyj.Fx.dao.wizard.core.DaoBaseResultSetStatement#convert()
	 */
@Override
public String convert() {
    // 결과
    StringBuffer resultPart = new StringBuffer();
    // resultSet파트
    StringBuffer returnPart = new StringBuffer();
    // query 파트
    StringBuffer resultSetMappingPart = new StringBuffer();
    IRetrunStatement baseReturnStatement = getBaseReturnStatement();
    T mapper = getMapper();
    int appendTabKeyCount = getAppendTabKeyCount();
    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(), appendTabKeyCount);
}
Also used : IResultSetConverter(kyj.Fx.dao.wizard.core.IResultSetConverter) IRetrunStatement(kyj.Fx.dao.wizard.core.IRetrunStatement) TbpSysDaoColumnsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO) TbpSysDaoFieldsDVO(kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)

Aggregations

TbpSysDaoColumnsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoColumnsDVO)11 TbpSysDaoFieldsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoFieldsDVO)7 TbpSysDaoMethodsDVO (kyj.Fx.dao.wizard.core.model.vo.TbpSysDaoMethodsDVO)4 ClassMeta (com.kyj.fx.voeditor.core.model.meta.ClassMeta)3 FieldMeta (com.kyj.fx.voeditor.core.model.meta.FieldMeta)3 EditorUtil (com.kyj.fx.voeditor.util.EditorUtil)2 CommonsContextMenu (com.kyj.fx.voeditor.visual.component.CommonsContextMenu)2 LockImagedYnColumn (com.kyj.fx.voeditor.visual.component.LockImagedYnColumn)2 Menus (com.kyj.fx.voeditor.visual.component.Menus)2 NumberingCellValueFactory (com.kyj.fx.voeditor.visual.component.NumberingCellValueFactory)2 ResultDialog (com.kyj.fx.voeditor.visual.component.ResultDialog)2 BaseOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.BaseOpenClassResourceView)2 DatabaseTableView (com.kyj.fx.voeditor.visual.component.popup.DatabaseTableView)2 JavaTextView (com.kyj.fx.voeditor.visual.component.popup.JavaTextView)2 MeerketAbstractVoOpenClassResourceView (com.kyj.fx.voeditor.visual.component.popup.MeerketAbstractVoOpenClassResourceView)2 SimpleSQLResultView (com.kyj.fx.voeditor.visual.component.popup.SimpleSQLResultView)2 SqlKeywords (com.kyj.fx.voeditor.visual.component.text.SqlKeywords)2 CommonContextMenuEvent (com.kyj.fx.voeditor.visual.events.CommonContextMenuEvent)2 Wizardtype (com.kyj.fx.voeditor.visual.framework.daowizard.GargoyleDaoWizardFactory.Wizardtype)2 DatabaseTypeMappingFunction (com.kyj.fx.voeditor.visual.functions.DatabaseTypeMappingFunction)2