use of com.ctrip.platform.dal.daogen.dao.DaoOfDatabaseSet in project dal by ctripcorp.
the class AbstractJavaDataPreparer method addDatabaseSet.
protected void addDatabaseSet(CodeGenContext codeGenCtx, String databaseSetName) throws SQLException {
DaoOfDatabaseSet daoOfDatabaseSet = BeanGetter.getDaoOfDatabaseSet();
List<DatabaseSet> sets = daoOfDatabaseSet.getAllDatabaseSetByName(databaseSetName);
if (null == sets || sets.isEmpty()) {
return;
}
JavaCodeGenContext ctx = (JavaCodeGenContext) codeGenCtx;
ContextHost contextHost = ctx.getContextHost();
DalConfigHost dalConfigHost = ctx.getDalConfigHost();
dalConfigHost.addDatabaseSet(sets);
for (DatabaseSet databaseSet : sets) {
List<DatabaseSetEntry> entries = daoOfDatabaseSet.getAllDatabaseSetEntryByDbsetid(databaseSet.getId());
if (entries == null || entries.isEmpty()) {
continue;
}
dalConfigHost.addDatabaseSetEntry(entries);
Map<String, DatabaseSetEntry> map = dalConfigHost.getDatabaseSetEntryMap();
for (DatabaseSetEntry entry : entries) {
String key = entry.getConnectionString();
if (map.containsKey(key)) {
DatabaseSetEntry value = map.get(key);
Resource resource = new Resource(value.getConnectionString(), value.getUserName(), value.getPassword(), value.getDbAddress(), value.getDbPort(), value.getDbCatalog(), value.getProviderName());
contextHost.addResource(resource);
}
}
}
}
Aggregations