/// <summary>
        /// Returns a hashmap of service admin grants. 
        /// Keys are process agent IDs where the process agent is the qualifier of the grant
        /// Values are lists of service admin grants that have that process agent as a qualifier
        /// 
        /// A grant is a service admin grant if
        ///     1. The agent is a service admin group
        ///     2. The function should be a "service admin" or "service management" ticket type 
        ///     3. qualifier should be a process agent
        /// </summary>
        /// <returns></returns>
        protected Dictionary<int, List<Grant>> getServiceAdminGrants()
        {
            // initializations
            Dictionary<int, List<Grant>> servAdminGrants = new Dictionary<int, List<Grant>>();
            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();

            // get all grants
            int[] grantIDs = wrapper.ListGrantIDsWrapper();
            Grant[] grants = wrapper.GetGrantsWrapper(grantIDs);

            int effGroupID = Convert.ToInt32(Session["GroupID"]);

            foreach (Grant grant in grants)
            {
                if (grant.agentID.Equals(effGroupID))
                {
                    // check if the grant is a service admin or service manage grant
                    // 1. agent should be a "service admin" group
                    // 2. function should be a "service admin" or "service management" ticket type
                    // 3. qualifier should be a process agent
                    int paID = 0;
                    Qualifier qualifier = new Qualifier();
                    string function = grant.function;
                    if (TicketTypes.IsAdministerPAType(function))
                    {

                        // get process agent that corresponds to qualifier
                        qualifier = AuthorizationAPI.GetQualifier(grant.qualifierID);
                        paID = qualifier.qualifierReferenceID;
                    }
                    else if (TicketTypes.IsManagePAType(function))
                    {
                        bool isManage = true;
                        bool isProcessAgent = false;
                        int targetId = -1;
                        qualifier = AuthorizationAPI.GetQualifier(grant.qualifierID);
                        //Qualifier is a Resource Mapping
                        if (qualifier.qualifierType.Equals(Qualifier.resourceMappingQualifierTypeID))
                        {
                            //int resourceMappingID = ;
                            ResourceMapping mapping = ticketIssuer.GetResourceMapping(qualifier.qualifierReferenceID);
                            if (mapping != null)
                            {
                                ResourceMappingKey mappingKey = mapping.Key;
                                if (mapping.Key.Type.Equals(ResourceMappingTypes.GROUP))
                                {
                                    if (mapping.values[0].Type == ResourceMappingTypes.CLIENT)
                                        paID = ticketIssuer.FindProcessAgentIdForClient((int)mapping.values[0].Entry, ProcessAgentType.SCHEDULING_SERVER);
                                }
                                else if (mapping.Key.Type.Equals(ResourceMappingTypes.PROCESS_AGENT))
                                {
                                    if (mapping.values[2].Type.Equals(ResourceMappingTypes.TICKET_TYPE))// && mapping.values[2].Entry.Equals(TicketTypes.GetTicketType(TicketTypes.MANAGE_USS_GROUP)))
                                    {
                                        paID = (int)mapping.values[1].Entry;
                                        ResourceMappingValue[] mappingValues = mapping.values;

                                        //TO BE FIXED: I am assuming that the Mapping has 3 values, the 3rd one being the Ticket Type,
                                        //the 2nd one being the Process Agent, and the 1st one the Resource Type.

                                        //if (mappingValues[2].Type.Equals(ResourceMappingTypes.TICKET_TYPE))
                                        //{
                                        //    if (TicketTypes.IsManagePAType((string)mappingValues[2].Entry))
                                        //        isManage = true;
                                        //}

                                        if (mappingValues[1].Type.Equals(ResourceMappingTypes.PROCESS_AGENT))
                                        {
                                            isProcessAgent = true;
                                            targetId = (int)mappingValues[1].Entry;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (paID > 0)
                    {
                        //get the list of grants that correspond to the process agent qualifier
                        List<Grant> list = new List<Grant>();
                        if (servAdminGrants.TryGetValue(paID, out list))
                        {
                            // process agent already exists
                            // add grant

                            list.Add(grant);
                        }
                        else
                        // process agent does not exist
                        // add list
                        {
                            list = new List<Grant>();

                            list.Add(grant);
                            servAdminGrants.Add(paID, list);

                        }
                    }

                }
            }
            return servAdminGrants;
        }