Class GroupManagerGroupDao

  • All Implemented Interfaces:
    GroupDao, org.springframework.beans.factory.InitializingBean

    public class GroupManagerGroupDao
    extends java.lang.Object
    implements GroupDao, org.springframework.beans.factory.InitializingBean

    GroupManagerGroupDao class.

    Version:
    $Id: $
    Author:
    DJ Gregor
    • Constructor Detail

      • GroupManagerGroupDao

        public GroupManagerGroupDao()
    • Method Detail

      • deleteGroup

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

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

        deleteRole

        Specified by:
        deleteRole in interface GroupDao
        Parameters:
        name - a String object.
      • deleteUser

        public void deleteUser​(java.lang.String name)
        Removes the user from the list of groups. Then overwrites to the "groups.xml"
        Specified by:
        deleteUser in interface GroupDao
        Parameters:
        name - a String object.
      • findGroupsForUser

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

        findGroupsForUser

        Specified by:
        findGroupsForUser in interface GroupDao
        Parameters:
        user - a String object.
        Returns:
        a List object.
      • getGroup

        public Group getGroup​(java.lang.String name)
        Get a group using its name
        Specified by:
        getGroup in interface GroupDao
        Parameters:
        name - the name of the group to return
        Returns:
        Group, the group specified by name
      • getGroupNames

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

        getGroupNames

        Specified by:
        getGroupNames in interface GroupDao
        Returns:
        a List object.
      • getGroups

        public java.util.Map<java.lang.String,​Group> getGroups()

        getGroups

        Specified by:
        getGroups in interface GroupDao
        Returns:
        a Map object.
      • getRole

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

        getRole

        Specified by:
        getRole in interface GroupDao
        Parameters:
        name - a String object.
        Returns:
        a Role object.
      • getRoleNames

        public java.lang.String[] getRoleNames()

        getRoleNames

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

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

        getRoles

        Specified by:
        getRoles in interface GroupDao
        Returns:
        a Collection object.
      • getSchedulesForRoleAt

        public java.util.List<Schedule> getSchedulesForRoleAt​(java.lang.String role,
                                                              java.util.Date time)

        getSchedulesForRoleAt

        Specified by:
        getSchedulesForRoleAt in interface GroupDao
        Parameters:
        role - a String object.
        time - a Date object.
        Returns:
        a List object.
      • getUserSchedulesForRole

        public java.util.List<Schedule> getUserSchedulesForRole​(java.lang.String user,
                                                                java.lang.String role)

        getUserSchedulesForRole

        Specified by:
        getUserSchedulesForRole in interface GroupDao
        Parameters:
        user - a String object.
        role - a String object.
        Returns:
        a List object.
      • groupNextOnDuty

        public long groupNextOnDuty​(java.lang.String group,
                                    java.util.Calendar time)
        Determines when a group is next on duty. If a group has no duty schedules listed in the config file, that group is assumed to always be on duty.
        Specified by:
        groupNextOnDuty in interface GroupDao
        Parameters:
        group - the group whose duty schedule we want
        time - the time to check for a duty schedule
        Returns:
        long, the time in millisec until the group is next on duty
      • hasGroup

        public boolean hasGroup​(java.lang.String name)
        Returns a boolean indicating if the group name appears in the xml file
        Specified by:
        hasGroup in interface GroupDao
        Parameters:
        name - a String object.
        Returns:
        true if the group exists in the xml file, false otherwise
      • isGroupOnDuty

        public boolean isGroupOnDuty​(java.lang.String group,
                                     java.util.Calendar time)
        Determines if a group is on duty at a given time. If a group has no duty schedules listed in the config file, that group is assumed to always be on duty.
        Specified by:
        isGroupOnDuty in interface GroupDao
        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.
      • isUserScheduledForRole

        public boolean isUserScheduledForRole​(java.lang.String user,
                                              java.lang.String role,
                                              java.util.Date time)

        isUserScheduledForRole

        Specified by:
        isUserScheduledForRole in interface GroupDao
        Parameters:
        user - a String object.
        role - a String object.
        time - a Date object.
        Returns:
        a boolean.
      • renameGroup

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

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

        public void saveGroup​(java.lang.String name,
                              Group details)
        Adds a new user and overwrites the "groups.xml"
        Specified by:
        saveGroup in interface GroupDao
        Parameters:
        name - a String object.
        details - a Group object.
      • saveGroups

        public void saveGroups()

        saveGroups

        Specified by:
        saveGroups in interface GroupDao
      • saveRole

        public void saveRole​(Role name)

        saveRole

        Specified by:
        saveRole in interface GroupDao
        Parameters:
        name - a Role object.
      • setGroups

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

        public boolean userHasRole​(java.lang.String user,
                                   java.lang.String role)

        userHasRole

        Specified by:
        userHasRole in interface GroupDao
        Parameters:
        user - a String object.
        role - a String object.
        Returns:
        a boolean.
      • afterPropertiesSet

        public void afterPropertiesSet()

        afterPropertiesSet

        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • setGroupManager

        public void setGroupManager​(GroupManager groupManager)

        setGroupManager

        Parameters:
        groupManager - a GroupManager object.
      • getDefaultMapForUser

        public java.lang.String getDefaultMapForUser​(java.lang.String user)

        getDefaultMapForUser

        Specified by:
        getDefaultMapForUser in interface GroupDao
        Parameters:
        user - a String object.
        Returns:
        a String object.