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.tklm.api.time.timeblock;
17  
18  import org.joda.time.DateTime;
19  import org.joda.time.Interval;
20  import org.kuali.kpme.core.api.assignment.Assignment;
21  import org.kuali.kpme.core.api.block.CalendarBlockPermissions;
22  import org.kuali.kpme.core.api.calendar.entry.CalendarEntry;
23  import org.springframework.cache.annotation.CacheEvict;
24  import org.springframework.cache.annotation.Cacheable;
25  import org.springframework.cache.annotation.Caching;
26  
27  import javax.jws.WebMethod;
28  import javax.jws.WebResult;
29  import javax.xml.bind.annotation.XmlElement;
30  import javax.xml.bind.annotation.XmlElementWrapper;
31  import java.math.BigDecimal;
32  import java.util.List;
33  
34  //@WebService(name = "groupService", targetNamespace = TkConstants.Namespace.TKLM_NAMESPACE_2_1)
35  //@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
36  public interface TimeBlockService {
37  	/**
38  	 * Fetch a TimeBlock by a given ID
39  	 * @param timeBlockId
40  	 * @return
41  	 */
42      //@WebMethod(operationName = "getTimeBlock")
43      //@WebResult(name = "timeBlock")
44  	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlock}' + 'timeBlockId=' + #p0")
45  	public TimeBlock getTimeBlock(String timeBlockId);
46  
47  	/**
48  	 * Delete a given TimeBlock
49  	 * @param timeBlock
50  	 */
51      //@WebMethod(operationName = "deleteTimeBlock")
52      @Caching(evict = {
53              @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true),
54              @CacheEvict(value={CalendarBlockPermissions.CACHE_NAME}, key="'{time}' + #p0.tkTimeBlockId")
55      })
56  	public void deleteTimeBlock(TimeBlock timeBlock);
57  	/**
58  	 * Build a TimeBlock with the given criteria
59       * @param principalId
60       * @param calendarEntry
61  	 * @param assignment
62  	 * @param earnCode
63  	 * @param documentId
64  	 * @param beginDateTime
65  	 * @param endDateTime
66  	 * @param hours
67       * @param amount
68  	 * @param getClockLogCreated
69       * @param getLunchDeleted
70       * @param clockLogBeginId
71       * @param clockLogEndId
72  	 * @return
73  	 */
74      //@WebMethod(operationName = "buildTimeBlocks")
75      //@XmlElementWrapper(name = "timeBlocks", required = true)
76      //@XmlElement(name = "timeBlock", required = false)
77      @WebResult(name = "timeBlocks")
78  	public List<TimeBlock> buildTimeBlocks(String principalId, CalendarEntry calendarEntry, Assignment assignment, String earnCode, String documentId,
79  											DateTime beginDateTime, DateTime endDateTime, BigDecimal hours, BigDecimal amount,
80                                              Boolean getClockLogCreated, Boolean getLunchDeleted, String userPrincipalId,
81                                              String clockLogBeginId, String clockLogEndId);
82  	/**
83  	 * Save a list of new TimeBlocks
84  	 * does a comparison for the old versus the new and only saves changed/new/deleted TimeBlocks
85  	 * @param oldTimeBlocks
86  	 * @param newTimeBlocks
87  	 */
88      //@WebMethod(operationName = "saveOrUpdateTimeBlocks")
89      //@XmlElementWrapper(name = "timeBlocks", required = true)
90      //@XmlElement(name = "timeBlock", required = false)
91      //@WebResult(name = "timeBlocks")
92      @Caching(evict = {
93              @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true)
94      })
95  	public List<TimeBlock> saveOrUpdateTimeBlocks(List<TimeBlock> oldTimeBlocks, List<TimeBlock> newTimeBlocks, String userPrincipalId);
96  
97  	/**
98  	 * Save a list of new TimeBlocks
99  	 * @param tbList
100 	 */
101     @WebMethod(operationName = "saveTimeBlocks")
102     @XmlElementWrapper(name = "timeBlocks", required = true)
103     @XmlElement(name = "timeBlock", required = false)
104     @WebResult(name = "timeBlocks")
105     @Caching(evict = {
106             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true)
107     })
108 	public List<TimeBlock> saveTimeBlocks(List<TimeBlock> tbList);
109 
110     void deleteTimeBlockAndHandleMissedPunch(TimeBlock timeBlock, boolean ignoreMissedPunch);
111 
112     /**
113 	 * Reset the TimeHourDetail object associated with the TimeBlock object on a List of TimeBlocks
114 	 * @param origTimeBlocks
115 	 */
116     //@WebMethod(operationName = "resetTimeHourDetail")
117     //@XmlElementWrapper(name = "timeBlocks", required = true)
118     //@XmlElement(name = "timeBlock", required = false)
119     //@WebResult(name = "timeBlocks")
120 	public List<TimeBlock> resetTimeHourDetail(List<TimeBlock> origTimeBlocks);
121 
122     /**
123 	 * Get the List of TimeBlock of a given document id
124 	 * @param documentId
125 	 * @return
126 	 */
127     //@WebMethod(operationName = "getTimeBlocks")
128     //@XmlElementWrapper(name = "timeBlocks", required = true)
129     //@XmlElement(name = "timeBlock", required = false)
130     //@WebResult(name = "timeBlocks")
131 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocks}' + 'documentId=' + #p0")
132 	public List<TimeBlock> getTimeBlocks(String documentId);
133 
134     @Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksWithMissedPunchInfo}' + 'documentId=' + #p0")
135     public List<TimeBlock> getTimeBlocksWithMissedPunchInfo(String documentId);
136 
137     /**
138 	 * Build a List of TimeBlocks over a span of multiple days
139      * @param principalId
140      * @param calendarEntry
141 	 * @param assignment
142 	 * @param earnCode
143 	 * @param documentId
144 	 * @param beginDateTime
145 	 * @param endDateTime
146 	 * @param hours
147      * @param amount
148 	 * @param clockLogCreated
149      * @param lunchDeleted
150 	 * @return
151 	 */
152     //@WebMethod(operationName = "buildTimeBlocksSpanDates")
153     //@XmlElementWrapper(name = "timeBlocks", required = true)
154     //@XmlElement(name = "timeBlock", required = false)
155     //@WebResult(name = "timeBlocks")
156 	public List<TimeBlock> buildTimeBlocksSpanDates(String principalId, CalendarEntry calendarEntry, Assignment assignment, String earnCode,
157                                                     String documentId, DateTime beginDateTime, DateTime endDateTime, BigDecimal hours, BigDecimal amount,
158                                                     Boolean clockLogCreated, Boolean lunchDeleted, String userPrincipalId,
159                                                     String clockLogBeginId, String clockLogEndId);
160 	/**
161 	 * Create a TimeBlock for the given criteria
162 	 * @param principalId
163      * @param documentId
164 	 * @param beginDateTime
165 	 * @param endDateTime
166 	 * @param assignment
167 	 * @param earnCode
168 	 * @param hours
169      * @param amount
170 	 * @param clockLogCreated
171 	 * @param lunchDeleted
172 	 * @return
173 	 */
174     //@WebMethod(operationName = "createTimeBlock")
175     //@WebResult(name = "timeBlock")
176 	public TimeBlock createTimeBlock(String principalId, String documentId, DateTime beginDateTime, DateTime endDateTime,
177                                      Assignment assignment, String earnCode, BigDecimal hours, BigDecimal amount,
178                                         Boolean clockLogCreated, Boolean lunchDeleted, String userPrincipalId);
179 
180     //@WebMethod(operationName = "deleteTimeBlocksAssociatedWithDocumentId")
181     @Caching(evict = {
182             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true),
183             @CacheEvict(value={CalendarBlockPermissions.CACHE_NAME}, allEntries = true)
184     })
185 	public void deleteTimeBlocksAssociatedWithDocumentId(String documentId);
186 
187     //@WebMethod(operationName = "getTimeBlockEditable")
188     //@WebResult(name = "editable")
189 	public Boolean getTimeBlockEditable(TimeBlock tb);
190 	
191 	/*
192 	 * Get all the time blocks with the given Clock Log id as the clockLogEndId
193 	 * @param tkClockLogId
194 	 * @return List<TimeBlock>	 * 
195 	 */
196     //@WebMethod(operationName = "getTimeBlocksForClockLogEndId")
197     //@XmlElementWrapper(name = "timeBlocks", required = true)
198     //@XmlElement(name = "timeBlock", required = false)
199     //@WebResult(name = "timeBlocks")
200 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksForClockLogEndId}' + 'tkClockLogId=' + #p0")
201 	public List<TimeBlock> getTimeBlocksForClockLogEndId(String tkClockLogId);
202 
203 	/*
204 	 * Get all the time blocks with the given Clock Log id as the clockLogBeginId
205 	 * @param tkClockLogId
206 	 * @return List<TimeBlock>	 * 
207 	 */
208     //@WebMethod(operationName = "getTimeBlocksForClockLogBeginId")
209     //@XmlElementWrapper(name = "timeBlocks", required = true)
210     //@XmlElement(name = "timeBlock", required = false)
211     //@WebResult(name = "timeBlocks")
212 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksForClockLogBeginId}' + 'tkClockLogId=' + #p0")
213 	public List<TimeBlock> getTimeBlocksForClockLogBeginId(String tkClockLogId);
214 
215     //@WebMethod(operationName = "getLatestEndTimestampForEarnCode")
216     //@XmlElementWrapper(name = "timeBlocks", required = true)
217     //@XmlElement(name = "timeBlock", required = false)
218     //@WebResult(name = "timeBlocks")
219 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getLatestEndTimestampForEarnCode}' + 'earnCode=' + #p0")
220 	public List<TimeBlock> getLatestEndTimestampForEarnCode(String earnCode);
221 
222     /**
223      * Get overnight timeblocks by the clock log begin id
224      * @param clockLogEndId
225      * @return
226      */
227     //@WebMethod(operationName = "getOvernightTimeBlocks")
228     //@XmlElementWrapper(name = "timeBlocks", required = true)
229     //@XmlElement(name = "timeBlock", required = false)
230     //@WebResult(name = "timeBlocks")
231 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getOvernightTimeBlocks}' + 'clockLogEndId=' + #p0")
232 	public List<TimeBlock> getOvernightTimeBlocks(String clockLogEndId);
233 
234     //@WebMethod(operationName = "isOvernightTimeBlock")
235     //@WebResult(name = "overnightBlock")
236     @Cacheable(value= TimeBlock.CACHE_NAME, key="'{isOvernightTimeBlock}' + 'clockLogEndId=' + #p0")
237     public boolean isOvernightTimeBlock(String clockLogEndId);
238 
239     //@WebMethod(operationName = "updateTimeBlock")
240     //@WebResult(name = "timeBlock")
241     @Caching(evict = {
242             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true),
243             @CacheEvict(value={CalendarBlockPermissions.CACHE_NAME}, key="'{time}' + #p0.tkTimeBlockId")
244     })
245 	public TimeBlock updateTimeBlock(TimeBlock tb);
246 	
247     //@WebMethod(operationName = "deleteLunchDeduction")
248     @Caching(evict = {
249             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true)
250     })
251     void deleteLunchDeduction(String tkTimeHourDetailId);
252 
253     //@WebMethod(operationName = "applyHolidayPremiumEarnCode")
254     //@XmlElementWrapper(name = "timeBlocks", required = true)
255     //@XmlElement(name = "timeBlock", required = false)
256     //@WebResult(name = "timeBlocks")
257 	public List<TimeBlock> applyHolidayPremiumEarnCode(String principalId, List<Assignment> timeAssignments, List<TimeBlock> appliedTimeBlocks);
258 
259 
260     public List<TimeBlock> getIntersectingTimeBlocks(String principalId, DateTime startTime, DateTime endTime);
261 }