use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.
the class LastValues method init.
/* (non-Javadoc)
* @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
*/
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
settings = Activator.getDefault().getDialogSettings();
initShowFilter = safeCast(settings.get("LastValuesView"), settings.getBoolean("LastValuesView"), initShowFilter);
session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject obj = session.findObjectById(Long.parseLong(site.getSecondaryId()));
dcTarget = ((obj != null) && (obj instanceof DataCollectionTarget)) ? (DataCollectionTarget) obj : null;
setPartName(Messages.get().LastValues_PartNamePrefix + ((dcTarget != null) ? dcTarget.getObjectName() : Messages.get().LastValues_Error));
}
use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.
the class LastValues method createClientArea.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.objectview.objecttabs.elements.OverviewPageElement#createClientArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createClientArea(Composite parent) {
viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.HIDE_SELECTION | SWT.H_SCROLL | SWT.MULTI);
setupTable();
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new OverviewDciLabelProvider());
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
return ((DciValue) e1).getDescription().compareToIgnoreCase(((DciValue) e2).getDescription());
}
});
viewer.setInput(((DataCollectionTarget) getObject()).getOverviewDciData().toArray());
viewer.getTable().getColumn(0).pack();
viewer.getTable().getColumn(1).pack();
createPopupMenu();
refreshController.setInterval(30);
refresh();
return viewer.getTable();
}
use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.
the class DataCollectionTest method testGetThresholdSummary.
public void testGetThresholdSummary() throws Exception {
final NXCSession session = connect();
session.syncObjects();
final List<ThresholdViolationSummary> list = session.getThresholdSummary(1);
for (ThresholdViolationSummary s : list) {
DataCollectionTarget target = (DataCollectionTarget) session.findObjectById(s.getNodeId(), DataCollectionTarget.class);
System.out.println("* " + target.getObjectName());
if (s.getDciList().size() > 0) {
for (DciValue v : s.getDciList()) {
System.out.println(" + " + v.getDescription());
}
} else {
System.out.println(" --- no threshold violations");
}
}
session.disconnect();
}
use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.
the class HistoricalData method get.
/* (non-Javadoc)
* @see org.netxms.websvc.handlers.AbstractHandler#get(java.lang.String)
*/
@Override
protected Object get(String id, Map<String, String> query) throws Exception {
NXCSession session = getSession();
AbstractObject obj = getObject();
long dciId = 0;
try {
dciId = Long.parseLong(id);
} catch (NumberFormatException e) {
dciId = session.dciNameToId(obj.getObjectId(), id);
}
if (obj == null || dciId == 0 || !(obj instanceof DataCollectionTarget))
throw new NXCException(RCC.INVALID_OBJECT_ID);
String timeFrom = query.get("from");
String timeTo = query.get("to");
String timeInteval = query.get("timeInterval");
String itemCount = query.get("itemCount");
DciData data = null;
if (timeFrom != null || timeTo != null) {
data = session.getCollectedData(obj.getObjectId(), dciId, new Date(parseLong(timeFrom, 0) * 1000), new Date(parseLong(timeTo, System.currentTimeMillis() / 1000) * 1000), parseInt(itemCount, 0), false);
} else if (timeInteval != null) {
Date now = new Date();
long from = now.getTime() - parseLong(timeInteval, 0) * 1000;
data = session.getCollectedData(obj.getObjectId(), dciId, new Date(from), new Date(), parseInt(itemCount, 0), false);
} else if (itemCount != null) {
data = session.getCollectedData(obj.getObjectId(), dciId, null, null, parseInt(itemCount, 0), false);
} else {
Date now = new Date();
// one hour
long from = now.getTime() - 3600000;
data = session.getCollectedData(obj.getObjectId(), dciId, new Date(from), now, parseInt(itemCount, 0), false);
}
return new ResponseContainer("values", data);
}
use of org.netxms.client.objects.DataCollectionTarget in project netxms by netxms.
the class DataCollectionEditor method init.
/* (non-Javadoc)
* @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite)
*/
@Override
public void init(IViewSite site) throws PartInitException {
super.init(site);
session = (NXCSession) ConsoleSharedData.getSession();
AbstractObject obj = session.findObjectById(Long.parseLong(site.getSecondaryId()));
settings = Activator.getDefault().getDialogSettings();
object = ((obj != null) && ((obj instanceof DataCollectionTarget) || (obj instanceof Template))) ? obj : null;
setPartName(Messages.get().DataCollectionEditor_PartNamePrefix + ((object != null) ? object.getObjectName() : Messages.get().DataCollectionEditor_Error));
}
Aggregations