Search in sources :

Example 6 with Trigger

use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.

the class DatabaseInfoTest method testGetTrigger.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getTrigger(java.lang.String)}
	 * .
	 */
public void testGetTrigger() {
    Trigger trigger = new Trigger();
    trigger.setName("trigger1");
    bean.setTriggerList(null);
    bean.setTriggerList(new ArrayList<Trigger>());
}
Also used : Trigger(com.cubrid.common.core.common.model.Trigger)

Example 7 with Trigger

use of com.cubrid.common.core.common.model.Trigger in project cubrid-manager by CUBRID.

the class CubridTriggerFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setTriggerList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        ITask task = null;
        if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
            task = new GetTriggerListTask(parent.getServer().getServerInfo());
            ((GetTriggerListTask) task).setDbName(database.getLabel());
        } else {
            task = new JDBCGetTriggerListTask(databaseInfo);
        }
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        List<Trigger> triggerList = null;
        if (task instanceof GetTriggerListTask) {
            triggerList = ((GetTriggerListTask) task).getTriggerInfoList();
        } else if (task instanceof JDBCGetTriggerListTask) {
            triggerList = ((JDBCGetTriggerListTask) task).getTriggerInfoList();
        }
        if (triggerList != null && !triggerList.isEmpty()) {
            for (Trigger trigger : triggerList) {
                String id = parent.getId() + NODE_SEPARATOR + trigger.getName();
                ICubridNode triggerNode = createTriggerNode(id, trigger);
                parent.addChild(triggerNode);
            }
        }
        databaseInfo.setTriggerList(triggerList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) Trigger(com.cubrid.common.core.common.model.Trigger) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) JDBCGetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerListTask) GetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.GetTriggerListTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) JDBCGetTriggerListTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.JDBCGetTriggerListTask)

Example 8 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 9 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 10 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