use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class DalConfigHost method getDatabaseSetEntryMap.
public Map<String, DatabaseSetEntry> getDatabaseSetEntryMap() throws SQLException {
Map<String, DatabaseSetEntry> map = null;
if (databaseSetEntryMap != null && databaseSetEntryMap.size() > 0) {
map = new HashMap<>();
Set<String> set = new HashSet<>();
for (Map.Entry<Integer, DatabaseSetEntry> entry : databaseSetEntryMap.entrySet()) {
set.add(entry.getValue().getConnectionString());
}
List<DalGroupDB> dbs = BeanGetter.getDaoOfDalGroupDB().getGroupDbsByDbNames(set);
if (dbs != null && dbs.size() > 0) {
for (DalGroupDB db : dbs) {
DatabaseSetEntry e = new DatabaseSetEntry();
e.setConnectionString(db.getDbname());
e.setProviderName(db.getDb_providerName());
e.setDbAddress(db.getDb_address());
e.setDbPort(db.getDb_port());
e.setUserName(db.getDb_user());
e.setPassword(db.getDb_password());
e.setDbCatalog(db.getDb_catalog());
map.put(e.getConnectionString(), e);
}
}
}
return map;
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class GenTaskBySqlBuilderResource method buildPagingSQL.
@POST
@Path("buildPagingSQL")
public // dbset
Status buildPagingSQL(// dbset
@FormParam("db_name") String db_set_name, // C#风格或者Java风格
@FormParam("sql_style") String sql_style, @FormParam("sql_content") String sql_content) {
Status status = Status.OK();
try {
DatabaseSetEntry databaseSetEntry = BeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(db_set_name);
CurrentLanguage lang = "java".equals(sql_style) ? CurrentLanguage.Java : CurrentLanguage.CSharp;
String pagingSQL = SqlBuilder.pagingQuerySql(sql_content, DbUtils.getDatabaseCategory(databaseSetEntry.getConnectionString()), lang);
status.setInfo(pagingSQL);
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
return status;
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class DaoOfDatabaseSet method getAllDatabaseSetEntryByDbsetid.
public List<DatabaseSetEntry> getAllDatabaseSetEntryByDbsetid(Integer databaseSet_Id) throws SQLException {
FreeSelectSqlBuilder<List<DatabaseSetEntry>> builder = new FreeSelectSqlBuilder<>(dbCategory);
builder.setTemplate("SELECT id, name, databaseType, sharding, connectionString, databaseSet_Id, update_user_no, update_time FROM databasesetentry WHERE databaseSet_Id = ?");
StatementParameters parameters = new StatementParameters();
int i = 1;
parameters.set(i++, "databaseSet_Id", Types.INTEGER, databaseSet_Id);
builder.mapWith(databaseSetEntryRowMapper);
DalHints hints = DalHints.createIfAbsent(null).allowPartial();
List<DatabaseSetEntry> list = queryDao.query(builder, parameters, hints);
processEntryList(list);
return list;
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class GenTaskByFreeSqlResource method buildPagingSQL.
@POST
@Path("buildPagingSQL")
public // dbset// name
Status buildPagingSQL(// dbset// name
@FormParam("db_name") String db_set_name, // C#风格或者Java风格
@FormParam("sql_style") String sql_style, @FormParam("sql_content") String sql_content) {
try {
Status status = Status.OK();
DatabaseSetEntry databaseSetEntry = BeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(db_set_name);
CurrentLanguage lang = (sql_content.contains("@") || "csharp".equals(sql_style)) ? CurrentLanguage.CSharp : CurrentLanguage.Java;
String pagingSQL = SqlBuilder.pagingQuerySql(sql_content, DbUtils.getDatabaseCategory(databaseSetEntry.getConnectionString()), lang);
status.setInfo(pagingSQL);
return status;
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
Status status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
}
use of com.ctrip.platform.dal.daogen.entity.DatabaseSetEntry in project dal by ctripcorp.
the class AbstractCSharpDataPreparer method addDatabaseSet.
protected void addDatabaseSet(CodeGenContext codeGenCtx, String databaseSetName) throws SQLException {
CSharpCodeGenContext ctx = (CSharpCodeGenContext) codeGenCtx;
List<DatabaseSet> sets = daoOfDatabaseSet.getAllDatabaseSetByName(databaseSetName);
if (null == sets || sets.isEmpty())
return;
DalConfigHost dalConfigHost = ctx.getDalConfigHost();
dalConfigHost.addDatabaseSet(sets);
for (DatabaseSet databaseSet : sets) {
List<DatabaseSetEntry> entries = daoOfDatabaseSet.getAllDatabaseSetEntryByDbsetid(databaseSet.getId());
if (null == entries || entries.isEmpty())
continue;
dalConfigHost.addDatabaseSetEntry(entries);
}
}
Aggregations