use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TbImporter method loadTmDbConn.
/**
* 加载连接 ;
*/
private void loadTmDbConn() {
// 加载连接前先释放已经存在连接
releaseTmDbConn();
if (projConfiger != null) {
List<DatabaseModelBean> termdbList = projConfiger.getTermBaseDbs(true);
if (termdbList.size() == 0) {
return;
}
DatabaseModelBean dmb = termdbList.get(0);
if (dmb != null) {
this.dbOp = DatabaseService.getDBOperator(dmb.toDbMetaData());
try {
dbOp.start();
} catch (Exception e) {
logger.error(MessageFormat.format(Messages.getString("importer.TbImporter.logger1"), dmb.getDbType(), dmb.getDbName()), e);
dbOp = null;
}
}
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class TmDbOperatorManager method loadTmDbConn.
/**
* 加载连接 ;
*/
private void loadTmDbConn() {
// 加载连接前先释放已经存在连接
releaseTmDbConn();
if (projConfiger != null) {
List<DatabaseModelBean> tmDbConfigList = projConfiger.getAllTmDbs();
for (int i = 0; i < tmDbConfigList.size(); i++) {
DatabaseModelBean dmb = tmDbConfigList.get(i);
DBOperator db = DatabaseService.getDBOperator(dmb.toDbMetaData());
if (null == db) {
continue;
}
try {
db.start();
if (dmb.isDefault()) {
defaultDbInfo = dmb.getDbName();
this.dbOpList.add(0, db);
} else {
this.dbOpList.add(db);
}
} catch (Exception e) {
logger.error(MessageFormat.format(Messages.getString("tm.TmDbOperatorManager.logger1"), dmb.getDbType(), dmb.getDbName()), e);
}
}
}
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method getTermBaseDbs.
/**
* 获取项目的所有术语库
* @param isDefault
* 是否获取默认术语库
* @return 数据库参数列表List<DatabaseModelBean> {@link DatabaseModelBean};;
*/
public List<DatabaseModelBean> getTermBaseDbs(boolean isDefault) {
List<DatabaseModelBean> dbList = new ArrayList<DatabaseModelBean>();
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
if (isDefault) {
ap.selectXPath("/projectDescription/hs/tb/db[@default='Y']");
} else {
ap.selectXPath("/projectDescription/hs/tb/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);
}
dbList.add(dbm);
}
} catch (Exception e) {
logger.error(Messages.getString("file.ProjectConfiger.logger2"), e);
return dbList;
}
return dbList;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method getDefaultTMDb.
/**
* 获取当前项目的默认的记忆库,default='Y'
* @return 返回{@link DatabaseModelBean};
*/
public DatabaseModelBean getDefaultTMDb() {
try {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/projectDescription/hs/tm/db[@default='Y']");
if (ap.evalXPath() != -1) {
DatabaseModelBean dbm = new DatabaseModelBean();
dbm.setDefault(true);
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);
}
return dbm;
}
} catch (Exception e) {
logger.error(Messages.getString("file.ProjectConfiger.logger4"), e);
return null;
}
return null;
}
use of net.heartsome.cat.common.bean.DatabaseModelBean in project translationstudio8 by heartsome.
the class ProjectConfiger method createTbNode.
private String createTbNode(List<DatabaseModelBean> dbList) {
StringBuffer content = new StringBuffer();
content.append("\n\t\t<tb>");
for (int i = 0; i < dbList.size(); i++) {
DatabaseModelBean dbModel = dbList.get(i);
content.append(createDbNode(dbModel));
}
content.append("</tb>");
return content.toString();
}
Aggregations