use of org.opennms.netmgt.config.users.DutySchedule in project opennms by OpenNMS.
the class UserManager method _buildDutySchedules.
/**
* Builds a mapping between user IDs and duty schedules. These are used by
* Notifd when determining to send a notice to a given user. This helps
* speed up the decision process.
*
* @param users
* the map of users parsed from the XML configuration file
*/
private void _buildDutySchedules(final Map<String, User> users) {
m_dutySchedules = new HashMap<String, List<DutySchedule>>();
for (final Entry<String, User> entry : users.entrySet()) {
final String key = entry.getKey();
final User curUser = entry.getValue();
if (curUser.getDutySchedules().size() > 0) {
final List<DutySchedule> dutyList = new ArrayList<DutySchedule>();
for (final String duty : curUser.getDutySchedules()) {
dutyList.add(new DutySchedule(duty));
}
m_dutySchedules.put(key, dutyList);
}
}
}
use of org.opennms.netmgt.config.users.DutySchedule in project opennms by OpenNMS.
the class AddDutySchedulesServlet method doPost.
/** {@inheritDoc} */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession userSession = request.getSession(true);
User user = (User) userSession.getAttribute("user.modifyUser.jsp");
int dutyAddCount = WebSecurityUtils.safeParseInt(request.getParameter("numSchedules"));
for (int j = 0; j < dutyAddCount; j++) {
user.addDutySchedule((new DutySchedule(new ArrayList<Boolean>(FALSE_LIST), 0, 2359)).toString());
}
// forward the request for proper display
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/userGroupView/users/modifyUser.jsp");
dispatcher.forward(request, response);
}
use of org.opennms.netmgt.config.users.DutySchedule in project opennms by OpenNMS.
the class UpdateGroupServlet method doPost.
/** {@inheritDoc} */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession userSession = request.getSession(false);
if (userSession != null) {
//group.modifyGroup.jsp
Group newGroup = (Group) userSession.getAttribute("group");
// get the rest of the group information from the form
newGroup.clearUsers();
String[] users = request.getParameterValues("selectedUsers");
if (users != null) {
for (int i = 0; i < users.length; i++) {
newGroup.addUser(users[i]);
}
}
Vector<Object> newSchedule = new Vector<Object>();
ChoiceFormat days = new ChoiceFormat("0#Mo|1#Tu|2#We|3#Th|4#Fr|5#Sa|6#Su");
Collection<String> dutySchedules = getDutySchedulesForGroup(newGroup);
dutySchedules.clear();
int dutyCount = WebSecurityUtils.safeParseInt(request.getParameter("dutySchedules"));
for (int duties = 0; duties < dutyCount; duties++) {
newSchedule.clear();
String deleteFlag = request.getParameter("deleteDuty" + duties);
// don't save any duties that were marked for deletion
if (deleteFlag == null) {
for (int i = 0; i < 7; i++) {
String curDayFlag = request.getParameter("duty" + duties + days.format(i));
if (curDayFlag != null) {
newSchedule.addElement(Boolean.TRUE);
} else {
newSchedule.addElement(Boolean.FALSE);
}
}
newSchedule.addElement(request.getParameter("duty" + duties + "Begin"));
newSchedule.addElement(request.getParameter("duty" + duties + "End"));
DutySchedule newDuty = new DutySchedule(newSchedule);
dutySchedules.add(newDuty.toString());
}
}
userSession.setAttribute("group", newGroup);
}
// forward the request for proper display
RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher(request.getParameter("redirect"));
dispatcher.forward(request, response);
}
use of org.opennms.netmgt.config.users.DutySchedule in project opennms by OpenNMS.
the class GroupController method addDutySchedules.
private ModelAndView addDutySchedules(HttpServletRequest request, HttpServletResponse response) throws Exception {
HttpSession userSession = request.getSession(true);
if (userSession != null) {
//group.modifyGroup.jsp
WebGroup group = (WebGroup) userSession.getAttribute("group.modifyGroup.jsp");
updateGroup(request, group);
Vector<Object> newSchedule = new Vector<Object>();
int dutyAddCount = WebSecurityUtils.safeParseInt(request.getParameter("numSchedules"));
for (int j = 0; j < dutyAddCount; j++) {
// add 7 false boolean values for each day of the week
for (int i = 0; i < 7; i++) {
newSchedule.addElement(Boolean.FALSE);
}
// add two strings for the begin and end time
newSchedule.addElement("0");
newSchedule.addElement("0");
group.addDutySchedule((new DutySchedule(newSchedule)).toString());
}
userSession.setAttribute("group.modifyGroup.jsp", group);
}
return new ModelAndView("admin/userGroupView/groups/modifyGroup");
}
Aggregations