001    /**
002     * Copyright 2004-2012 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 as of a particular date
057             * @param workArea
058             * @param asOfDate
059             * @return
060             */
061        @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
062            public List<TkRole> getWorkAreaRoles(Long workArea, Date asOfDate);
063        /**
064             * Fetch all Roles for a given work area and role name as of a particular date
065             * @param workArea
066             * @param roleName
067             * @param asOfDate
068             * @return
069             */
070        @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
071            public List<TkRole> getWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
072            /**
073             * Fetch all Inactive Roles for a given work area as of a particular date
074             * @param workArea
075             * @param asOfDate
076             * @return
077             */
078        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
079            public List<TkRole> getInActiveWorkAreaRoles(Long workArea, Date asOfDate);
080        /**
081             * Fetch all Inactive Roles for a given work area and role name as of a particular date
082             * @param workArea
083             * @param roleName
084             * @param asOfDate
085             * @return
086             */
087        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
088            public List<TkRole> getInActiveWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
089            /**
090             * Fetch all Roles for a given Department and Role Name as of a particular date
091             * @param department
092             * @param roleName
093             * @param asOfDate
094             * @return
095             */
096        @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
097            public List<TkRole> getDepartmentRoles(String department, String roleName, Date asOfDate);
098            
099            /**
100             * Fetch all Inactive Roles for a given Department and Role Name as of a particular date
101             * @param department
102             * @param roleName
103             * @param asOfDate
104             * @return
105             */
106        @Cacheable(value= TkRole.CACHE_NAME, key="'{getDepartmentInactiveRoles}' + 'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
107            public List<TkRole> getDepartmentInactiveRoles(String department, String roleName, Date asOfDate);
108            /**
109             * Fetch all Roles for a given Department of a particular date
110             * @param department
111             * @param asOfDate
112             * @return
113             */
114        @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0 + '|' + 'asOfDate=' + #p1")
115            public List<TkRole> getDepartmentRoles(String department, Date asOfDate);
116            /**
117             * Save or Update a given TkRole
118             * @param role
119             */
120        @CacheEvict(value={TkRole.CACHE_NAME, TkRoleGroup.CACHE_NAME}, allEntries = true)
121            public void saveOrUpdate(TkRole role);
122            /**
123             * Save or Update a List of TkRole objects
124             * @param roles
125             */
126        @CacheEvict(value={TkRole.CACHE_NAME, TkRoleGroup.CACHE_NAME}, allEntries = true)
127            public void saveOrUpdate(List<TkRole> roles);
128    
129        /**
130         * Gets the list of principal IDs responsible for the provided assignment /
131         * role name combination.
132         *
133         * @param assignment the assignment to query
134         * @param roleName The role we are interested in.
135         * @param asOfDate effective date
136         * @return
137         */
138        public List<String> getResponsibleParties(Assignment assignment, String roleName, Date asOfDate);
139    
140        /**
141         * Provides a unique set of work areas that this user is an approver for.
142         * @param principalId The principal to retrieve roles for.
143         * @param asOfDate effective date
144         * @return A Set of Long work area numbers.
145         */
146        @Cacheable(value= TkRole.CACHE_NAME, key="'{getWorkAreasForApprover}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
147        public Set<Long> getWorkAreasForApprover(String principalId, Date asOfDate);
148    
149        /**
150         * Provides a unique set of principal ids that have active assignments in the
151         * given work areas.
152         * @param workAreas A set of work area numbers.
153         * @param asOfDate effective date
154         * @return A Set of String principal IDs.
155         */
156        public Set<String> getActivePrinciaplsForWorkAreas(Set<Long> workAreas, Date asOfDate);
157        
158        /**
159         * Fetches Role by primary key
160         */
161        @Cacheable(value= TkRole.CACHE_NAME, key="'tkRoleId=' + #p0")
162        public TkRole getRole(String tkRoleId);
163        
164        /**
165         * Fetches Role by position number
166         */
167        @Cacheable(value= TkRole.CACHE_NAME, key="'positionNumber=' + #p0")
168        public TkRole getRolesByPosition(String positionNumber);
169    
170        @Cacheable(value= TkRole.CACHE_NAME, key="'{getInactiveRolesByPosition}' + 'positionNumber=' + #p0")
171        public TkRole getInactiveRolesByPosition(String positionNumber);
172    
173        @Cacheable(value= TkRole.CACHE_NAME, key="'{getPositionRolesForWorkArea}' + 'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
174        public List<TkRole> getPositionRolesForWorkArea(Long workArea, Date asOfDate);
175    
176        @Cacheable(value= TkRole.CACHE_NAME,
177                key="'principalId=' + #p0" +
178                        "+ '|' + 'asOfDate=' + #p1" +
179                        "+ '|' + 'roleName=' + #p2" +
180                        "+ '|' + 'workArea=' + #p3" +
181                        "+ '|' + 'department=' + #p4")
182        List<TkRole> getRoles(String principalId, Date asOfDate, String roleName, Long workArea, String department);
183    }