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.assignment.service;
017
018 import org.kuali.hr.lm.leavecalendar.LeaveCalendarDocument;
019 import org.kuali.hr.time.assignment.Assignment;
020 import org.kuali.hr.time.assignment.AssignmentDescriptionKey;
021 import org.kuali.hr.time.calendar.CalendarEntries;
022 import org.kuali.hr.time.timesheet.TimesheetDocument;
023 import org.springframework.cache.annotation.Cacheable;
024
025 import java.sql.Date;
026 import java.util.List;
027 import java.util.Map;
028
029 public interface AssignmentService {
030 /**
031 * Fetches a list of Assignments for a given principal Id as of a particular date
032 * @param principalId
033 * @param asOfDate
034 * @return
035 */
036 @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
037 public List<Assignment> getAssignments(String principalId, Date asOfDate);
038 /**
039 * Reverse lookup of an assignment based on the assignment key and the document
040 * @param timesheetDocument
041 * @param assignmentKey
042 * @return
043 */
044 public Assignment getAssignment(TimesheetDocument timesheetDocument, String assignmentKey);
045 /**
046 * Reverse lookup of an assignment based on the assignment id
047 * @param tkAssignmentId
048 * @return
049 */
050 @Cacheable(value= Assignment.CACHE_NAME, key="'tkAssignmentId=' + #p0")
051 public Assignment getAssignment(String tkAssignmentId);
052 /**
053 * Get Assignment Description key based off of description
054 * @param assignmentDesc
055 * @return
056 */
057 public AssignmentDescriptionKey getAssignmentDescriptionKey(String assignmentDesc);
058 /**
059 * Get all assignment descriptions for a document
060 * @param td
061 * @param clockOnlyAssignments
062 * @return
063 */
064 public Map<String,String> getAssignmentDescriptions(TimesheetDocument td, boolean clockOnlyAssignments);
065 /**
066 * Get all assignment descriptions for an assignment
067 * @param assignment
068 * @return
069 */
070 public Map<String,String> getAssignmentDescriptions(Assignment assignment);
071 /**
072 * Get all active assignments for a work area
073 * @param workArea
074 * @param asOfDate
075 * @return
076 */
077 @Cacheable(value= Assignment.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
078 public List<Assignment> getActiveAssignmentsForWorkArea(Long workArea, Date asOfDate);
079
080 /**
081 * Get active assignments for all users for the current date
082 * CAUTION this method will return a lot of data in a normal production env
083 * It is intended to only be used in a batch setting
084 * @param asOfDate
085 * @return
086 */
087 @Cacheable(value= Assignment.CACHE_NAME, key="'asOfDate=' + #p0")
088 public List<Assignment> getActiveAssignments(Date asOfDate);
089
090
091 /**
092 * For a given AssignmentDescriptionKey return the matching assignment.
093 * @param key
094 * @return
095 */
096 public Assignment getAssignment(AssignmentDescriptionKey key, Date asOfDate);
097
098
099 /**
100 * Fetch principal id and key as of a particular date
101 * @param principalId
102 * @param key
103 * @param asOfDate
104 * @return
105 */
106 public Assignment getAssignment(String principalId, AssignmentDescriptionKey key, Date asOfDate);
107
108 /**
109 * Get assignments by pay calendar entry
110 * @param principalId
111 * @param payCalendarEntry
112 * @return
113 */
114 public List<Assignment> getAssignmentsByPayEntry(String principalId, CalendarEntries payCalendarEntry);
115 /**
116 * Get assignments for Time Calendar by calendar entry
117 * @param principalId
118 * @param calendarEntry
119 * @return
120 */
121 public List<Assignment> getAssignmentsByCalEntryForTimeCalendar(String principalId, CalendarEntries calendarEntry);
122 /**
123 * Get assignments for Leave Calendar by calendar entry
124 * @param principalId
125 * @param calendarEntry
126 * @return
127 */
128 public List<Assignment> getAssignmentsByCalEntryForLeaveCalendar(String principalId, CalendarEntries calendarEntry);
129
130 /**
131 * KPME-1129 Kagata
132 * Get a list of active assignments based on principalId and jobNumber as of a particular date
133 * @param principalId
134 * @param jobNumber
135 * @param asOfDate
136 * @return
137 */
138 @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2")
139 public List<Assignment> getActiveAssignmentsForJob(String principalId, Long jobNumber, Date asOfDate);
140
141 List<Assignment> searchAssignments(Date fromEffdt, Date toEffdt, String principalId, String jobNumber,
142 String dept, String workArea, String active, String showHistory);
143
144
145 /**
146 * Get all assignment descriptions for a document
147 * @param td
148 * @param clockOnlyAssignments
149 * @return
150 */
151 public Map<String,String> getAssignmentDescriptions(LeaveCalendarDocument lcd);
152
153 /**
154 * Get all assignment descriptions for given list of Assignments
155 * @param assignments
156 * @return
157 */
158 public Map<String, String> getAssignmentDescriptionsForAssignments(List<Assignment> assignments);
159
160 public Assignment getAssignment(LeaveCalendarDocument leaveCalendarDocument, String assignmentKey);
161
162 public Assignment getAssignment(List<Assignment> assignments, String assignmentKey, Date beginDate);
163
164 public Assignment getMaxTimestampAssignment(String principalId);
165
166 /**
167 * Filter the given list of assignments with given criteria
168 * @param assignments
169 * @param flsaStatus
170 * @param chkForLeaveEligible
171 * @return List<Assignment>
172 */
173 public List<Assignment> filterAssignments(List<Assignment> assignments, String flsaStatus, boolean chkForLeaveEligible);
174
175 /**
176 * Get assignment that applies to primary job of employee
177 * to be used in calculating system scheduled time off
178 * @param timesheetDocument
179 * @param payEndDate
180 * @return
181 */
182 public Assignment getAssignmentToApplyScheduledTimeOff(TimesheetDocument timesheetDocument, java.sql.Date payEndDate);
183 /**
184 * Get list of unique principalIds with given workarea list and dates
185 * @param workAreaList
186 * @param effdt
187 * @param startDate
188 * @param endDate
189 * @return
190 */
191 public List<String> getPrincipalIds(List<String> workAreaList, Date effdt, Date startDate, Date endDate);
192
193 public List<Assignment> getAssignments(List<String> workAreaList, Date effdt, Date startDate, Date endDate);
194 }