Search in sources :

Example 1 with DbSpaceInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo in project cubrid-manager by CUBRID.

the class VolumeFolderInfoEditor method initialize.

/**
	 * Init the value of editor field
	 *
	 */
private void initialize() {
    // FIXME extract to utility class
    if (database == null || database.getDatabaseInfo() == null) {
        return;
    }
    if (database.getDatabaseInfo().getDbSpaceInfoList() == null) {
        return;
    }
    int totalSize = 0;
    int freeSize = 0;
    // String volumeType = "";
    Map<String, String> map3 = new HashMap<String, String>();
    map3.put("0", Messages.tblVolumeFolderType);
    map3.put("1", volumeType);
    spInfoListData.add(map3);
    Map<String, String> map2 = new HashMap<String, String>();
    map2.put("0", Messages.tblVolumeFolderVolumeCount);
    map2.put("1", dbSpaceList.size() + "                                                                                   ");
    spInfoListData.add(map2);
    for (DbSpaceInfo dbSpaceInfo : dbSpaceList) {
        totalSize += dbSpaceInfo.getTotalpage();
        freeSize += dbSpaceInfo.getFreepage();
    }
    if (!VolumeType.ACTIVE_LOG.toString().equalsIgnoreCase(volumeType) && !VolumeType.ARCHIVE_LOG.toString().equalsIgnoreCase(volumeType)) {
        Map<String, String> map4 = new HashMap<String, String>();
        map4.put("0", Messages.tblVolumeFolderFreeSize);
        map4.put("1", StringUtil.formatNumber(freeSize * (database.getDatabaseInfo().getDbSpaceInfoList().getPagesize() / (1048576.0f)), "#,###.##") + "M (" + StringUtil.formatNumber(freeSize, "#,###") + " pages)");
        spInfoListData.add(map4);
    }
    Map<String, String> map5 = new HashMap<String, String>();
    map5.put("0", Messages.tblVolumeFolderTotalSize);
    map5.put("1", StringUtil.formatNumber(totalSize * (database.getDatabaseInfo().getDbSpaceInfoList().getPagesize() / (1048576.0f)), "#,###.##") + "M (" + StringUtil.formatNumber(totalSize, "#,###") + " pages)");
    spInfoListData.add(map5);
    if (CompatibleUtil.isSupportLogPageSize(database.getServer().getServerInfo()) && (VolumeType.ACTIVE_LOG.toString().equalsIgnoreCase(volumeType) || VolumeType.ARCHIVE_LOG.toString().equalsIgnoreCase(volumeType))) {
        Map<String, String> map6 = new HashMap<String, String>();
        map6.put("0", Messages.tblVolumeFolderLogPageSize);
        map6.put("1", StringUtil.formatNumber(database.getDatabaseInfo().getDbSpaceInfoList().getLogpagesize(), "#,###") + " byte");
        spInfoListData.add(map6);
    } else {
        Map<String, String> map6 = new HashMap<String, String>();
        map6.put("0", Messages.tblVolumeFolderPageSize);
        map6.put("1", StringUtil.formatNumber(database.getDatabaseInfo().getDbSpaceInfoList().getPagesize(), "#,###") + " byte");
        spInfoListData.add(map6);
    }
    spaceNameLabel.setText(volumeFolderName);
    while (!spInfoListData.isEmpty()) {
        spInfoListData.remove(0);
    }
    if (spInfoTable != null && !spInfoTable.isDisposed()) {
        spInfoTableViewer.refresh();
        for (int i = 0; i < spInfoTable.getColumnCount(); i++) {
            spInfoTable.getColumn(i).pack();
        }
        for (int i = 0; i < (spInfoTable.getItemCount() + 1) / 2; i++) {
            spInfoTable.getItem(i * 2).setBackground(color);
        }
    }
}
Also used : HashMap(java.util.HashMap) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)

Example 2 with DbSpaceInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method getLogString.

private String getLogString(DBVolumeSpaceInfo volumeSpaceInfo, String type) {
    // FIXME extract
    long totalPage = 0;
    List<DbSpaceInfo> dbSpaceInfoList = volumeSpaceInfo.getVolumeSpaceInfo(type);
    if (dbSpaceInfoList != null) {
        for (DbSpaceInfo dbSpaceInfo : dbSpaceInfoList) {
            totalPage += dbSpaceInfo.getTotalpage();
        }
    }
    return getSpaceDesc(totalPage * volumeSpaceInfo.getPageSize());
}
Also used : DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)

