Search in sources :

Example 11 with Trigger

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"));
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger)

Example 12 with Trigger

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;
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList)

Example 13 with Trigger

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);
    }
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger) DropTriggerAction(com.cubrid.common.ui.cubrid.trigger.action.DropTriggerAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) HashSet(java.util.HashSet)

Example 14 with Trigger

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));
    }
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CreateTriggerDialog(com.cubrid.common.ui.cubrid.trigger.dialog.CreateTriggerDialog) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 15 with Trigger

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;
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger)

Aggregations

Trigger (com.cubrid.common.core.common.model.Trigger)17 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)3 SQLException (java.sql.SQLException)3 ITask (com.cubrid.common.core.task.ITask)2 CreateTriggerDialog (com.cubrid.common.ui.cubrid.trigger.dialog.CreateTriggerDialog)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2 GetTriggerListTask (com.cubrid.cubridmanager.core.cubrid.trigger.task.GetTriggerListTask)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 TableItem (org.eclipse.swt.widgets.TableItem)2 SchemaComment (com.cubrid.common.core.schemacomment.model.SchemaComment)1 AlterTriggerAction (com.cubrid.common.ui.cubrid.trigger.action.AlterTriggerAction)1 DropTriggerAction (com.cubrid.common.ui.cubrid.trigger.action.DropTriggerAction)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 JDBCGetTriggerInfoTask (com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerInfoTask)1