use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdingVisitorIT method initFactories.
private void initFactories(String threshd, String thresholds) throws Exception {
LOG.info("Initialize Threshold Factories");
ThresholdingConfigFactory.setInstance(new ThresholdingConfigFactory(getClass().getResourceAsStream(thresholds)));
ThreshdConfigFactory.setInstance(new ThreshdConfigFactory(getClass().getResourceAsStream(threshd), "127.0.0.1", false));
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method deleteThreshold.
private ModelAndView deleteThreshold(String thresholdIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (thresholdIndexString == null) {
throw new ServletException("thresholdIndex parameter required to delete a threshold");
}
int thresholdIndex = WebSecurityUtils.safeParseInt(thresholdIndexString);
Group group = configFactory.getGroup(groupName);
group.removeThreshold(group.getThresholds().get(thresholdIndex));
//and setup the group view again
modelAndView = new ModelAndView("admin/thresholds/editGroup");
modelAndView.addObject("group", configFactory.getGroup(groupName));
saveChanges();
return modelAndView;
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method deleteExpression.
private ModelAndView deleteExpression(String expressionIndexString, String groupName) throws ServletException {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView;
if (expressionIndexString == null) {
throw new ServletException("expressionIndex parameter required to delete a threshold expression");
}
int expressionIndex = WebSecurityUtils.safeParseInt(expressionIndexString);
Group group = configFactory.getGroup(groupName);
group.removeExpression(group.getExpressions().get(expressionIndex));
saveChanges();
//and setup the group view again
modelAndView = new ModelAndView("admin/thresholds/editGroup");
modelAndView.addObject("group", configFactory.getGroup(groupName));
return modelAndView;
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method gotoNewExpression.
private ModelAndView gotoNewExpression(String groupName) {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
final Group group = configFactory.getGroup(groupName);
final List<Expression> expressions = group.getExpressions();
//We're assuming that adding a expression puts it at the end of the current list (i.e. that the Group implementation
// uses a simple List structure, probably ArrayList). We can be a bit cleverer later on and check though, so we should
int expressionIndex = expressions.size();
//Check if last expression has expression def. If not, we assume that is a new definition (not saved yet on thresholds.xml)
Expression expression = null;
if (expressionIndex > 0) {
expression = expressions.get(expressionIndex - 1);
if (expression.getExpression() == null || expression.getExpression().equals("")) {
expressionIndex--;
} else {
expression = null;
}
}
// create a new expression object
if (expression == null) {
expression = new Expression();
//Set the two default values which need to be set for the UI to work properly
expression.setDsType("node");
expression.setType(ThresholdType.HIGH);
//Default to 1 - 0 will give an error, so we may as well be helpful
expression.setTrigger(1);
group.addExpression(expression);
}
//Double check the guess index, just in case:
if (expression != expressions.get(expressionIndex)) {
//Ok, our guesses on indexing were completely wrong. Failover and check each threshold in the group
for (int i = 0; i < expressions.size(); i++) {
if (expression == expressions.get(i)) {
expressionIndex = i;
//out of the for loop
break;
}
}
}
ModelAndView modelAndView;
modelAndView = new ModelAndView("admin/thresholds/editExpression");
modelAndView.addObject("expression", expression);
modelAndView.addObject("expressionIndex", expressionIndex);
modelAndView.addObject("groupName", groupName);
modelAndView.addObject("isNew", true);
addStandardEditingBits(modelAndView);
return modelAndView;
}
use of org.opennms.netmgt.config.ThresholdingConfigFactory in project opennms by OpenNMS.
the class ThresholdController method gotoGroupEdit.
private ModelAndView gotoGroupEdit(String groupName) {
ThresholdingConfigFactory configFactory = ThresholdingConfigFactory.getInstance();
ModelAndView modelAndView = new ModelAndView("admin/thresholds/editGroup");
modelAndView.addObject("group", configFactory.getGroup(groupName));
return modelAndView;
}
Aggregations