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.assignment.service;
017
018 import org.kuali.hr.time.assignment.Assignment;
019 import org.kuali.hr.time.assignment.AssignmentDescriptionKey;
020 import org.kuali.hr.time.calendar.CalendarEntries;
021 import org.kuali.hr.time.timesheet.TimesheetDocument;
022 import org.springframework.cache.annotation.Cacheable;
023
024 import java.sql.Date;
025 import java.util.List;
026 import java.util.Map;
027
028 public interface AssignmentService {
029 /**
030 * Fetches a list of Assignments for a given principal Id as of a particular date
031 * @param principalId
032 * @param asOfDate
033 * @return
034 */
035 @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
036 public List<Assignment> getAssignments(String principalId, Date asOfDate);
037 /**
038 * Reverse lookup of an assignment based on the assignment key and the document
039 * @param timesheetDocument
040 * @param assignmentKey
041 * @return
042 */
043 public Assignment getAssignment(TimesheetDocument timesheetDocument, String assignmentKey);
044 /**
045 * Reverse lookup of an assignment based on the assignment id
046 * @param tkAssignmentId
047 * @return
048 */
049 @Cacheable(value= Assignment.CACHE_NAME, key="'tkAssignmentId=' + #p0")
050 public Assignment getAssignment(String tkAssignmentId);
051 /**
052 * Get Assignment Description key based off of description
053 * @param assignmentDesc
054 * @return
055 */
056 public AssignmentDescriptionKey getAssignmentDescriptionKey(String assignmentDesc);
057 /**
058 * Get all assignment descriptions for a document
059 * @param td
060 * @param clockOnlyAssignments
061 * @return
062 */
063 public Map<String,String> getAssignmentDescriptions(TimesheetDocument td, boolean clockOnlyAssignments);
064 /**
065 * Get all assignment descriptions for an assignment
066 * @param assignment
067 * @return
068 */
069 public Map<String,String> getAssignmentDescriptions(Assignment assignment);
070 /**
071 * Get all active assignments for a work area
072 * @param workArea
073 * @param asOfDate
074 * @return
075 */
076 @Cacheable(value= Assignment.CACHE_NAME, key="'workArea=' + #p0 + '|' + 'asOfDate=' + #p1")
077 public List<Assignment> getActiveAssignmentsForWorkArea(Long workArea, Date asOfDate);
078
079 /**
080 * Get active assignments for all users for the current date
081 * CAUTION this method will return a lot of data in a normal production env
082 * It is intended to only be used in a batch setting
083 * @param asOfDate
084 * @return
085 */
086 @Cacheable(value= Assignment.CACHE_NAME, key="'asOfDate=' + #p0")
087 public List<Assignment> getActiveAssignments(Date asOfDate);
088
089
090 /**
091 * For a given AssignmentDescriptionKey return the matching assignment.
092 * @param key
093 * @return
094 */
095 public Assignment getAssignment(AssignmentDescriptionKey key, Date asOfDate);
096
097
098 /**
099 * Fetch principal id and key as of a particular date
100 * @param principalId
101 * @param key
102 * @param asOfDate
103 * @return
104 */
105 public Assignment getAssignment(String principalId, AssignmentDescriptionKey key, Date asOfDate);
106
107 /**
108 * Get assignments by pay calendar entry
109 * @param principalId
110 * @param payCalendarEntry
111 * @return
112 */
113 public List<Assignment> getAssignmentsByPayEntry(String principalId, CalendarEntries payCalendarEntry);
114
115 /**
116 * KPME-1129 Kagata
117 * Get a list of active assignments based on principalId and jobNumber as of a particular date
118 * @param principalId
119 * @param jobNumber
120 * @param asOfDate
121 * @return
122 */
123 @Cacheable(value= Assignment.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2")
124 public List<Assignment> getActiveAssignmentsForJob(String principalId, Long jobNumber, Date asOfDate);
125
126 List<Assignment> searchAssignments(Date fromEffdt, Date toEffdt, String principalId, String jobNumber,
127 String dept, String workArea, String active, String showHistory);
128
129 public Assignment getMaxTimestampAssignment(String principalId);
130 }