use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.
the class TriggerTest method testTrigger.
/**
* execute test contents
*
*/
public void testTrigger() {
String name = "name";
String conditionTime = "conditionTime";
String eventType = "eventType";
String target_class = "target_class";
String target_attribute = "target_attribute";
String condition = "condition";
String actionTime = "actionTime";
String actionType = "actionType";
String action = "action";
String status = "status";
String priority = "2";
Trigger trigger = new Trigger();
//test getters and setters
trigger.setName(name);
trigger.setConditionTime(conditionTime);
trigger.setEventType(eventType);
trigger.setTarget_class(target_class);
trigger.setTarget_att(target_attribute);
trigger.setCondition(condition);
trigger.setActionTime(actionTime);
trigger.setActionType(actionType);
trigger.setAction(action);
trigger.setStatus(status);
trigger.setPriority(priority);
//test public int compareTo(Trigger obj)
assertNotNull(trigger.compareTo(trigger));
//test public boolean equals(Object obj)
assertTrue(trigger.equals(trigger));
assertFalse(trigger.equals(null));
assertFalse(trigger.equals("other object"));
//test public int hashCode()
trigger.hashCode();
trigger.setAction("REJECT1");
trigger.setAction("INVALIDATE TRANSACTION1");
trigger.setAction("PRINT12");
trigger.setCondition(null);
trigger.setCondition("if you");
assertEquals(trigger.getName(), name);
assertEquals(trigger.getConditionTime(), conditionTime);
assertEquals(trigger.getEventType(), eventType);
assertEquals(trigger.getTarget_class(), target_class);
assertEquals(trigger.getTarget_att(), target_attribute);
assertEquals(trigger.getCondition(), "you");
assertEquals(trigger.getActionTime(), actionTime);
assertEquals(trigger.getActionType(), "PRINT");
assertEquals(trigger.getAction(), "");
assertEquals(trigger.getStatus(), status);
assertEquals(trigger.getPriority(), "02.00");
//assertNotNull(Trigger.formatPriority("0"));
}
use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.
the class ModelUtil method getTriggerList.
/**
* Parse triggerlist message TreeNode and return Trigger Object
*
* @param triggerlistnode TreeNode
* @return List<Trigger>
*/
public static List<Trigger> getTriggerList(TreeNode triggerlistnode) {
List<TreeNode> nodelist = triggerlistnode.getChildren();
List<Trigger> triggerlist = new ArrayList<Trigger>();
if (nodelist == null) {
return triggerlist;
}
for (TreeNode triggerinfo : nodelist) {
Trigger trigger = new Trigger();
SocketTask.setFieldValue(triggerinfo, trigger);
triggerlist.add(trigger);
}
return triggerlist;
}
use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.
the class TriggerDashboardEditorPart method dropTrigger.
/**
* dropTrigger
*/
public void dropTrigger() {
TableItem[] items = triggersDetailInfoTable.getTable().getSelection();
if (items.length > 0) {
List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
for (TableItem item : items) {
Trigger trigger = (Trigger) item.getData();
Set<String> typeSet = new HashSet<String>();
typeSet.add(NodeType.TRIGGER);
ICubridNode triggerNode = CommonUITool.findNode(database, typeSet, trigger.getName());
selectNodeList.add((ISchemaNode) triggerNode);
}
if (selectNodeList.size() > 0) {
DropTriggerAction action = (DropTriggerAction) ActionManager.getInstance().getAction(DropTriggerAction.ID);
ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
action.run(selectNodeList.toArray(nodeArr));
refresh();
}
} else {
CommonUITool.openWarningBox(Messages.errTriggerNoSelection);
}
}
use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.
the class NewTriggerAction method run.
/**
* Create trigger
* @param database CubridDatabase
*/
public void run(CubridDatabase database) {
CreateTriggerDialog dlg = new CreateTriggerDialog(getShell(), database);
ISelectionProvider provider = getSelectionProvider();
if (dlg.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTriggerFolderLoader.TRIGGER_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String triggerName = dlg.getTriggerName().toLowerCase(Locale.getDefault());
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + triggerName;
Trigger trigger = new Trigger();
trigger.setName(triggerName);
ICubridNode newNode = CubridTriggerFolderLoader.createTriggerNode(id, trigger);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
}
}
use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.
the class CreateTriggerDialog method getNewTrigger.
/**
*
* Get new trigger
*
* @return the Trigger object
*/
private Trigger getNewTrigger() {
// FIXME move this logic to core module
Trigger newTrigger = new Trigger();
String triggerName = triggerNameText.getText();
String triggerEventTargetTable = triggerTargetTableCombo.getText().trim();
String triggerEventTargetColumn = triggerTargetColumnCombo.getText().trim();
String eventTime = getEventTime();
String eventType = getEventType();
String triggerCondition = triggerConditionText.getText().trim();
String crChar = "\r";
String nlChar = "\n";
triggerCondition = triggerCondition.replaceAll(crChar, "");
triggerCondition = triggerCondition.replaceAll(nlChar, " ");
String triggerActionType = getActionType();
String triggerActionContent = triggerActionText.getText().trim();
triggerActionContent = triggerActionContent.replaceAll(crChar, "");
triggerActionContent = triggerActionContent.replaceAll(nlChar, " ");
String actionTime = getActionTime();
String triggerStatus = getStatus();
String strPriority = triggerPriorityText.getText();
newTrigger.setName(triggerName);
newTrigger.setEventType(eventType);
newTrigger.setTarget_class(triggerEventTargetTable);
newTrigger.setTarget_att(triggerEventTargetColumn);
newTrigger.setConditionTime(eventTime);
newTrigger.setAction(triggerActionContent);
newTrigger.setActionType(triggerActionType);
newTrigger.setActionTime(actionTime);
newTrigger.setCondition(triggerCondition);
newTrigger.setStatus(triggerStatus);
newTrigger.setPriority(strPriority);
if (isCommentSupport) {
String description = triggerDescriptionText.getText();
newTrigger.setDescription(description);
}
return newTrigger;
}
Aggregations