use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TmDbManagerDialog method addServerWithExistCheck.
/**
* 将当前操作的服务器配置信息添加到配置文件中<br>
* 在添加前,先判断该服务器是否已经存在,如果已经存在则更新
* @param currServer
* 需要处理的配置信息
* @param currDbTypeServers
* 当前数据库类型下的所有服务器,用于显示在界面上;
*/
private void addServerWithExistCheck(DatabaseModelBean currServer, List<DatabaseModelBean> currDbTypeServers) {
DatabaseModelBean bean = currServer.copyToOtherIntance(new DatabaseModelBean());
String existSerId = configer.isServerExist(bean, getCurrDbMetaData());
if (existSerId != null && !existSerId.equals("")) {
if (!bean.getId().equals(existSerId)) {
configer.deleteServerById(bean.getId());
for (DatabaseModelBean temp : currDbTypeServers) {
if (temp.getId().equals(bean.getId())) {
currDbTypeServers.remove(temp);
break;
}
}
}
bean.setId(existSerId);
currServer.setId(existSerId);
updateServer(bean, currDbTypeServers);
return;
}
configer.addServerConfig(bean);
currDbTypeServers.add(bean);
setLastSelectedServer(bean.getId());
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TermViewerBodyMenu method getDbOperator.
DBOperator getDbOperator(IProject project) {
if (null == project) {
return null;
}
ProjectConfiger projectConfiger = ProjectConfigerFactory.getProjectConfiger(project);
List<DatabaseModelBean> termBaseDbs = projectConfiger.getTermBaseDbs(true);
if (null == termBaseDbs || termBaseDbs.isEmpty()) {
return null;
}
return DatabaseService.getDBOperator(termBaseDbs.get(0).toDbMetaData());
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method createTmNode.
private String createTmNode(List<DatabaseModelBean> dbList) {
StringBuffer content = new StringBuffer();
content.append("\n\t\t<tm>");
for (int i = 0; i < dbList.size(); i++) {
DatabaseModelBean dbModel = dbList.get(i);
content.append(createDbNode(dbModel));
}
content.append("</tm>");
return content.toString();
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method getAllTmDbs.
/**
* 获取当前项目的所有翻译记忆库
* @return 数据库参数列表List<DatabaseModelBean> {@link DatabaseModelBean};
*/
public List<DatabaseModelBean> getAllTmDbs() {
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/projectDescription/hs/tm/db");
while (ap.evalXPath() != -1) {
DatabaseModelBean dbm = new DatabaseModelBean();
String defaultAttr = vu.getCurrentElementAttribut("default", "N");
if (defaultAttr.equals("Y")) {
dbm.setDefault(true);
} else {
dbm.setDefault(false);
}
dbm.setDbType(vu.getChildContent("type"));
dbm.setDbName(vu.getChildContent("name"));
dbm.setItlDBLocation(vu.getChildContent("location"));
dbm.setInstance(vu.getChildContent("instance"));
dbm.setHost(vu.getChildContent("server"));
dbm.setPort(vu.getChildContent("port"));
dbm.setUserName(vu.getChildContent("user"));
dbm.setPassword(DESImpl.decrypt(vu.getChildContent("password")));
String hasMatch = vu.getChildContent("hasmatch");
if (hasMatch.equals("true")) {
dbm.setHasMatch(true);
} else {
dbm.setHasMatch(false);
}
if (dbm.isDefault()) {
dbList.add(0, dbm);
} else {
dbList.add(dbm);
}
}
} catch (Exception e) {
logger.error(Messages.getString("file.ProjectConfiger.logger3"), e);
return dbList;
}
return dbList;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method getReferrenceTMDbs.
/**
* 获取当前项目的所有参考翻译记忆库,default='N'
* @return 数据库参数列表List<DatabaseModelBean> {@link DatabaseModelBean};
*/
public List<DatabaseModelBean> getReferrenceTMDbs() {
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/projectDescription/hs/tm/db[@default='N']");
while (ap.evalXPath() != -1) {
DatabaseModelBean dbm = new DatabaseModelBean();
dbm.setDefault(false);
dbm.setDbType(vu.getChildContent("type"));
dbm.setDbName(vu.getChildContent("name"));
dbm.setItlDBLocation(vu.getChildContent("location"));
dbm.setInstance(vu.getChildContent("instance"));
dbm.setHost(vu.getChildContent("server"));
dbm.setPort(vu.getChildContent("port"));
dbm.setUserName(vu.getChildContent("user"));
dbm.setPassword(DESImpl.decrypt(vu.getChildContent("password")));
String hasMatch = vu.getChildContent("hasmatch");
if (hasMatch.equals("true")) {
dbm.setHasMatch(true);
} else {
dbm.setHasMatch(false);
}
dbList.add(dbm);
}
} catch (Exception e) {
logger.error(Messages.getString("file.ProjectConfiger.logger5"), e);
return dbList;
}
return dbList;
}
Aggregations