Search in sources :

Example 6 with DDLInfo

use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.

the class CubridDDLScript method getTables.

@Override
public List<DDLInfo> getTables(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
    SqlSession client = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
    List<DDLInfo> reval = new ArrayList<DDLInfo>();
    DDLInfo ddlInfo;
    StringBuilder ddlStr;
    for (String name : objNmArr) {
        ddlStr = new StringBuilder();
        ddlInfo = new DDLInfo();
        ddlInfo.setName(name);
        dataParamInfo.setObjectName(name);
        if (ddlOption.isAddDropClause()) {
            ddlStr.append("/* DROP TABLE " + name + "; */").append(BlankConstants.NEW_LINE_TWO);
        }
        ParamMap source = client.selectOne("tableScript", dataParamInfo);
        ddlStr.append(source.getString("CREATE TABLE"));
        ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
        reval.add(ddlInfo);
    }
    return reval;
}
Also used : ParamMap(com.vartech.common.app.beans.ParamMap) SqlSession(org.apache.ibatis.session.SqlSession) ArrayList(java.util.ArrayList) DDLInfo(com.varsql.core.db.valueobject.ddl.DDLInfo)

Example 7 with DDLInfo

use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.

the class CubridDDLScript method getFunctions.

@Override
public List<DDLInfo> getFunctions(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
    logger.debug(" Function DDL Generation...");
    SqlSession sqlSesseion = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
    List<DDLInfo> reval = new ArrayList<DDLInfo>();
    DDLInfo ddlInfo;
    StringBuilder ddlStr;
    for (String name : objNmArr) {
        ddlInfo = new DDLInfo();
        ddlInfo.setName(name);
        ddlStr = new StringBuilder();
        dataParamInfo.setObjectName(name);
        if (ddlOption.isAddDropClause()) {
            ddlStr.append("/* DROP FUNCTION " + dataParamInfo.getObjectName() + "; */").append(BlankConstants.NEW_LINE_TWO);
        }
        List<Map> scriptInfoList = sqlSesseion.selectList("functionScript", dataParamInfo);
        Map param = scriptInfoList.get(0);
        StringBuffer argsSb = new StringBuffer();
        for (int i = 0; i < scriptInfoList.size(); i++) {
            Map scriptInfoMap = scriptInfoList.get(i);
            argsSb.append(scriptInfoMap.get("")).append(scriptInfoMap.get(""));
        }
        param.put("schema", dataParamInfo.getSchema());
        param.put("ddlOption", ddlOption);
        param.put("ARGUMENTS", argsSb.toString());
        ddlStr.append(SQLTemplateFactory.getInstance().sqlRender(dbType, SQLTemplateCode.FUNCTION.create, param));
        ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
        reval.add(ddlInfo);
    }
    return reval;
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) ArrayList(java.util.ArrayList) DDLInfo(com.varsql.core.db.valueobject.ddl.DDLInfo) ParamMap(com.vartech.common.app.beans.ParamMap) Map(java.util.Map)

Example 8 with DDLInfo

use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.

the class CubridDDLScript method getTriggers.

/**
 * @Method Name  : getTrigger
 * @Method 설명 : trigger ddl
 * @Method override : @see com.varsql.core.db.ddl.script.DDLScriptImpl#getTrigger(com.varsql.core.db.valueobject.DatabaseParamInfo, java.lang.String[])
 * @작성자   : ytkim
 * @작성일   : 2018. 9. 19.
 * @변경이력  :
 * @param dataParamInfo
 * @param objNmArr
 * @return
 * @throws Exception
 */
@Override
public List<DDLInfo> getTriggers(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
    logger.debug("Trigger DDL Generation...");
    SqlSession sqlSesseion = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
    List<DDLInfo> reval = new ArrayList<DDLInfo>();
    DDLInfo ddlInfo;
    StringBuilder ddlStr;
    boolean addFlag;
    for (String name : objNmArr) {
        ddlInfo = new DDLInfo();
        ddlInfo.setName(name);
        ddlStr = new StringBuilder();
        dataParamInfo.setObjectName(name);
        if (ddlOption.isAddDropClause()) {
            ddlStr.append("/* DROP Trigger " + dataParamInfo.getObjectName() + "; */").append(BlankConstants.NEW_LINE_TWO);
        }
        List<String> scrList = sqlSesseion.selectList("objectScriptSource", dataParamInfo);
        addFlag = false;
        for (int i = 0; i < scrList.size(); i++) {
            if (addFlag == false && !"".equals(StringUtils.trim(scrList.get(i)))) {
                addFlag = true;
            }
            if (addFlag) {
                ddlStr.append(scrList.get(i));
            }
        }
        ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
        reval.add(ddlInfo);
    }
    return reval;
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) ArrayList(java.util.ArrayList) DDLInfo(com.varsql.core.db.valueobject.ddl.DDLInfo)

