Class GroupManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.Map<java.lang.String,​java.util.List<DutySchedule>> m_dutySchedules
      The duty schedules for each group
    • Constructor Summary

      Constructors 
      Constructor Description
      GroupManager()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void deleteGroup​(java.lang.String name)
      Removes the group from the list of groups.
      void deleteRole​(java.lang.String name)
      deleteRole
      void deleteUser​(java.lang.String name)
      Removes the user from the list of groups.
      java.util.List<Group> findGroupsForUser​(java.lang.String user)
      findGroupsForUser
      Group getGroup​(java.lang.String name)
      Get a group using its name
      java.util.List<java.lang.String> getGroupNames()
      getGroupNames
      java.util.Map<java.lang.String,​Group> getGroups()
      Get the groups
      OnmsGroup getOnmsGroup​(java.lang.String groupName)
      getOnmsGroup
      OnmsGroupList getOnmsGroupList()
      getOnmsGroupList
      Role getRole​(java.lang.String roleName)
      getRole
      java.lang.String[] getRoleNames()
      getRoleNames
      java.util.Collection<Role> getRoles()
      getRoles
      OwnedIntervalSequence getRoleScheduleEntries​(java.lang.String roleid, java.util.Date start, java.util.Date end)
      getRoleScheduleEntries
      java.util.List<Schedule> getSchedulesForRoleAt​(java.lang.String roleId, java.util.Date time)
      getSchedulesForRoleAt
      java.util.List<Schedule> getUserSchedulesForRole​(java.lang.String userId, java.lang.String roleId)
      getUserSchedulesForRole
      long groupNextOnDuty​(java.lang.String group, java.util.Calendar time)
      Determines when a group is next on duty.
      boolean hasGroup​(java.lang.String groupName)
      Returns a boolean indicating if the group name appears in the xml file
      boolean isGroupOnDuty​(java.lang.String group, java.util.Calendar time)
      Determines if a group is on duty at a given time.
      boolean isUserScheduledForRole​(java.lang.String userId, java.lang.String roleId, java.util.Date time)
      isUserScheduledForRole
      protected void parseXml​(java.io.InputStream stream)
      parseXml
      void renameGroup​(java.lang.String oldName, java.lang.String newName)
      Renames the group from the list of groups.
      void renameUser​(java.lang.String oldName, java.lang.String newName)
      When this method is called group name is changed, so also is the group name belonging to the view.
      void save​(OnmsGroup group)
      save
      void saveGroup​(java.lang.String name, Group details)
      Adds a new user and overwrites the "groups.xml"
      void saveGroups()
      saveGroups
      void saveRole​(Role role)
      saveRole
      protected abstract void saveXml​(java.lang.String data)
      saveXml
      void setGroups​(java.util.Map<java.lang.String,​Group> grp)
      Set the groups data
      abstract void update()
      update
      boolean userHasRole​(java.lang.String userId, java.lang.String roleid)
      userHasRole
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • m_dutySchedules

        protected static java.util.Map<java.lang.String,​java.util.List<DutySchedule>> m_dutySchedules
        The duty schedules for each group
    • Constructor Detail

      • GroupManager

        public GroupManager()
    • Method Detail

      • parseXml

        protected void parseXml​(java.io.InputStream stream)
                         throws java.io.IOException

        parseXml

        Parameters:
        stream - a InputStream object.
        Throws:
        java.io.IOException
      • setGroups

        public void setGroups​(java.util.Map<java.lang.String,​Group> grp)
        Set the groups data
        Specified by:
        setGroups in interface GroupConfig
        Parameters:
        grp - a Map object.
      • getGroups

        public java.util.Map<java.lang.String,​Group> getGroups()
                                                              throws java.io.IOException
        Get the groups
        Specified by:
        getGroups in interface GroupConfig
        Returns:
        a Map object.
        Throws:
        java.io.IOException - if any.
      • getOnmsGroupList

        public OnmsGroupList getOnmsGroupList()
                                       throws java.io.IOException
        Description copied from interface: GroupConfig

        getOnmsGroupList

        Specified by:
        getOnmsGroupList in interface GroupConfig
        Returns:
        an OnmsGroupList
        Throws:
        java.io.IOException
      • getOnmsGroup

        public OnmsGroup getOnmsGroup​(java.lang.String groupName)
                               throws java.io.IOException
        Description copied from interface: GroupConfig

        getOnmsGroup

        Specified by:
        getOnmsGroup in interface GroupConfig
        Returns:
        an OnmsGroup
        Throws:
        java.io.IOException
      • save

        public void save​(OnmsGroup group)
                  throws java.lang.Exception
        Description copied from interface: GroupConfig

        save

        Specified by:
        save in interface GroupConfig
        Throws:
        java.lang.Exception
      • update

        public abstract void update()
                             throws java.io.IOException

        update

        Throws:
        java.io.IOException - if any.
      • hasGroup

        public boolean hasGroup​(java.lang.String groupName)
                         throws java.io.IOException
        Returns a boolean indicating if the group name appears in the xml file
        Specified by:
        hasGroup in interface GroupConfig
        Parameters:
        groupName - a String object.
        Returns:
        true if the group exists in the xml file, false otherwise
        Throws:
        java.io.IOException - if any.
      • getGroupNames

        public java.util.List<java.lang.String> getGroupNames()
                                                       throws java.io.IOException

        getGroupNames

        Specified by:
        getGroupNames in interface GroupConfig
        Returns:
        a List object.
        Throws:
        java.io.IOException - if any.
      • getGroup

        public Group getGroup​(java.lang.String name)
                       throws java.io.IOException
        Get a group using its name
        Specified by:
        getGroup in interface GroupConfig
        Parameters:
        name - the name of the group to return
        Returns:
        Group, the group specified by name
        Throws:
        java.io.IOException - if any.
      • saveGroups

        public void saveGroups()
                        throws java.lang.Exception

        saveGroups

        Specified by:
        saveGroups in interface GroupConfig
        Throws:
        java.lang.Exception - if any.
      • isGroupOnDuty

        public boolean isGroupOnDuty​(java.lang.String group,
                                     java.util.Calendar time)
                              throws java.io.IOException
        Determines if a group is on duty at a given time. If a group has no duty schedules listed in the configuration file, that group is assumed to always be on duty.
        Specified by:
        isGroupOnDuty in interface GroupConfig
        Parameters:
        group - the group whose duty schedule we want
        time - the time to check for a duty schedule
        Returns:
        boolean, true if the group is on duty, false otherwise.
        Throws:
        java.io.IOException - if any.
      • groupNextOnDuty

        public long groupNextOnDuty​(java.lang.String group,
                                    java.util.Calendar time)
                             throws java.io.IOException
        Determines when a group is next on duty. If a group has no duty schedules listed in the configuration file, that group is assumed to always be on duty.
        Specified by:
        groupNextOnDuty in interface GroupConfig
        Parameters:
        group - the group whose duty schedule we want
        time - the time to check for a duty schedule
        Returns:
        long, the time in milliseconds until the group is next on duty
        Throws:
        java.io.IOException - if any.
      • saveXml

        protected abstract void saveXml​(java.lang.String data)
                                 throws java.io.IOException

        saveXml

        Parameters:
        data - a String object.
        Throws:
        java.io.IOException - if any.
      • saveGroup

        public void saveGroup​(java.lang.String name,
                              Group details)
                       throws java.lang.Exception
        Adds a new user and overwrites the "groups.xml"
        Specified by:
        saveGroup in interface GroupConfig
        Parameters:
        name - a String object.
        details - a Group object.
        Throws:
        java.lang.Exception - if any.
      • saveRole

        public void saveRole​(Role role)
                      throws java.lang.Exception

        saveRole

        Specified by:
        saveRole in interface GroupConfig
        Parameters:
        role - a Role object.
        Throws:
        java.lang.Exception - if any.
      • deleteUser

        public void deleteUser​(java.lang.String name)
                        throws java.lang.Exception
        Removes the user from the list of groups. Then overwrites to the "groups.xml"
        Specified by:
        deleteUser in interface GroupConfig
        Parameters:
        name - a String object.
        Throws:
        java.lang.Exception - if any.
      • deleteGroup

        public void deleteGroup​(java.lang.String name)
                         throws java.lang.Exception
        Removes the group from the list of groups. Then overwrites to the "groups.xml"
        Specified by:
        deleteGroup in interface GroupConfig
        Parameters:
        name - a String object.
        Throws:
        java.lang.Exception - if any.
      • deleteRole

        public void deleteRole​(java.lang.String name)
                        throws java.lang.Exception

        deleteRole

        Specified by:
        deleteRole in interface GroupConfig
        Parameters:
        name - a String object.
        Throws:
        java.lang.Exception - if any.
      • renameGroup

        public void renameGroup​(java.lang.String oldName,
                                java.lang.String newName)
                         throws java.lang.Exception
        Renames the group from the list of groups. Then overwrites to the "groups.xml"
        Specified by:
        renameGroup in interface GroupConfig
        Parameters:
        oldName - a String object.
        newName - a String object.
        Throws:
        java.lang.Exception - if any.
      • renameUser

        public void renameUser​(java.lang.String oldName,
                               java.lang.String newName)
                        throws java.lang.Exception
        When this method is called group name is changed, so also is the group name belonging to the view. Also overwrites the "groups.xml" file
        Specified by:
        renameUser in interface GroupConfig
        Parameters:
        oldName - a String object.
        newName - a String object.
        Throws:
        java.lang.Exception - if any.
      • getRoleNames

        public java.lang.String[] getRoleNames()

        getRoleNames

        Specified by:
        getRoleNames in interface GroupConfig
        Returns:
        an array of String objects.
      • getRoles

        public java.util.Collection<Role> getRoles()

        getRoles

        Specified by:
        getRoles in interface GroupConfig
        Returns:
        a Collection object.
      • getRole

        public Role getRole​(java.lang.String roleName)

        getRole

        Specified by:
        getRole in interface GroupConfig
        Parameters:
        roleName - a String object.
        Returns:
        a Role object.
      • userHasRole

        public boolean userHasRole​(java.lang.String userId,
                                   java.lang.String roleid)
                            throws java.io.IOException

        userHasRole

        Specified by:
        userHasRole in interface GroupConfig
        Parameters:
        userId - a String object.
        roleid - a String object.
        Returns:
        a boolean.
        Throws:
        java.io.IOException - if any.
      • getSchedulesForRoleAt

        public java.util.List<Schedule> getSchedulesForRoleAt​(java.lang.String roleId,
                                                              java.util.Date time)
                                                       throws java.io.IOException

        getSchedulesForRoleAt

        Specified by:
        getSchedulesForRoleAt in interface GroupConfig
        Parameters:
        roleId - a String object.
        time - a Date object.
        Returns:
        a List object.
        Throws:
        java.io.IOException - if any.
      • getUserSchedulesForRole

        public java.util.List<Schedule> getUserSchedulesForRole​(java.lang.String userId,
                                                                java.lang.String roleId)
                                                         throws java.io.IOException

        getUserSchedulesForRole

        Specified by:
        getUserSchedulesForRole in interface GroupConfig
        Parameters:
        userId - a String object.
        roleId - a String object.
        Returns:
        a List object.
        Throws:
        java.io.IOException - if any.
      • isUserScheduledForRole

        public boolean isUserScheduledForRole​(java.lang.String userId,
                                              java.lang.String roleId,
                                              java.util.Date time)
                                       throws java.io.IOException

        isUserScheduledForRole

        Specified by:
        isUserScheduledForRole in interface GroupConfig
        Parameters:
        userId - a String object.
        roleId - a String object.
        time - a Date object.
        Returns:
        a boolean.
        Throws:
        java.io.IOException - if any.
      • getRoleScheduleEntries

        public OwnedIntervalSequence getRoleScheduleEntries​(java.lang.String roleid,
                                                            java.util.Date start,
                                                            java.util.Date end)
                                                     throws java.io.IOException

        getRoleScheduleEntries

        Specified by:
        getRoleScheduleEntries in interface GroupConfig
        Parameters:
        roleid - a String object.
        start - a Date object.
        end - a Date object.
        Returns:
        a OwnedIntervalSequence object.
        Throws:
        java.io.IOException - if any.
      • findGroupsForUser

        public java.util.List<Group> findGroupsForUser​(java.lang.String user)

        findGroupsForUser

        Specified by:
        findGroupsForUser in interface GroupConfig
        Parameters:
        user - a String object.
        Returns:
        a List object.