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>());
}
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));
}
}
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