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