use of com.cubrid.cubridmanager.core.cubrid.trigger.task.AddTriggerTask in project cubrid-manager by CUBRID.
the class CreateTriggerDialog method executeBySocket.
/**
*
* Execute to add or alter trigger by socket
*
* @param buttonId int
*/
private void executeBySocket(int buttonId) {
// FIXME remove
String taskName = null;
String message = null;
ITask executedTask = null;
if (buttonId == IDialogConstants.OK_ID) {
String eventType = getEventType();
String triggerEventTargetTable = triggerTargetTableCombo.getText().trim();
String triggerEventTargetColumn = triggerTargetColumnCombo.getText().trim();
AddTriggerTask task = new AddTriggerTask(database.getServer().getServerInfo());
task.setDbName(database.getName());
task.setTriggerName("\"" + triggerName + "\"");
String eventTime = getEventTime();
task.setConditionTime(TriggerConditionTime.eval(eventTime));
task.setEventType(TriggerEvent.eval(eventType));
String triggerActionType = getActionType();
String triggerAction = triggerActionText.getText().trim();
String crChar = "\r";
String nlChar = "\n";
triggerAction = triggerAction.replaceAll(crChar, "");
triggerAction = triggerAction.replaceAll(nlChar, " ");
task.setAction(Trigger.TriggerAction.eval(triggerActionType), triggerAction);
if (triggerEventTargetTable.length() > 0) {
if (triggerEventTargetColumn.length() > 0) {
task.setEventTarget("\"" + triggerEventTargetTable + "\"(\"" + triggerEventTargetColumn + "\")");
} else {
task.setEventTarget("\"" + triggerEventTargetTable + "\"");
}
}
String actionTime = getActionTime();
if (!actionTime.equals(Messages.actionTimeDefault)) {
// action time selected
task.setActionTime(TriggerActionTime.eval(actionTime));
}
String triggerCondition = triggerConditionText.getText().trim();
triggerCondition = triggerCondition.replaceAll(crChar, "");
triggerCondition = triggerCondition.replaceAll(nlChar, " ");
task.setCondition(triggerCondition);
String triggerStatus = this.getStatus();
task.setStatus(TriggerStatus.eval(triggerStatus));
String strPriority = triggerPriorityText.getText();
task.setPriority(strPriority);
taskName = Messages.bind(Messages.addTriggerTaskName, triggerName);
message = Messages.newTriggerSuccess;
executedTask = task;
} else if (buttonId == ALTER_TRIGGER_OK_ID) {
AlterTriggerTask task = new AlterTriggerTask(database.getServer().getServerInfo());
task.setDbName(database.getName());
task.setTriggerName(trigger.getName());
String triggerStatus = this.getStatus();
task.setStatus(TriggerStatus.eval(triggerStatus));
String strPriority = triggerPriorityText.getText();
task.setPriority(strPriority);
taskName = Messages.bind(Messages.alterTriggerTaskName, trigger.getName());
message = Messages.alterTriggerSuccess;
executedTask = task;
}
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(executedTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
setReturnCode(buttonId);
close();
CommonUITool.openInformationBox(Messages.msgInformation, message);
}
}
Aggregations