Search in sources :

Example 6 with EventProcessingPolicyRule

use of org.netxms.client.events.EventProcessingPolicyRule in project netxms by netxms.

the class ExportFileBuilder method doExport.

/**
 * Do export operation and call completion handler when done
 *
 * @param completionHandler
 */
private void doExport(final ExportCompletionHandler completionHandler) {
    final long[] eventList = new long[events.size()];
    int i = 0;
    for (EventObject o : events.values()) eventList[i++] = o.getCode();
    final long[] templateList = new long[templates.size()];
    i = 0;
    for (Template t : templates.values()) templateList[i++] = t.getObjectId();
    final long[] trapList = new long[traps.size()];
    i = 0;
    for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
    final UUID[] ruleList = new UUID[rules.size()];
    i = 0;
    for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
    final long[] scriptList = new long[scripts.size()];
    i = 0;
    for (Script s : scripts.values()) scriptList[i++] = s.getId();
    final long[] toolList = new long[tools.size()];
    i = 0;
    for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
    final long[] summaryTableList = new long[summaryTables.size()];
    i = 0;
    for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
    final long[] actionList = new long[actions.size()];
    i = 0;
    for (ServerAction a : actions.values()) actionList[i++] = a.getId();
    final String descriptionText = description.getText();
    new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    completionHandler.exportCompleted(xml);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExportFileBuilder_ExportJobError;
        }
    }.start();
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) Script(org.netxms.client.Script) SnmpTrap(org.netxms.client.snmp.SnmpTrap) EventObject(org.netxms.client.events.EventObject) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) UUID(java.util.UUID) ServerAction(org.netxms.client.ServerAction) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 7 with EventProcessingPolicyRule

use of org.netxms.client.events.EventProcessingPolicyRule in project netxms by netxms.

the class EventProcessingPolicyTest method testGetPolicy.

public void testGetPolicy() throws Exception {
    final NXCSession session = connect();
    EventProcessingPolicy p = session.getEventProcessingPolicy();
    for (EventProcessingPolicyRule r : p.getRules()) System.out.println("  " + r.getGuid() + " " + r.getComments());
    session.disconnect();
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) EventProcessingPolicy(org.netxms.client.events.EventProcessingPolicy)

Example 8 with EventProcessingPolicyRule

use of org.netxms.client.events.EventProcessingPolicyRule in project netxms by netxms.

the class NXCSession method saveEventProcessingPolicy.

/**
 * Save event processing policy. If policy was not previously open by current
 * session exception will be thrown.
 *
 * @param epp Modified event processing policy
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void saveEventProcessingPolicy(EventProcessingPolicy epp) throws IOException, NXCException {
    final List<EventProcessingPolicyRule> rules = epp.getRules();
    NXCPMessage msg = newMessage(NXCPCodes.CMD_SAVE_EPP);
    msg.setFieldInt32(NXCPCodes.VID_NUM_RULES, rules.size());
    sendMessage(msg);
    final long msgId = msg.getMessageId();
    waitForRCC(msgId);
    int id = 1;
    for (EventProcessingPolicyRule rule : rules) {
        msg = new NXCPMessage(NXCPCodes.CMD_EPP_RECORD);
        msg.setMessageId(msgId);
        msg.setFieldInt32(NXCPCodes.VID_RULE_ID, id++);
        rule.fillMessage(msg);
        sendMessage(msg);
    }
    // Wait for final confirmation if there was some rules
    if (rules.size() > 0)
        waitForRCC(msgId);
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) NXCPMessage(org.netxms.base.NXCPMessage) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint)

Example 9 with EventProcessingPolicyRule

use of org.netxms.client.events.EventProcessingPolicyRule in project netxms by netxms.

the class ExportFileBuilder method addRules.

/**
 * Add rules to list
 */
private void addRules() {
    RuleSelectionDialog dlg = new RuleSelectionDialog(getSite().getShell(), rulesCache);
    if (dlg.open() == Window.OK) {
        final Set<Long> eventCodes = new HashSet<Long>();
        for (EventProcessingPolicyRule r : dlg.getSelectedRules()) {
            rules.put(r.getRuleNumber(), r);
            for (Long e : r.getEvents()) {
                if (e >= 100000) {
                    eventCodes.add(e);
                }
            }
        }
        ruleViewer.setInput(rules.values().toArray());
        setModified();
        if (eventCodes.size() > 0) {
            for (EventObject o : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
                events.put(o.getCode(), o);
            }
            eventViewer.setInput(events.values().toArray());
        }
        ;
    }
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) RuleSelectionDialog(org.netxms.ui.eclipse.epp.dialogs.RuleSelectionDialog) EventObject(org.netxms.client.events.EventObject) HashSet(java.util.HashSet)

Example 10 with EventProcessingPolicyRule

use of org.netxms.client.events.EventProcessingPolicyRule in project netxms by netxms.

the class EventProcessingPolicyEditor method pasteRules.

/**
 * Paste rules from internal clipboard
 */
private void pasteRules() {
    int position = lastSelectedRule;
    RuleEditor anchor = null;
    if (position < ruleEditors.size() - 1) {
        for (int i = position; i < ruleEditors.size(); i++) if (!ruleEditors.get(i).isDisposed()) {
            anchor = ruleEditors.get(i);
            break;
        }
    }
    for (EventProcessingPolicyRule rule : clipboard.paste()) {
        rule.setRuleNumber(position + 1);
        policy.insertRule(rule, position);
        RuleEditor editor = new RuleEditor(dataArea, rule, this);
        ruleEditors.add(position, editor);
        GridData gd = new GridData();
        gd.horizontalAlignment = SWT.FILL;
        gd.grabExcessHorizontalSpace = true;
        editor.setLayoutData(gd);
        if (anchor != null)
            editor.moveAbove(anchor);
        position++;
    }
    for (int i = position; i < ruleEditors.size(); i++) ruleEditors.get(i).setRuleNumber(i + 1);
    updateEditorAreaLayout();
    setModified(true);
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) GridData(org.eclipse.swt.layout.GridData) RuleEditor(org.netxms.ui.eclipse.epp.widgets.RuleEditor)

Aggregations

EventProcessingPolicyRule (org.netxms.client.events.EventProcessingPolicyRule)10 RuleEditor (org.netxms.ui.eclipse.epp.widgets.RuleEditor)4 GridData (org.eclipse.swt.layout.GridData)3 NXCPMessage (org.netxms.base.NXCPMessage)2 EventObject (org.netxms.client.events.EventObject)2 EventProcessingPolicy (org.netxms.client.events.EventProcessingPolicy)2 AccessPoint (org.netxms.client.objects.AccessPoint)2 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Script (org.netxms.client.Script)1 ServerAction (org.netxms.client.ServerAction)1 DciSummaryTableDescriptor (org.netxms.client.datacollection.DciSummaryTableDescriptor)1 EventTemplate (org.netxms.client.events.EventTemplate)1 Template (org.netxms.client.objects.Template)1 ObjectTool (org.netxms.client.objecttools.ObjectTool)1 SnmpTrap (org.netxms.client.snmp.SnmpTrap)1