View Javadoc

1   /**
2    * Copyright 2004-2013 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
57  	 * @param workArea
58  	 * @return
59  	 */
60      @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0")
61  	public List<TkRole> getWorkAreaRoles(Long workArea);
62      /**
63  	 * Fetch all Roles for a given work area and role name as of a particular date
64  	 * @param workArea
65  	 * @param roleName
66  	 * @param asOfDate
67  	 * @return
68  	 */
69      @Cacheable(value= TkRole.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
70  	public List<TkRole> getWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
71  	/**
72  	 * Fetch all Inactive Roles for a given work area
73  	 * @param workArea
74  	 * @return
75  	 */
76      @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0")
77  	public List<TkRole> getInActiveWorkAreaRoles(Long workArea);
78      /**
79  	 * Fetch all Inactive Roles for a given work area and role name as of a particular date
80  	 * @param workArea
81  	 * @param roleName
82  	 * @param asOfDate
83  	 * @return
84  	 */
85      @Cacheable(value= TkRole.CACHE_NAME, key="'{getInActiveWorkAreaRoles}' + 'workArea=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
86  	public List<TkRole> getInActiveWorkAreaRoles(Long workArea, String roleName, Date asOfDate);
87  	/**
88  	 * Fetch all Roles for a given Department and Role Name as of a particular date
89  	 * @param department
90  	 * @param roleName
91  	 * @param asOfDate
92  	 * @return
93  	 */
94      @Cacheable(value= TkRole.CACHE_NAME, key="'department=' + #p0 + '|' + 'roleName=' + #p1 + '|' + 'asOfDate=' + #p2")
95  	public List<TkRole> getDepartmentRoles(String department, String roleName, Date asOfDate);
96  	
97  	/**
98  	 * Fetch all Inactive Roles for a given Department and Role Name as of a particular date
99  	 * @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 }