Example 9 with DDLInfo

use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.

the class CubridDDLScript method getProcedures.

@Override
public List<DDLInfo> getProcedures(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
    logger.debug(" Procedure DDL Generation... ");
    SqlSession sqlSesseion = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
    List<DDLInfo> reval = new ArrayList<DDLInfo>();
    DDLInfo ddlInfo;
    StringBuilder ddlStr;
    for (String name : objNmArr) {
        ddlInfo = new DDLInfo();
        ddlInfo.setName(name);
        ddlStr = new StringBuilder();
        dataParamInfo.setObjectName(name);
        if (ddlOption.isAddDropClause()) {
            ddlStr.append("/* DROP PROCEDURE " + dataParamInfo.getObjectName() + "; */").append(BlankConstants.NEW_LINE_TWO);
        }
        List<Map> scriptInfoList = sqlSesseion.selectList("procedureScript", dataParamInfo);
        Map param = scriptInfoList.get(0);
        StringBuffer argsSb = new StringBuffer();
        for (int i = 0; i < scriptInfoList.size(); i++) {
            Map scriptInfoMap = scriptInfoList.get(i);
            argsSb.append(scriptInfoMap.get("")).append(scriptInfoMap.get(""));
        }
        param.put("schema", dataParamInfo.getSchema());
        param.put("ddlOption", ddlOption);
        param.put("ARGUMENTS", argsSb.toString());
        ddlStr.append(SQLTemplateFactory.getInstance().sqlRender(dbType, SQLTemplateCode.PROCEDURE.create, param));
        ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
        reval.add(ddlInfo);
    }
    return reval;
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) ArrayList(java.util.ArrayList) DDLInfo(com.varsql.core.db.valueobject.ddl.DDLInfo) ParamMap(com.vartech.common.app.beans.ParamMap) Map(java.util.Map)

Example 10 with DDLInfo

use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.

the class CubridDDLScript method getSequences.

/**
 * @Method Name  : getSequence
 * @Method 설명 : Sequence 구하기.
 * @Method override : @see com.varsql.core.db.ddl.script.DDLScriptImpl#getSequence(com.varsql.core.db.valueobject.DatabaseParamInfo, java.lang.String[])
 * @작성자   : ytkim
 * @작성일   : 2018. 9. 19.
 * @변경이력  :
 * @param dataParamInfo
 * @param objNmArr
 * @return
 * @throws Exception
 */
@Override
public List<DDLInfo> getSequences(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
    logger.debug("Sequence DDL Generation...");
    SqlSession sqlSesseion = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
    List<DDLInfo> reval = new ArrayList<DDLInfo>();
    DDLInfo ddlInfo;
    StringBuilder ddlStr;
    for (String name : objNmArr) {
        ddlInfo = new DDLInfo();
        ddlInfo.setName(name);
        ddlStr = new StringBuilder();
        dataParamInfo.setObjectName(name);
        Map param = sqlSesseion.selectOne("sequenceScript", dataParamInfo);
        param.put("schema", dataParamInfo.getSchema());
        param.put("ddlOption", ddlOption);
        ddlStr.append(SQLTemplateFactory.getInstance().sqlRender(dbType, SQLTemplateCode.SEQUENCE.create, param));
        ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
        reval.add(ddlInfo);
    }
    return reval;
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) ArrayList(java.util.ArrayList) DDLInfo(com.varsql.core.db.valueobject.ddl.DDLInfo) ParamMap(com.vartech.common.app.beans.ParamMap) Map(java.util.Map)

Aggregations

DDLInfo (com.varsql.core.db.valueobject.ddl.DDLInfo)62 ArrayList (java.util.ArrayList)61 SqlSession (org.apache.ibatis.session.SqlSession)60 ParamMap (com.vartech.common.app.beans.ParamMap)32 Map (java.util.Map)29 HashMap (java.util.HashMap)18 List (java.util.List)15 DataTypeImpl (com.varsql.core.db.meta.datatype.DataTypeImpl)4 DataTypeInfo (com.varsql.core.db.valueobject.DataTypeInfo)4 ProgressInfo (com.varsql.core.common.beans.ProgressInfo)1 VarsqlFileType (com.varsql.core.common.code.VarsqlFileType)1 BlankConstants (com.varsql.core.common.constants.BlankConstants)1 VarsqlConstants (com.varsql.core.common.constants.VarsqlConstants)1 SecurityUtil (com.varsql.core.common.util.SecurityUtil)1 SQLWriter (com.varsql.core.data.writer.SQLWriter)1 DBType (com.varsql.core.db.DBType)1 MetaControlBean (com.varsql.core.db.MetaControlBean)1 MetaControlFactory (com.varsql.core.db.MetaControlFactory)1 VarsqlReportConfig (com.varsql.core.db.report.VarsqlReportConfig)1 ObjectType (com.varsql.core.db.servicemenu.ObjectType)1