use of com.cubrid.cubridmanager.core.common.model.OnOffType in project cubrid-manager by CUBRID.
the class EditBackupPlanDialog method okPressed.
/**
* When press ok button,call it
*/
public void okPressed() {
// Gets the data of dialog
int intLever = leverCombo.getSelectionIndex();
if (intLever == 1 && !CommonUITool.openConfirmBox(Messages.msgLevelOneWarning)) {
return;
}
if (intLever == 2 && !CommonUITool.openConfirmBox(Messages.msgLevelTwoWarning)) {
return;
}
String newBackupid = idText.getText().trim();
String newPath = pathText.getText().trim();
String newPeriodType = periodGroup.getTextOfTypeCombo();
String newPeriodDate = periodGroup.getDetailValue();
String newTime = periodGroup.getTime();
String newLever = Integer.toString(intLever);
OnOffType newArchivedel = deleteButton.getSelection() ? OnOffType.ON : OnOffType.OFF;
OnOffType newUpdatestatus = updateButton.getSelection() ? OnOffType.ON : OnOffType.OFF;
String bkNum = null;
OnOffType newStroreold = null;
if (isBkNumSupports) {
newStroreold = OnOffType.OFF;
bkNum = String.valueOf(numKeepBackups.getSelection());
if (StringUtil.isEmpty(bkNum)) {
bkNum = "0";
}
} else {
newStroreold = storeButton.getSelection() ? OnOffType.ON : OnOffType.OFF;
bkNum = "0";
}
OnOffType newOnoff = onlineButton.getSelection() ? OnOffType.ON : OnOffType.OFF;
YesNoType newZip = useCompressButton.getSelection() ? YesNoType.Y : YesNoType.N;
YesNoType newCheck = checkingButton.getSelection() ? YesNoType.Y : YesNoType.N;
String newMt = Integer.valueOf(numThreadspinner.getSelection()).toString();
// Sets the object of backupPlanInfo
backupPlanInfo.setBackupid(newBackupid);
backupPlanInfo.setPath(newPath);
backupPlanInfo.setPeriod_type(newPeriodType);
backupPlanInfo.setPeriod_date(newPeriodDate);
backupPlanInfo.setTime(newTime);
backupPlanInfo.setLevel(newLever);
backupPlanInfo.setArchivedel(newArchivedel.getText());
backupPlanInfo.setUpdatestatus(newUpdatestatus.getText());
backupPlanInfo.setStoreold(newStroreold.getText());
backupPlanInfo.setOnoff(newOnoff.getText());
backupPlanInfo.setZip(newZip.getText());
backupPlanInfo.setCheck(newCheck.getText());
backupPlanInfo.setMt(newMt);
backupPlanInfo.setBknum(bkNum);
// Executes the task
ServerInfo serverInfo = database.getServer().getServerInfo();
BackupPlanTask backupPlanTask = new BackupPlanTask(opBackupInfo, serverInfo);
backupPlanTask.setDbname(database.getName());
backupPlanTask.setBackupid(newBackupid);
backupPlanTask.setPath(newPath);
backupPlanTask.setPeriodType(newPeriodType);
backupPlanTask.setPeriodDate(newPeriodDate);
backupPlanTask.setTime(newTime);
backupPlanTask.setLevel(newLever);
backupPlanTask.setArchivedel(newArchivedel);
backupPlanTask.setUpdatestatus(newUpdatestatus);
backupPlanTask.setStoreold(newStroreold);
backupPlanTask.setOnoff(newOnoff);
backupPlanTask.setZip(newZip);
backupPlanTask.setCheck(newCheck);
backupPlanTask.setMt(newMt);
backupPlanTask.setBknum(bkNum);
String taskName = Messages.bind(Messages.editBackupPlanTaskName, newBackupid);
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(backupPlanTask);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
super.okPressed();
}
}
use of com.cubrid.cubridmanager.core.common.model.OnOffType in project cubrid-manager by CUBRID.
the class GetAllClassesTaskExecutor method init.
/**
* initialize some values
*/
private void init() {
ServerInfo serverInfo = new ServerInfo();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
DatabaseInfo dbInfo = null;
OnOffType status = OnOffType.OFF;
if (isConnected) {
serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
if (dbInfo.getRunningType() == DbRunningType.CS) {
status = OnOffType.ON;
}
} else {
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
CMHostNodePersistManager.getInstance().addServer(ip, Integer.parseInt(port), userName, serverInfo);
MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
addTask(monitoringTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
addTask(getDatabaseListTask);
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
addTask(getUserInfoTask);
}
if (dbInfo == null || (dbInfo != null && !dbInfo.isLogined())) {
LoginDatabaseTask loginDbTask = new LoginDatabaseTask(serverInfo);
loginDbTask.setCMUser("admin");
loginDbTask.setDbName(dbName);
loginDbTask.setDbUser("dba");
loginDbTask.setDbPassword(dbaPassword);
addTask(loginDbTask);
UpdateCMUserTask updateCMUserTask = new UpdateCMUserTask(serverInfo);
updateCMUserTask.setCmUserName("admin");
updateCMUserTask.setCasAuth(CasAuthType.AUTH_ADMIN.getText());
updateCMUserTask.setDbCreator(DbCreateAuthType.AUTH_ADMIN.getText());
updateCMUserTask.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_ADMIN.getText());
addTask(updateCMUserTask);
}
GetClassListTask getClassListTask = new GetClassListTask(serverInfo);
getClassListTask.setDbName(dbName);
getClassListTask.setDbStatus(status);
addTask(getClassListTask);
}
use of com.cubrid.cubridmanager.core.common.model.OnOffType in project cubrid-manager by CUBRID.
the class GetAllClassesTaskExecutor method exec.
/**
* @see com.cubrid.common.ui.spi.progress.TaskExecutor#exec(org.eclipse.core.runtime.IProgressMonitor)
* @param monitor IProgressMonitor
* @return boolean
*/
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
boolean isConnected = false;
OnOffType status = OnOffType.OFF;
MonitorDashboardPreference monPref = new MonitorDashboardPreference();
for (ITask task : taskList) {
if (task instanceof MonitoringTask) {
MonitoringTask monitoringTask = (MonitoringTask) task;
monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
isConnected = true;
} else if (task instanceof UpdateCMUserTask) {
UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
ServerInfo serverInfo = updateCMUserTask.getServerInfo();
if (serverInfo != null && serverInfo.isConnected()) {
List<String> dbNameList = new ArrayList<String>();
List<String> dbUserList = new ArrayList<String>();
List<String> dbPasswordList = new ArrayList<String>();
List<String> dbBrokerPortList = new ArrayList<String>();
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
if (userInfo != null) {
List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
int size = authDatabaseList.size();
for (int i = 0; i < size; i++) {
DatabaseInfo databaseInfo = authDatabaseList.get(i);
dbNameList.add(databaseInfo.getDbName());
dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
if (databaseInfo.getDbName().equalsIgnoreCase(dbName)) {
password = dbaPassword;
dbUserList.add("dba");
} else {
dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
}
dbPasswordList.add(password == null ? "" : password);
}
}
}
String[] dbNameArr = new String[dbNameList.size()];
String[] dbUserArr = new String[dbUserList.size()];
String[] dbPasswordArr = new String[dbPasswordList.size()];
String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
updateCMUserTask.execute();
}
} else if (task instanceof GetClassListTask) {
GetClassListTask getClassListTask = (GetClassListTask) task;
if (status != OnOffType.OFF) {
getClassListTask.setDbStatus(status);
}
getClassListTask.execute();
dbClasses = getClassListTask.getDbClassInfo();
} else {
task.execute();
}
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
if (isConnected) {
disConnect();
}
return false;
}
if (openErrorBox(shell, msg, monitor)) {
if (isConnected) {
disConnect();
}
return false;
}
if (task instanceof GetDatabaseListTask) {
GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
DatabaseInfo dbInfo = databaseInfoList.get(i);
if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
DbRunningType type = dbInfo.getRunningType();
if (type == DbRunningType.CS) {
status = OnOffType.ON;
}
}
}
} else if (task instanceof GetCMUserListTask) {
ServerInfo serverInfo = ((GetCMUserListTask) task).getServerInfo();
if (serverInfo != null && serverInfo.isConnected()) {
GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
serverInfo.setLoginedUserInfo(userInfo);
break;
}
}
}
}
}
if (isConnected) {
disConnect();
}
return true;
}
Aggregations