View Javadoc

1   /**
2    * Copyright 2004-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.hr.time.roles.service;
17  
18  import org.kuali.hr.time.assignment.Assignment;
19  import org.kuali.hr.time.roles.TkRole;
20  import org.kuali.hr.time.roles.TkRoleGroup;
21  import org.springframework.cache.annotation.CacheEvict;
22  import org.springframework.cache.annotation.Cacheable;
23  
24  import java.sql.Date;
25  import java.util.List;
26  import java.util.Set;
27  
28  public interface TkRoleService {
29  	/**
30  	 * Fetch all roles for a given Principal ID as of a particular date
31  	 * @param principalId
32  	 * @param asOfDate
33  	 * @return
34  	 */
35      @Cacheable(value= TkRole.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
36  	public List<TkRole> getRoles(String principalId, Date asOfDate);
37  	
38  	/**
39  	 * Fetch all inactive roles for a given Principal ID as of a particular date
40  	 * @param principalId
41  	 * @param asOfDate
42  	 * @return
43  	 */
44      @Cacheable(value= TkRole.CACHE_NAME, key="'{getInactiveRoles}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
45  	public List<TkRole> getInactiveRoles(String principalId, Date asOfDate);
46  	/**
47  	 * Fetch all roles for a given Principal ID and Role Name as of a particular date
48  	 * @param principalId
49  	 * @param roleName
50  	 * @param asOfDate
51  	 * @return
52  	 */
53      @Cacheable(value= TkRole.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
54  	public List<TkRole> getRoles(String principalId, String roleName, Date asOfDate);
55  	/**
56  	 * Fetch all Roles for a given Work Area as of a particular date
57  	 * @param workArea
58  	 * @param asOfDate
59  	 * @return
60  	 */
61      @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
62  	public List<TkRole> getWorkAreaRoles(Long workArea, Date asOfDate);
63      /**
64  	 * Fetch all Roles for a given work area and role name as of a particular date
65  	 * @param workArea
66  	 * @param roleName
67  	 * @param asOfDate
68  	 * @return
69  	 */
70      @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
71  	public List<TkRole> getWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
72  	/**
73  	 * Fetch all Inactive Roles for a given work area as of a particular date
74  	 * @param workArea
75  	 * @param asOfDate
76  	 * @return
77  	 */
78      @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
79  	public List<TkRole> getInActiveWorkAreaRoles(Long workArea, Date asOfDate);
80      /**
81  	 * Fetch all Inactive Roles for a given work area and role name as of a particular date
82  	 * @param workArea
83  	 * @param roleName
84  	 * @param asOfDate
85  	 * @return
86  	 */
87      @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
88  	public List<TkRole> getInActiveWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
89  	/**
90  	 * Fetch all Roles for a given Department and Role Name as of a particular date
91  	 * @param department
92  	 * @param roleName
93  	 * @param asOfDate
94  	 * @return
95  	 */
96      @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
97  	public List<TkRole> getDepartmentRoles(String department, String roleName, Date asOfDate);
98  	
99  	/**
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 }