use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.
the class OracleDDLScript 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);
String objType = sqlSesseion.selectOne("sourceObjectType", dataParamInfo);
List srcScriptList = null;
if (StringUtils.contains(objType, "PROCEDURE")) {
if (ddlOption.isAddDropClause()) {
ddlStr.append("/* DROP PROCEDURE " + dataParamInfo.getObjectName() + "; */").append(BlankConstants.NEW_LINE_TWO);
}
ddlStr.append("CREATE OR REPLACE ");
srcScriptList = sqlSesseion.selectList("objectScriptSource", dataParamInfo);
for (int i = 0; i < srcScriptList.size(); i++) {
ddlStr.append(srcScriptList.get(i));
}
} else if (StringUtils.contains(objType, "PACKAGE")) {
if (ddlOption.isAddDropClause()) {
ddlStr.append(BlankConstants.NEW_LINE).append("/* DROP PACKAGE BODY " + name + "; */").append(BlankConstants.NEW_LINE_TWO);
;
ddlStr.append("/* DROP PACKAGE " + name + "; */").append(BlankConstants.NEW_LINE_TWO);
}
dataParamInfo.setObjectType("PACKAGE");
ddlStr.append("CREATE OR REPLACE ");
srcScriptList = sqlSesseion.selectList("objectScriptSource", dataParamInfo);
for (int i = 0; i < srcScriptList.size(); i++) {
ddlStr.append(srcScriptList.get(i));
}
dataParamInfo.setObjectType("PACKAGE BODY");
ddlStr.append("/ \n\n ");
ddlStr.append("CREATE OR REPLACE ");
srcScriptList = sqlSesseion.selectList("objectScriptSource", dataParamInfo);
for (int i = 0; i < srcScriptList.size(); i++) {
ddlStr.append(srcScriptList.get(i));
}
}
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.
the class OracleDDLScript 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;
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);
}
ddlStr.append("CREATE OR REPLACE ");
List scrList = sqlSesseion.selectList("objectScriptSource", dataParamInfo);
for (int i = 0; i < scrList.size(); i++) {
ddlStr.append(scrList.get(i));
}
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.
the class CubridDDLScript method getViews.
@Override
public List<DDLInfo> getViews(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
StringBuilder ddlStr;
SqlSession sqlSesseion = SQLManager.getInstance().sqlSessionTemplate(dataParamInfo.getVconnid());
List<DDLInfo> reval = new ArrayList<DDLInfo>();
DDLInfo ddlInfo;
for (String name : objNmArr) {
ddlStr = new StringBuilder();
ddlInfo = new DDLInfo();
ddlInfo.setName(name);
dataParamInfo.setObjectName(name);
if (ddlOption.isAddDropClause()) {
ddlStr.append("/* DROP ViEW " + dataParamInfo.getObjectName() + "; */").append(BlankConstants.NEW_LINE_TWO);
}
ParamMap source = sqlSesseion.selectOne("viewScript", dataParamInfo);
ddlStr.append("CREATE OR REPLACE VIEW ").append(name).append(" AS ").append(BlankConstants.NEW_LINE_TWO);
ddlStr.append(source.getString("Create View"));
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.
the class CubridDDLScript method getIndexs.
@Override
public List<DDLInfo> getIndexs(DatabaseParamInfo dataParamInfo, DDLCreateOption ddlOption, String... objNmArr) throws Exception {
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);
dataParamInfo.setObjectName(name);
ddlStr = new StringBuilder();
List srcScriptList = sqlSesseion.selectList("indexScript", dataParamInfo);
Map indexMap;
if (ddlOption.isAddDropClause()) {
if (srcScriptList.size() > 0) {
indexMap = (Map) srcScriptList.get(0);
ddlStr.append("/* DROP INDEX " + dataParamInfo.getObjectName() + " ON ").append(indexMap.get("TABLE_NAME")).append("; */").append(BlankConstants.NEW_LINE_TWO);
}
}
ddlStr.append("CREATE ");
if (srcScriptList.size() > 0) {
indexMap = (Map) srcScriptList.get(0);
if ("UQ".equals(indexMap.get("INDEX_TYPE")))
ddlStr.append(" UNIQUE INDEX ");
else {
ddlStr.append(" INDEX ");
}
ddlStr.append(indexMap.get("INDEX_NAME") + " ON ");
ddlStr.append(indexMap.get("TABLE_NAME") + "\n ( ");
for (int i = 0; i < srcScriptList.size(); i++) {
indexMap = (Map) srcScriptList.get(i);
ddlStr.append(i > 0 ? ", " : "");
ddlStr.append(indexMap.get("COLUMN_NAME"));
ddlStr.append(" ").append(indexMap.get("ASC_OR_DESC"));
}
ddlStr.append(")").append(BlankConstants.NEW_LINE);
}
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.varsql.core.db.valueobject.ddl.DDLInfo in project varsql by varsqlinfo.
the class PostgresqlDDLScript 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);
}
Map scriptInfo = sqlSesseion.selectOne("procedureScript", dataParamInfo);
ddlStr.append(scriptInfo.get(MetaColumnConstants.CREATE_SOURCE));
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
Aggregations