use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.
the class CSharpDataPreparerOfSqlBuilderProcessor method buildExtraSqlBuilderHost.
private CSharpTableHost buildExtraSqlBuilderHost(CodeGenContext codeGenCtx, GenTaskBySqlBuilder sqlBuilder) throws Exception {
GenTaskByTableViewSp tableViewSp = new GenTaskByTableViewSp();
tableViewSp.setCud_by_sp(false);
tableViewSp.setPagination(false);
tableViewSp.setAllInOneName(sqlBuilder.getAllInOneName());
tableViewSp.setDatabaseSetName(sqlBuilder.getDatabaseSetName());
tableViewSp.setPrefix("");
tableViewSp.setSuffix("");
DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
String dbType = DbUtils.getDbType(sqlBuilder.getAllInOneName());
if (dbType != null && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
dbCategory = DatabaseCategory.MySql;
}
List<StoredProcedure> allSpNames = DbUtils.getAllSpNames(sqlBuilder.getAllInOneName());
return buildTableHost(codeGenCtx, tableViewSp, sqlBuilder.getTable_name(), dbCategory, allSpNames);
}
use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.
the class AbstractCSharpDataPreparer method getDatabaseCategory.
protected DatabaseCategory getDatabaseCategory(String dbName) throws Exception {
DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
String dbType = DbUtils.getDbType(dbName);
if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
dbCategory = DatabaseCategory.MySql;
}
return dbCategory;
}
use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.
the class AbstractJavaDataPreparer method getDatabaseCategory.
protected DatabaseCategory getDatabaseCategory(String allInOneName) throws Exception {
DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
String dbType = DbUtils.getDbType(allInOneName);
if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
dbCategory = DatabaseCategory.MySql;
}
return dbCategory;
}
use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.
the class CSharpDataPreparerOfFreeSqlProcessor method buildFreeSqlPojoHost.
private CSharpFreeSqlPojoHost buildFreeSqlPojoHost(CSharpCodeGenContext codeGenCtx, GenTaskByFreeSql task) throws Exception {
CSharpFreeSqlPojoHost freeSqlHost = new CSharpFreeSqlPojoHost();
List<CSharpParameterHost> pHosts = new ArrayList<>();
DatabaseCategory dbCategory = DatabaseCategory.SqlServer;
String dbType = DbUtils.getDbType(task.getAllInOneName());
if (dbType != null && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
dbCategory = DatabaseCategory.MySql;
}
List<AbstractParameterHost> list = DbUtils.testAQuerySql(task.getAllInOneName(), task.getSql_content(), task.getParameters(), new CsharpGivenSqlResultSetExtractor(dbCategory));
for (AbstractParameterHost _ahost : list) {
pHosts.add((CSharpParameterHost) _ahost);
}
freeSqlHost.setColumns(pHosts);
freeSqlHost.setTableName("");
String className = task.getPojo_name();
if (className.equalsIgnoreCase("简单类型")) {
freeSqlHost.setClassName(task.getMethod_name().substring(0, 1).toUpperCase() + task.getMethod_name().substring(1));
} else {
freeSqlHost.setClassName(CommonUtils.normalizeVariable(WordUtils.capitalize(task.getPojo_name())));
}
freeSqlHost.setNameSpace(codeGenCtx.getNamespace());
return freeSqlHost;
}
use of com.ctrip.platform.dal.daogen.enums.DatabaseCategory in project dal by ctripcorp.
the class GenTaskBySqlBuilderResource method getTableColumnSqlType.
/**
* @param set_name
* @param table_name
* @return <column alias, sqltype>
*/
private Map<String, Integer> getTableColumnSqlType(String set_name, String table_name) throws Exception {
DatabaseSetEntry databaseSetEntry = SpringBeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(set_name);
String dbName = databaseSetEntry.getConnectionString();
DatabaseCategory dbCategory = DbUtils.getDatabaseCategory(dbName);
List<AbstractParameterHost> paramsHost = DbUtils.getAllColumnNames(dbName, table_name, new JavaColumnNameResultSetExtractor(dbName, table_name, dbCategory));
Map<String, Integer> map = new HashMap<>();
if (paramsHost != null) {
for (int i = 0; i < paramsHost.size(); i++) {
JavaParameterHost paramHost = (JavaParameterHost) paramsHost.get(i);
map.put(paramHost.getAlias().toLowerCase(), paramHost.getSqlType());
}
}
return map;
}
Aggregations