View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.core.assignment.service;
17  
18  import java.util.*;
19  
20  import org.joda.time.LocalDate;
21  import org.kuali.kpme.core.assignment.Assignment;
22  import org.kuali.kpme.core.assignment.AssignmentDescriptionKey;
23  import org.kuali.kpme.core.calendar.entry.CalendarEntry;
24  import org.springframework.cache.annotation.Cacheable;
25  
26  public interface AssignmentService {
27  	/**
28  	 * Fetches a list of Assignments for a given principal Id as of a particular date
29  	 * @param principalId
30  	 * @param asOfDate
31  	 * @return
32  	 */
33      @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
34      public List<Assignment> getAssignments(String principalId, LocalDate asOfDate);
35  
36      /**
37       * Reverse lookup of an assignment based on the assignment id
38       * @param tkAssignmentId
39       * @return
40       */
41      @Cacheable(value= Assignment.CACHE_NAME, key="'tkAssignmentId=' + #p0")
42      public Assignment getAssignment(String tkAssignmentId);
43      /**
44       * Get Assignment Description key based off of description
45       * @param assignmentDesc
46       * @return
47       */
48      public AssignmentDescriptionKey getAssignmentDescriptionKey(String assignmentDesc);
49      /**
50       * Get all assignment descriptions for an assignment
51       * @param assignment
52       * @return
53       */
54  	public Map<String,String> getAssignmentDescriptions(Assignment assignment);
55  	/**
56  	 * Get all active assignments for a work area
57  	 * @param workArea
58  	 * @param asOfDate
59  	 * @return
60  	 */
61      @Cacheable(value= Assignment.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
62  	public List<Assignment> getActiveAssignmentsForWorkArea(Long workArea, LocalDate asOfDate);
63  
64      @Cacheable(value= Assignment.CACHE_NAME, key="'{getPrincipalIdsInActiveAssigmentsForWorkArea}' + 'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
65      public List<String> getPrincipalIdsInActiveAssignmentsForWorkArea(Long workArea, LocalDate asOfDate);
66  
67      @Cacheable(value= Assignment.CACHE_NAME, key="'{getPrincipalIdsInActiveAssigmentsForWorkAreas}' + 'workAreas=' + T(org.kuali.rice.core.api.cache.CacheKeyUtils).key(#p0) + '|' + 'asOfDate=' + #p1")
68      public List<String> getPrincipalIdsInActiveAssignmentsForWorkAreas(List<Long> workAreas, LocalDate asOfDate);
69  
70  	/**
71  	 * Get active assignments for all users for the current date
72  	 * CAUTION this method will return a lot of data in a normal production env
73  	 * It is intended to only be used in a batch setting
74  	 * @param asOfDate
75  	 * @return
76  	 */
77      @Cacheable(value= Assignment.CACHE_NAME, key="'asOfDate=' + #p0")
78  	public List<Assignment> getActiveAssignments(LocalDate asOfDate);
79  
80  
81      /**
82       * For a given AssignmentDescriptionKey return the matching assignment.
83       * @param key
84       * @return
85       */
86      public Assignment getAssignmentForTargetPrincipal(AssignmentDescriptionKey key, LocalDate asOfDate);
87  
88      
89      /**
90       * Fetch principal id and key as of a particular date
91       * @param principalId
92       * @param key
93       * @param asOfDate
94       * @return
95       */
96      public Assignment getAssignment(String principalId, AssignmentDescriptionKey key, LocalDate asOfDate);
97      
98      /**
99       * Get assignments by pay calendar entry
100      * @param principalId
101      * @param payCalendarEntry
102      * @return
103      */
104     @Cacheable(value= Assignment.CACHE_NAME, key="'{getAssignmentsByPayEntry}' + 'principalId=' + #p0 + '|' + 'payCalendarEntry=' + #p1.getHrCalendarEntryId()")
105     public List<Assignment> getAssignmentsByPayEntry(String principalId, CalendarEntry payCalendarEntry);
106     /**
107      * Get assignments for Time Calendar by calendar entry
108      * @param principalId
109      * @param calendarEntry
110      * @return
111      */
112     @Cacheable(value= Assignment.CACHE_NAME, key="'{getAssignmentsByCalEntryForTimeCalendar}' + 'principalId=' + #p0 + '|' + 'payCalendarEntry=' + #p1.getHrCalendarEntryId()")
113     public List<Assignment> getAssignmentsByCalEntryForTimeCalendar(String principalId, CalendarEntry calendarEntry);
114     /**
115      * Get assignments for Leave Calendar by calendar entry
116      * @param principalId
117      * @param calendarEntry
118      * @return
119      */
120     @Cacheable(value= Assignment.CACHE_NAME, key="'{getAssignmentsByCalEntryForLeaveCalendar}' + 'principalId=' + #p0 + '|' + 'payCalendarEntry=' + #p1.getHrCalendarEntryId()")
121     public List<Assignment> getAssignmentsByCalEntryForLeaveCalendar(String principalId, CalendarEntry calendarEntry);
122     
123     /**
124 	 * KPME-1129 Kagata
125 	 * Get a list of active assignments based on principalId and jobNumber as of a particular date 
126 	 * @param principalId
127 	 * @param jobNumber
128 	 * @param asOfDate
129 	 * @return
130 	 */
131     @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2")
132     public List<Assignment> getActiveAssignmentsForJob(String principalId, Long jobNumber, LocalDate asOfDate);
133 
134     List<Assignment> searchAssignments(String userPrincipalId, LocalDate fromEffdt, LocalDate toEffdt, String principalId, String jobNumber,
135                                     String dept, String workArea, String active, String showHistory);
136     
137     
138     /**
139      * Get all assignment descriptions for given list of Assignments
140      * @param assignments
141      * @return
142      */
143     public Map<String, String> getAssignmentDescriptionsForAssignments(List<Assignment>  assignments);
144     
145     public Assignment getAssignment(List<Assignment> assignments, String assignmentKey, LocalDate beginDate);
146     
147     public Assignment getMaxTimestampAssignment(String principalId);
148     
149     /**
150      * Filter the given list of assignments with given criteria
151      * @param assignments
152      * @param flsaStatus
153      * @param chkForLeaveEligible
154      * @return List<Assignment>
155      */
156     public List<Assignment> filterAssignments(List<Assignment> assignments, String flsaStatus, boolean chkForLeaveEligible);
157     
158 	/**
159 	 * Get list of unique principalIds with given workarea list and dates
160 	 * @param workAreaList
161 	 * @param effdt
162 	 * @param startDate
163 	 * @param endDate
164 	 * @return
165 	 */
166 	public List<String> getPrincipalIds(List<String> workAreaList, LocalDate effdt, LocalDate startDate, LocalDate endDate);
167 	
168 	public List<Assignment> getAssignments(List<String> workAreaList, LocalDate effdt, LocalDate startDate, LocalDate endDate);
169 
170     public String getAssignmentDescription(String principalId, Long jobNumber, Long workArea, Long task, LocalDate asOfDate);
171 
172     @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'beginDate=' + #p1 + '|' + 'endDate=' + #p2")
173     public Map<LocalDate, List<Assignment>> getAssignmentHistoryBetweenDays(String principalId, LocalDate beginDate, LocalDate endDate);
174 
175     public List<Assignment> filterAssignmentListForUser(String userPrincipalId, List<Assignment> assignments);
176 
177     public List<Assignment> getRecentAssignments(String principalId);
178 
179     public List<Assignment> getRecentAssignments(String principalId, LocalDate startDate, LocalDate endDate);
180 }