use of com.ctrip.platform.dal.daogen.host.DalConfigHost 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);
}
}
}
}
use of com.ctrip.platform.dal.daogen.host.DalConfigHost in project dal by ctripcorp.
the class JavaCodeGenContextCreator method process.
@Override
public void process(CodeGenContext context) throws Exception {
try {
JavaCodeGenContext ctx = (JavaCodeGenContext) context;
Project project = BeanGetter.getDaoOfProject().getProjectByID(ctx.getProjectId());
DalConfigHost dalConfigHost = null;
if (project.getDal_config_name() != null && !project.getDal_config_name().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getDal_config_name());
} else if (project.getNamespace() != null && !project.getNamespace().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getNamespace());
} else {
dalConfigHost = new DalConfigHost("");
}
ctx.setDalConfigHost(dalConfigHost);
ctx.setNamespace(project.getNamespace());
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
throw e;
}
}
use of com.ctrip.platform.dal.daogen.host.DalConfigHost 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);
}
}
use of com.ctrip.platform.dal.daogen.host.DalConfigHost in project dal by ctripcorp.
the class JavaDalGenerator method createContext.
@Override
public CodeGenContext createContext(int projectId, boolean regenerate, Progress progress, boolean newPojo, boolean ignoreApproveStatus) throws Exception {
JavaCodeGenContext ctx = null;
try {
ctx = new JavaCodeGenContext(projectId, regenerate, progress);
Project project = BeanGetter.getDaoOfProject().getProjectByID(projectId);
DalConfigHost dalConfigHost = null;
if (project.getDal_config_name() != null && !project.getDal_config_name().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getDal_config_name());
} else if (project.getNamespace() != null && !project.getNamespace().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getNamespace());
} else {
dalConfigHost = new DalConfigHost("");
}
ctx.setDalConfigHost(dalConfigHost);
ctx.setNamespace(project.getNamespace());
} catch (Exception e) {
LoggerManager.getInstance().error(e);
throw e;
}
return ctx;
}
use of com.ctrip.platform.dal.daogen.host.DalConfigHost in project dal by ctripcorp.
the class CSharpCodeGenContextCreator method process.
@Override
public void process(CodeGenContext context) throws Exception {
try {
CSharpCodeGenContext ctx = (CSharpCodeGenContext) context;
Project project = BeanGetter.getDaoOfProject().getProjectByID(ctx.getProjectId());
DalConfigHost dalConfigHost = null;
if (project.getDal_config_name() != null && !project.getDal_config_name().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getDal_config_name());
} else if (project.getNamespace() != null && !project.getNamespace().isEmpty()) {
dalConfigHost = new DalConfigHost(project.getNamespace());
} else {
dalConfigHost = new DalConfigHost("");
}
ctx.setDalConfigHost(dalConfigHost);
ctx.setNamespace(project.getNamespace());
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
throw e;
}
}
Aggregations