Search in sources :

Example 1 with DaoOfDatabaseSet

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);
            }
        }
    }
}
Also used : DaoOfDatabaseSet(com.ctrip.platform.dal.daogen.dao.DaoOfDatabaseSet) DaoOfDatabaseSet(com.ctrip.platform.dal.daogen.dao.DaoOfDatabaseSet) DalConfigHost(com.ctrip.platform.dal.daogen.host.DalConfigHost) JavaCodeGenContext(com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)

Aggregations

DaoOfDatabaseSet (com.ctrip.platform.dal.daogen.dao.DaoOfDatabaseSet)1 JavaCodeGenContext (com.ctrip.platform.dal.daogen.generator.java.JavaCodeGenContext)1 DalConfigHost (com.ctrip.platform.dal.daogen.host.DalConfigHost)1