Search in sources :

Example 11 with DatabaseModelBean

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;
            }
        }
    }
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) SQLException(java.sql.SQLException) ImportException(net.heartsome.cat.common.core.exception.ImportException)

Example 12 with DatabaseModelBean

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);
            }
        }
    }
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) DBOperator(net.heartsome.cat.database.DBOperator) SQLException(java.sql.SQLException)

Example 13 with DatabaseModelBean

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;
}
Also used : AutoPilot(com.ximpleware.AutoPilot) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) ArrayList(java.util.ArrayList) NavException(com.ximpleware.NavException) TranscodeException(com.ximpleware.TranscodeException) XPathEvalException(com.ximpleware.XPathEvalException) XPathParseException(com.ximpleware.XPathParseException) IOException(java.io.IOException) ModifyException(com.ximpleware.ModifyException) ParseException(com.ximpleware.ParseException)

Example 14 with DatabaseModelBean

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;
}
Also used : AutoPilot(com.ximpleware.AutoPilot) DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean) NavException(com.ximpleware.NavException) TranscodeException(com.ximpleware.TranscodeException) XPathEvalException(com.ximpleware.XPathEvalException) XPathParseException(com.ximpleware.XPathParseException) IOException(java.io.IOException) ModifyException(com.ximpleware.ModifyException) ParseException(com.ximpleware.ParseException)

Example 15 with DatabaseModelBean

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();
}
Also used : DatabaseModelBean(net.heartsome.cat.common.bean.DatabaseModelBean)

Aggregations

DatabaseModelBean (net.heartsome.cat.common.bean.DatabaseModelBean)71 ArrayList (java.util.ArrayList)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)16 SQLException (java.sql.SQLException)15 SelectionEvent (org.eclipse.swt.events.SelectionEvent)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 MenuItem (org.eclipse.swt.widgets.MenuItem)12 List (java.util.List)11 Point (org.eclipse.swt.graphics.Point)11 File (java.io.File)10 GridData (org.eclipse.swt.layout.GridData)10 GridLayout (org.eclipse.swt.layout.GridLayout)10 Button (org.eclipse.swt.widgets.Button)10 Composite (org.eclipse.swt.widgets.Composite)10 Label (org.eclipse.swt.widgets.Label)10 Menu (org.eclipse.swt.widgets.Menu)10 Iterator (java.util.Iterator)8 Map (java.util.Map)8 MetaData (net.heartsome.cat.common.bean.MetaData)8 HSDropDownButton (net.heartsome.cat.common.ui.HSDropDownButton)8