Search in sources :

Example 11 with DutySchedule

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);
        }
    }
}
Also used : User(org.opennms.netmgt.config.users.User) OnmsUser(org.opennms.netmgt.model.OnmsUser) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) OnmsUserList(org.opennms.netmgt.model.OnmsUserList) List(java.util.List) DutySchedule(org.opennms.netmgt.config.users.DutySchedule)

Example 12 with DutySchedule

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);
}
Also used : User(org.opennms.netmgt.config.users.User) HttpSession(javax.servlet.http.HttpSession) ArrayList(java.util.ArrayList) DutySchedule(org.opennms.netmgt.config.users.DutySchedule) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 13 with DutySchedule

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);
}
Also used : Group(org.opennms.netmgt.config.groups.Group) HttpSession(javax.servlet.http.HttpSession) ChoiceFormat(java.text.ChoiceFormat) DutySchedule(org.opennms.netmgt.config.users.DutySchedule) Vector(java.util.Vector) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 14 with DutySchedule

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");
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) DutySchedule(org.opennms.netmgt.config.users.DutySchedule) Vector(java.util.Vector) WebGroup(org.opennms.web.group.WebGroup)

Aggregations

DutySchedule (org.opennms.netmgt.config.users.DutySchedule)14 HttpSession (javax.servlet.http.HttpSession)7 Vector (java.util.Vector)5 RequestDispatcher (javax.servlet.RequestDispatcher)5 ChoiceFormat (java.text.ChoiceFormat)4 ArrayList (java.util.ArrayList)4 Group (org.opennms.netmgt.config.groups.Group)3 User (org.opennms.netmgt.config.users.User)3 List (java.util.List)2 WebGroup (org.opennms.web.group.WebGroup)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ServletException (javax.servlet.ServletException)1 Contact (org.opennms.netmgt.config.users.Contact)1 Password (org.opennms.netmgt.config.users.Password)1 OnmsGroup (org.opennms.netmgt.model.OnmsGroup)1 OnmsGroupList (org.opennms.netmgt.model.OnmsGroupList)1 OnmsUser (org.opennms.netmgt.model.OnmsUser)1 OnmsUserList (org.opennms.netmgt.model.OnmsUserList)1 Group (org.opennms.web.admin.groups.parsers.Group)1 GroupInfo (org.opennms.web.admin.groups.parsers.GroupInfo)1