use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class SystemDBOperator method checkDbConnection.
/**
* 测试数据库服务器连接,不适用于Internal DB
* @return false 连接失败, true 连接成功;
*/
public boolean checkDbConnection() {
Connection conn = null;
MetaData data = null;
try {
data = (MetaData) metaData.clone();
data.setDatabaseName("");
} catch (CloneNotSupportedException e) {
logger.warn("", e);
return false;
}
try {
String url = Utils.replaceParams(dbConfig.getDbURL(), data);
String driver = dbConfig.getDriver();
Properties prop = Utils.replaceParams(dbConfig.getConfigProperty(), data);
conn = getConnection(driver, url, prop);
} catch (ClassNotFoundException e) {
logger.error(Messages.getString("database.SystemDBOperator.logger1"), e);
return false;
} catch (SQLException e) {
logger.error(Messages.getString("database.SystemDBOperator.logger2"), e);
return false;
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
logger.warn("", e);
}
}
}
return true;
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class ExportDatabaseBean method equals.
@Override
public boolean equals(Object o) {
if (o instanceof ExportDatabaseBean) {
ExportDatabaseBean bean = (ExportDatabaseBean) o;
MetaData b = bean.getDbBean();
MetaData a = this.getDbBean();
String dbname = a.getDatabaseName();
String host = b.getServerName();
String port = a.getPort();
String instance = a.getInstance();
String localPath = a.getDataPath();
if (b.getDatabaseName().equals(dbname) && b.getServerName().equals(host) && b.getDataPath().equals(localPath) && b.getPort().equals(port) && b.getInstance().equals(instance)) {
return true;
}
}
return super.equals(o);
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class TmDbManagerDialog method resetInputValue.
/**
* 当选择数据库类型节点时,重置所有输入 ;
*/
private void resetInputValue() {
MetaData metaData = dbMetaDataMap.get(getCurrDbType());
currServer.setId("");
currServer.setDbType(metaData.getDbType());
currServer.setItlDBLocation("");
if (metaData.dataPathSupported()) {
currServer.setItlDBLocation(metaData.getDataPath());
}
currServer.setHost("");
if (metaData.serverNameSupported()) {
currServer.setHost(metaData.getServerName());
}
currServer.setInstance("");
if (metaData.instanceSupported()) {
currServer.setInstance(metaData.getInstance());
}
currServer.setPort("");
if (metaData.portSupported()) {
currServer.setPort(metaData.getPort());
}
currServer.setUserName("");
if (metaData.userNameSupported()) {
currServer.setUserName(metaData.getUserName());
}
currServer.setPassword("");
if (metaData.passwordSupported()) {
currServer.setPassword(metaData.getPassword());
}
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class TmDbManagerDialog method validator.
/**
* 输入验证器 ;
*/
private IStatus validator() {
String instance = currServer.getInstance();
String host = currServer.getHost();
String port = currServer.getPort();
String location = currServer.getItlDBLocation();
String username = currServer.getUserName();
MetaData dbMetaData = dbMetaDataMap.get(currServer.getDbType());
if (dbMetaData.dataPathSupported()) {
File f = new File(location);
if (location == null || location.trim().length() == 0) {
if (dbMetaData.getDbType().equals(Constants.DBTYPE_INTERNALDB)) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg5"));
} else if (dbMetaData.getDbType().equals(Constants.DBTYPE_SQLITE)) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg11"));
}
} else if (!f.exists()) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg12"));
}
}
if (dbMetaData.serverNameSupported()) {
if (host == null || host.trim().length() == 0) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg6"));
}
}
if (dbMetaData.portSupported()) {
if (port == null || port.trim().length() == 0) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg7"));
}
}
if (dbMetaData.userNameSupported()) {
if (username == null || username.trim().length() == 0) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg8"));
}
}
if (dbMetaData.instanceSupported()) {
if (instance == null || instance.trim().length() == 0) {
return ValidationStatus.error(Messages.getString("dialog.TmDbManagerDialog.msg9"));
}
}
return ValidationStatus.ok();
}
use of net.heartsome.cat.common.bean.MetaData in project translationstudio8 by heartsome.
the class TmDbManagerDialog method initUI.
/**
* 根据当前操作不同的数据库类型,初始化界面 ;
*/
private void initUI(boolean isAdd) {
MetaData curDbMetaData = dbMetaDataMap.get(getCurrDbType());
if (!isAdd) {
Control[] childrens = locationText.getParent().getChildren();
for (Control c : childrens) {
if (!(c instanceof Composite)) {
if (c instanceof Text || c instanceof Button) {
c.setEnabled(false);
}
} else {
Composite com = (Composite) c;
Control[] ch = com.getChildren();
for (Control chl : ch) {
if (c instanceof Text || c instanceof Button) {
chl.setEnabled(false);
}
}
}
}
} else {
if (curDbMetaData.dataPathSupported()) {
locationText.setEnabled(true);
borwserBtn.setEnabled(true);
} else {
locationText.setEnabled(false);
borwserBtn.setEnabled(false);
}
if (curDbMetaData.serverNameSupported()) {
hostText.setEnabled(true);
} else {
hostText.setEnabled(false);
}
if (curDbMetaData.instanceSupported()) {
instanceText.setEnabled(true);
} else {
instanceText.setEnabled(false);
}
if (curDbMetaData.portSupported()) {
portText.setEnabled(true);
} else {
portText.setEnabled(false);
}
if (curDbMetaData.userNameSupported()) {
usernameText.setEnabled(true);
} else {
usernameText.setEnabled(false);
}
if (curDbMetaData.passwordSupported()) {
passwordText.setEnabled(true);
} else {
passwordText.setEnabled(false);
}
}
}
Aggregations