use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ShowRadioInterfaces method selectionChanged.
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
if ((obj instanceof AbstractNode) && ((AbstractNode) obj).isWirelessController()) {
action.setEnabled(true);
objectId = ((AbstractObject) obj).getObjectId();
} else {
action.setEnabled(false);
objectId = 0;
}
} else {
action.setEnabled(false);
objectId = 0;
}
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ExpansionTest method testNodeAndAlarmExpanssion.
public void testNodeAndAlarmExpanssion() throws Exception {
final NXCSession session = connect();
session.syncObjects();
final AbstractNode object = (AbstractNode) session.findObjectById(TestConstants.NODE_ID);
final Map<Long, Alarm> alarms = session.getAlarms();
final Map<String, String> inputValues = new HashMap<String, String>();
final Alarm alarm = alarms.values().iterator().next();
inputValues.put("Key1", "Value1");
inputValues.put("Key2", "Value2");
final List<String> stringsToExpand = new ArrayList<String>();
stringsToExpand.add("%%%a%A");
stringsToExpand.add("%g%I");
stringsToExpand.add("%K%n%U");
stringsToExpand.add("%(Key1)%(Key2)");
final List<String> expandedStrings = session.substitureMacross(new ObjectContextBase(object, alarm), stringsToExpand, inputValues);
assertEquals("%" + object.getPrimaryIP().getHostAddress().toString() + alarm.getMessage(), expandedStrings.get(0));
assertEquals(object.getGuid().toString() + object.getObjectId(), expandedStrings.get(1));
assertEquals(alarm.getKey() + object.getObjectName() + session.getUserName(), expandedStrings.get(2));
session.disconnect();
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class CreateSnmpDci method createDci.
/**
* @param session
* @param value
* @param description
* @param pollingInterval
* @param retentionTime
* @param deltaCalculation
* @param lockRequired
* @throws Exception
*/
private static void createDci(NXCSession session, SnmpValue value, String description, int pollingInterval, int retentionTime, int deltaCalculation, Map<Long, Boolean> lockRequired) throws Exception {
AbstractNode node = (AbstractNode) session.findObjectById(value.getNodeId(), AbstractNode.class);
if (node == null)
throw new NXCException(RCC.INTERNAL_ERROR);
DataCollectionConfiguration dcc;
if (lockRequired.get(node.getObjectId())) {
dcc = session.openDataCollectionConfiguration(node.getObjectId());
} else {
dcc = new DataCollectionConfiguration(session, node.getObjectId());
}
final DataCollectionItem dci = (DataCollectionItem) dcc.findItem(dcc.createItem(null), DataCollectionItem.class);
dci.setPollingInterval(pollingInterval);
dci.setRetentionTime(retentionTime);
dci.setOrigin(DataCollectionItem.SNMP);
dci.setDataType(dciTypeFromAsnType(value.getType()));
dci.setStatus(DataCollectionItem.ACTIVE);
dci.setDescription(description);
dci.setDeltaCalculation(deltaCalculation);
dci.setName(value.getName());
dcc.modifyObject(dci);
if (lockRequired.get(node.getObjectId())) {
dcc.close();
}
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ShowObjectEvents method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
ColumnFilter cf = new ColumnFilter();
cf.setOperation(ColumnFilterSetOperation.OR);
for (Object o : ((IStructuredSelection) selection).toList()) {
if (!(o instanceof AbstractObject))
continue;
cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
}
try {
// $NON-NLS-1$
LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "EventLog", IWorkbenchPage.VIEW_ACTIVATE);
LogFilter filter = new LogFilter();
// $NON-NLS-1$
filter.setColumnFilter("event_source", cf);
List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
// $NON-NLS-1$
orderingColumns.add(new OrderingColumn("event_timestamp", Messages.get().ShowObjectEvents_Time, true));
filter.setOrderingColumns(orderingColumns);
view.queryWithFilter(filter);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectEvents_Error, String.format(Messages.get().ShowObjectEvents_CannotOpenLogViewer, e.getMessage()));
}
return null;
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ShowObjectSyslog method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
ColumnFilter cf = new ColumnFilter();
cf.setOperation(ColumnFilterSetOperation.OR);
for (Object o : ((IStructuredSelection) selection).toList()) {
if (!(o instanceof AbstractObject))
continue;
cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
}
try {
// $NON-NLS-1$
LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "syslog", IWorkbenchPage.VIEW_ACTIVATE);
LogFilter filter = new LogFilter();
// $NON-NLS-1$
filter.setColumnFilter("source_object_id", cf);
List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
// $NON-NLS-1$
orderingColumns.add(new OrderingColumn("msg_timestamp", Messages.get().ShowObjectSyslog_Time, true));
filter.setOrderingColumns(orderingColumns);
view.queryWithFilter(filter);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSyslog_Error, String.format(Messages.get().ShowObjectSyslog_ErrorOpenLogViewer, e.getMessage()));
}
return null;
}
Aggregations