001    /**
002     * Copyright 2004-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.roles.service;
017    
018    import org.kuali.hr.time.assignment.Assignment;
019    import org.kuali.hr.time.roles.TkRole;
020    import org.kuali.hr.time.roles.TkRoleGroup;
021    import org.springframework.cache.annotation.CacheEvict;
022    import org.springframework.cache.annotation.Cacheable;
023    
024    import java.sql.Date;
025    import java.util.List;
026    import java.util.Set;
027    
028    public interface TkRoleService {
029            /**
030             * Fetch all roles for a given Principal ID as of a particular date
031             * @param principalId
032             * @param asOfDate
033             * @return
034             */
035        @Cacheable(value= TkRole.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
036            public List<TkRole> getRoles(String principalId, Date asOfDate);
037            
038            /**
039             * Fetch all inactive roles for a given Principal ID as of a particular date
040             * @param principalId
041             * @param asOfDate
042             * @return
043             */
044        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInactiveRoles}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
045            public List<TkRole> getInactiveRoles(String principalId, Date asOfDate);
046            /**
047             * Fetch all roles for a given Principal ID and Role Name as of a particular date
048             * @param principalId
049             * @param roleName
050             * @param asOfDate
051             * @return
052             */
053        @Cacheable(value= TkRole.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
054            public List<TkRole> getRoles(String principalId, String roleName, Date asOfDate);
055            /**
056             * Fetch all Roles for a given Work Area
057             * @param workArea
058             * @return
059             */
060        @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0")
061            public List<TkRole> getWorkAreaRoles(Long workArea);
062        /**
063             * Fetch all Roles for a given work area and role name as of a particular date
064             * @param workArea
065             * @param roleName
066             * @param asOfDate
067             * @return
068             */
069        @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
070            public List<TkRole> getWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
071            /**
072             * Fetch all Inactive Roles for a given work area
073             * @param workArea
074             * @return
075             */
076        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0")
077            public List<TkRole> getInActiveWorkAreaRoles(Long workArea);
078        /**
079             * Fetch all Inactive Roles for a given work area and role name as of a particular date
080             * @param workArea
081             * @param roleName
082             * @param asOfDate
083             * @return
084             */
085        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
086            public List<TkRole> getInActiveWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
087            /**
088             * Fetch all Roles for a given Department and Role Name as of a particular date
089             * @param department
090             * @param roleName
091             * @param asOfDate
092             * @return
093             */
094        @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
095            public List<TkRole> getDepartmentRoles(String department, String roleName, Date asOfDate);
096            
097            /**
098             * Fetch all Inactive Roles for a given Department and Role Name as of a particular date
099             * @param department
100             * @param roleName
101             * @param asOfDate
102             * @return
103             */
104        @Cacheable(value= TkRole.CACHE_NAME, key="'{getDepartmentInactiveRoles}' + 'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
105            public List<TkRole> getDepartmentInactiveRoles(String department, String roleName, Date asOfDate);
106            /**
107             * Fetch all Roles for a given Department
108             * @param department
109             * @return
110             */
111        @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0")
112            public List<TkRole> getDepartmentRoles(String department);
113            /**
114             * Fetch all Inactive Roles for a given Department
115             * @param department
116             * @return
117             */
118        @Cacheable(value= TkRole.CACHE_NAME, key="'{getDepartmentInactiveRoles}' + 'department=' + #p0")
119            public List<TkRole> getDepartmentInactiveRoles(String department);
120            /**
121             * Save or Update a given TkRole
122             * @param role
123             */
124        @CacheEvict(value={TkRole.CACHE_NAME, TkRoleGroup.CACHE_NAME}, allEntries = true)
125            public void saveOrUpdate(TkRole role);
126            /**
127             * Save or Update a List of TkRole objects
128             * @param roles
129             */
130        @CacheEvict(value={TkRole.CACHE_NAME, TkRoleGroup.CACHE_NAME}, allEntries = true)
131            public void saveOrUpdate(List<TkRole> roles);
132    
133        /**
134         * Gets the list of principal IDs responsible for the provided assignment /
135         * role name combination.
136         *
137         * @param assignment the assignment to query
138         * @param roleName The role we are interested in.
139         * @param asOfDate effective date
140         * @return
141         */
142        public List<String> getResponsibleParties(Assignment assignment, String roleName, Date asOfDate);
143    
144        /**
145         * Provides a unique set of work areas that this user is an approver for.
146         * @param principalId The principal to retrieve roles for.
147         * @param asOfDate effective date
148         * @return A Set of Long work area numbers.
149         */
150        @Cacheable(value= TkRole.CACHE_NAME, key="'{getWorkAreasForApprover}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
151        public Set<Long> getWorkAreasForApprover(String principalId, Date asOfDate);
152    
153        /**
154         * Provides a unique set of principal ids that have active assignments in the
155         * given work areas.
156         * @param workAreas A set of work area numbers.
157         * @param asOfDate effective date
158         * @return A Set of String principal IDs.
159         */
160        public Set<String> getActivePrincipalsForWorkAreas(Set<Long> workAreas, Date asOfDate);
161        
162        /**
163         * Fetches Role by primary key
164         */
165        @Cacheable(value= TkRole.CACHE_NAME, key="'tkRoleId=' + #p0")
166        public TkRole getRole(String tkRoleId);
167        
168        /**
169         * Fetches Role by position number
170         */
171        @Cacheable(value= TkRole.CACHE_NAME, key="'positionNumber=' + #p0")
172        public TkRole getRolesByPosition(String positionNumber);
173    
174        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInactiveRolesByPosition}' + 'positionNumber=' + #p0")
175        public TkRole getInactiveRolesByPosition(String positionNumber);
176    
177        @Cacheable(value= TkRole.CACHE_NAME, key="'{getPositionRolesForWorkArea}' + 'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
178        public List<TkRole> getPositionRolesForWorkArea(Long workArea, Date asOfDate);
179    
180        @Cacheable(value= TkRole.CACHE_NAME,
181                key="'principalId=' + #p0" +
182                        "+ '|' + 'asOfDate=' + #p1" +
183                        "+ '|' + 'roleName=' + #p2" +
184                        "+ '|' + 'workArea=' + #p3" +
185                        "+ '|' + 'department=' + #p4")
186        List<TkRole> getRoles(String principalId, Date asOfDate, String roleName, Long workArea, String department);
187    }