Example 3 with DbSpaceInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo in project cubrid-manager by CUBRID.

the class RenameDatabaseDialog method initial.

/**
	 * 
	 * Initial data
	 * 
	 */
private void initial() {
    EnvInfo envInfo = database.getServer().getServerInfo().getEnvInfo();
    if (envInfo != null) {
        extVolumePath = envInfo.getDatabaseDir();
        extVolumePath = FileUtil.changeSeparatorByOS(extVolumePath, database.getServer().getServerInfo().getServerOsInfo());
        exVolumePathText.setText(extVolumePath);
    }
    String dir = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
    if (dir != null && dir.trim().length() > 0) {
        extVolumePath = dir;
        exVolumePathText.setText(extVolumePath);
    }
    if (spaceInfoList == null) {
        spaceInfoList = new ArrayList<Map<String, String>>();
        if (this.dbSpaceInfoList != null) {
            List<DbSpaceInfo> list = this.dbSpaceInfoList.getSpaceinfo();
            for (int i = 0; list != null && i < list.size(); i++) {
                Map<String, String> map = new HashMap<String, String>();
                DbSpaceInfo spaceInfo = list.get(i);
                String type = spaceInfo.getType();
                if (!VolumeType.GENERIC.getText().equals(type) && !VolumeType.DATA.getText().equals(type) && !VolumeType.INDEX.getText().equals(type) && !VolumeType.TEMP.getText().equals(type)) {
                    continue;
                }
                map.put("0", spaceInfo.getSpacename());
                map.put("1", spaceInfo.getSpacename());
                String location = spaceInfo.getLocation();
                location = FileUtil.changeSeparatorByOS(location, database.getServer().getServerInfo().getServerOsInfo());
                map.put("2", location);
                map.put("3", location);
                spaceInfoList.add(map);
            }
        }
    }
    volumeTableViewer.setInput(spaceInfoList);
    for (int i = 0; i < volumeTable.getColumnCount(); i++) {
        volumeTable.getColumn(i).pack();
    }
    databaseNameText.addModifyListener(this);
    exVolumePathText.addModifyListener(this);
}
Also used : HashMap(java.util.HashMap) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) Map(java.util.Map) HashMap(java.util.HashMap) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 4 with DbSpaceInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo in project cubrid-manager by CUBRID.

the class DeleteDatabaseDialog method initial.

/**
	 * 
	 * Init the value of dialog field
	 * 
	 */
