use of org.opennms.web.svclayer.model.ProgressMonitor in project opennms by OpenNMS.
the class DefaultSurveillanceServiceIntegrationIT method testCreateSurveillanceServiceTableUsingViewName.
@Test
@Transactional
public void testCreateSurveillanceServiceTableUsingViewName() {
String viewName = "default";
SimpleWebTable table = m_surveillanceService.createSurveillanceTable(viewName, new ProgressMonitor() {
@Override
public void beginNextPhase(String string) {
System.err.println("PHASE: " + string);
}
@Override
public void setPhaseCount(int i) {
}
});
assertEquals("default", table.getTitle());
}
use of org.opennms.web.svclayer.model.ProgressMonitor in project opennms by OpenNMS.
the class SurveillanceViewController method createProgressMonitor.
private ProgressMonitor createProgressMonitor(final String viewName) {
ProgressMonitor progressMonitor;
final ProgressMonitor monitor = new ProgressMonitor();
Thread bgRunner = new Thread("SurveillanceView Builder") {
@Override
public void run() {
try {
m_service.createSurveillanceTable(viewName, monitor);
} catch (Throwable t) {
monitor.errorOccurred(t);
}
}
};
bgRunner.start();
progressMonitor = monitor;
return progressMonitor;
}
use of org.opennms.web.svclayer.model.ProgressMonitor in project opennms by OpenNMS.
the class SurveillanceViewController method handleRequestInternal.
/** {@inheritDoc} */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) throws Exception {
if (!m_service.isViewName(req.getParameter(VIEW_NAME_PARAMETER))) {
SurveillanceViewError viewError = createSurveillanceViewError(WebSecurityUtils.sanitizeString(req.getParameter(VIEW_NAME_PARAMETER)));
return new ModelAndView("surveillanceViewError", "error", viewError);
}
HttpSession session = req.getSession();
resp.setHeader("Refresh", String.valueOf(m_service.getHeaderRefreshSeconds(WebSecurityUtils.sanitizeString(req.getParameter(VIEW_NAME_PARAMETER)))));
ProgressMonitor progressMonitor = (ProgressMonitor) session.getAttribute(PROGRESS_MONITOR_KEY);
if (progressMonitor == null) {
progressMonitor = createProgressMonitor(WebSecurityUtils.sanitizeString(req.getParameter(VIEW_NAME_PARAMETER)));
session.setAttribute(PROGRESS_MONITOR_KEY, progressMonitor);
}
if (progressMonitor.isError()) {
session.removeAttribute(PROGRESS_MONITOR_KEY);
Throwable t = progressMonitor.getThrowable();
throw new Exception("SurveillanceView Builder Thread threw exception: [" + t.getClass().getName() + "] " + t.getMessage(), t);
}
if (progressMonitor.isFinished()) {
session.removeAttribute(PROGRESS_MONITOR_KEY);
SimpleWebTable table = (SimpleWebTable) progressMonitor.getResult();
ModelAndView modelAndView = new ModelAndView("surveillanceView", "webTable", table);
modelAndView.addObject("viewNames", m_service.getViewNames());
return modelAndView;
}
return new ModelAndView("progressBar", "progress", progressMonitor);
}
Aggregations