use of com.vartech.common.app.beans.ParamMap in project varsql by varsqlinfo.
the class MysqlDDLScript 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);
}
ParamMap source = sqlSesseion.selectOne("functionScript", dataParamInfo);
ddlStr.append(source.getString("Create Function"));
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.vartech.common.app.beans.ParamMap in project varsql by varsqlinfo.
the class MysqlDDLScript 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;
}
use of com.vartech.common.app.beans.ParamMap in project varsql by varsqlinfo.
the class OracleDDLScript 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);
}
List<ParamMap> srcList = client.selectList("tableScript", dataParamInfo);
ddlStr.append("CREATE TABLE " + name + "(\n");
String dataType = "";
dataParamInfo.setObjectName(name);
DataTypeImpl dataTypeImpl = dbInstanceFactory.getDataTypeImpl();
ParamMap source;
for (int i = 0; i < srcList.size(); i++) {
source = srcList.get(i);
dataType = String.valueOf(source.get("DATA_TYPE"));
DataTypeInfo dataTypeInfo = dataTypeImpl.getDataType(dataType);
ddlStr.append("\t");
if (i > 0) {
ddlStr.append(",");
}
ddlStr.append(source.get(MetaColumnConstants.COLUMN_NAME)).append(" ");
ddlStr.append(DbMetaUtils.getTypeName(dataTypeInfo, null, dataTypeInfo.getDataTypeName(), source.getString(MetaColumnConstants.COLUMN_SIZE), source.getString(MetaColumnConstants.DECIMAL_DIGITS)));
ddlStr.append(getDefaultValue(source.getString("DATA_DEFAULT"), dataTypeInfo, true));
ddlStr.append(getNotNullValue(source.getString(MetaColumnConstants.NULLABLE)));
ddlStr.append(BlankConstants.NEW_LINE);
}
List srcPkList = client.selectList("tableScriptPk", dataParamInfo);
Map pkMap;
for (int i = 0; i < srcPkList.size(); i++) {
pkMap = (HashMap) srcPkList.get(i);
if (i == 0)
ddlStr.append(BlankConstants.TAB).append(",CONSTRAINT ").append(pkMap.get("CONSTRAINT_NAME")).append(" PRIMARY KEY ( ").append(pkMap.get("COLUMN_NAME"));
else {
ddlStr.append(", " + pkMap.get("COLUMN_NAME"));
}
if (i == srcPkList.size() - 1) {
ddlStr.append(")").append(BlankConstants.NEW_LINE);
}
}
ddlStr.append(");").append(BlankConstants.NEW_LINE_TWO);
List srcCommentList = client.selectList("tableScriptComments", dataParamInfo);
for (int i = 0; i < srcCommentList.size(); i++) {
ddlStr.append(srcCommentList.get(i)).append(BlankConstants.NEW_LINE);
}
if (srcCommentList.size() > 0) {
ddlStr.append(BlankConstants.NEW_LINE);
}
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(ddlStr.toString(), dbType));
reval.add(ddlInfo);
}
return reval;
}
use of com.vartech.common.app.beans.ParamMap 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.vartech.common.app.beans.ParamMap in project varsql by varsqlinfo.
the class PostgresqlDDLScript 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("VIEW_SOURCE"));
ddlInfo.setCreateScript(VarsqlFormatterUtil.ddlFormat(VarsqlFormatterUtil.addLastSemicolon(ddlStr, ddlOption), dbType));
reval.add(ddlInfo);
}
return reval;
}
Aggregations