private void initial() {
    dbNameText.setText(database.getName());
    List<Map<String, Object>> volumeTableListData = new ArrayList<Map<String, Object>>();
    for (DbSpaceInfo bean : dbSpaceInfo.getSpaceinfo()) {
        if (!bean.getType().equals("GENERIC") && !bean.getType().equals("DATA") && !bean.getType().equals("TEMP") && !bean.getType().equals("INDEX") && !bean.getType().equals("Active_log")) {
            continue;
        }
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("0", bean.getSpacename());
        map.put("1", bean.getLocation());
        map.put("2", bean.getDate());
        map.put("3", bean.getType());
        map.put("4", bean.getTotalpage() == 0 ? "" : (bean.getTotalpage() + ""));
        map.put("5", bean.getFreepage() == 0 ? "" : (bean.getFreepage() + ""));
        double mb = dbSpaceInfo.getPagesize() * bean.getTotalpage() / 1048576.0;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        nf.setGroupingUsed(false);
        String volsize = nf.format(mb) + "";
        map.put("6", volsize);
        volumeTableListData.add(map);
    }
    tableViewer.setInput(volumeTableListData);
    for (int i = 0; i < volumeTable.getColumnCount(); i++) {
        volumeTable.getColumn(i).pack();
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) HashMap(java.util.HashMap) Map(java.util.Map) NumberFormat(java.text.NumberFormat)

Example 5 with DbSpaceInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo in project cubrid-manager by CUBRID.

the class DatabaseModelTest method testModelDatabaseInfo.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void testModelDatabaseInfo() {
    DatabaseInfo bean = new DatabaseInfo(testDbName, serverInfo);
    bean.setDbName("dbName");
    assertEquals(bean.getDbName(), "dbName");
    bean.setLogined(true);
    assertTrue(bean.isLogined());
    bean.setDbDir("dbDir");
    assertEquals(bean.getDbDir(), "dbDir");
    bean.setRunningType(DbRunningType.CS);
    assertEquals(bean.getRunningType(), DbRunningType.CS);
    DbUserInfoList dbUserInfoList = new DbUserInfoList();
    bean.setDbUserInfoList(dbUserInfoList);
    assertTrue(bean.getDbUserInfoList() != null);
    DbUserInfo dbUserInfo = new DbUserInfo();
    bean.addDbUserInfo(dbUserInfo);
    bean.removeDbUserInfo(dbUserInfo);
    bean.setAuthLoginedDbUserInfo(dbUserInfo);
    assertEquals(bean.getAuthLoginedDbUserInfo(), dbUserInfo);
    bean.setBrokerPort("brokerPort");
    assertEquals(bean.getBrokerPort(), "brokerPort");
    bean.setTriggerList(new ArrayList());
    assertEquals(bean.getTriggerList() != null, true);
    bean.setUserTableInfoList(new ArrayList());
    assertEquals(bean.getUserTableInfoList() != null, true);
    bean.setUserViewInfoList(new ArrayList());
    assertEquals(bean.getUserViewInfoList() != null, true);
    bean.setSysTableInfoList(new ArrayList());
    assertEquals(bean.getSysTableInfoList() != null, true);
    bean.setSysViewInfoList(new ArrayList());
    assertEquals(bean.getSysViewInfoList() != null, true);
    bean.setPartitionedTableMap(new HashMap());
    assertEquals(bean.getPartitionedTableMap() != null, true);
    bean.setBackupPlanInfoList(new ArrayList());
    assertEquals(bean.getBackupPlanInfoList() != null, true);
    bean.setQueryPlanInfoList(new ArrayList());
    assertEquals(bean.getQueryPlanInfoList() != null, true);
    bean.setDbSpaceInfoList(new DbSpaceInfoList());
    assertEquals(bean.getDbSpaceInfoList() != null, true);
    bean.setDbUserInfoList(new DbUserInfoList());
    assertEquals(bean.getDbUserInfoList() != null, true);
    bean.setSpProcedureInfoList(new ArrayList());
    assertEquals(bean.getSpProcedureInfoList() != null, true);
    bean.setSpFunctionInfoList(new ArrayList());
    assertEquals(bean.getSpFunctionInfoList() != null, true);
    bean.setSerialInfoList(new ArrayList());
    assertEquals(bean.getSerialInfoList() != null, true);
    bean.setServerInfo(serverInfo);
    assertEquals(bean.getServerInfo() != null, true);
    bean.clear();
    bean.setLogined(true);
    assertEquals(bean.isLogined(), true);
    bean.addDbUserInfo(new DbUserInfo());
    bean.removeDbUserInfo(new DbUserInfo());
    bean.getClassInfoList();
    bean.addPartitionedTableList("dbname", null);
    bean.addBackupPlanInfo(new BackupPlanInfo());
    bean.removeBackupPlanInfo(new BackupPlanInfo());
    bean.removeAllBackupPlanInfo();
    bean.addQueryPlanInfo(new QueryPlanInfo());
    bean.removeQueryPlanInfo(new QueryPlanInfo());
    bean.removeAllQueryPlanInfo();
    bean.addSpaceInfo(new DbSpaceInfo());
    bean.removeSpaceInfo(new DbSpaceInfo());
    bean.getSpInfoList();
    bean.getSchemaInfo("tableName");
    bean.putSchemaInfo(new SchemaInfo());
    bean.clearSchemas();
    bean.getErrorMessage();
    bean.setDbUserInfoList(null);
    assertEquals(bean.getDbUserInfoList(), null);
    bean.addDbUserInfo(new DbUserInfo());
    bean.removeDbUserInfo(new DbUserInfo());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) HashMap(java.util.HashMap) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ArrayList(java.util.ArrayList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Aggregations

DbSpaceInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo)17 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)7 HashMap (java.util.HashMap)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 Map (java.util.Map)4 ArrayList (java.util.ArrayList)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 Point (org.eclipse.swt.graphics.Point)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 ITask (com.cubrid.common.core.task.ITask)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)1 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)1 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)1