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     /**
111 	 * Reset the TimeHourDetail object associated with the TimeBlock object on a List of TimeBlocks
112 	 * @param origTimeBlocks
113 	 */
114     //@WebMethod(operationName = "resetTimeHourDetail")
115     //@XmlElementWrapper(name = "timeBlocks", required = true)
116     //@XmlElement(name = "timeBlock", required = false)
117     //@WebResult(name = "timeBlocks")
118 	public List<TimeBlock> resetTimeHourDetail(List<TimeBlock> origTimeBlocks);
119 
120     /**
121 	 * Get the List of TimeBlock of a given document id
122 	 * @param documentId
123 	 * @return
124 	 */
125     //@WebMethod(operationName = "getTimeBlocks")
126     //@XmlElementWrapper(name = "timeBlocks", required = true)
127     //@XmlElement(name = "timeBlock", required = false)
128     //@WebResult(name = "timeBlocks")
129 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocks}' + 'documentId=' + #p0")
130 	public List<TimeBlock> getTimeBlocks(String documentId);
131 
132     @Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksWithMissedPunchInfo}' + 'documentId=' + #p0")
133     public List<TimeBlock> getTimeBlocksWithMissedPunchInfo(String documentId);
134 
135     /**
136 	 * Build a List of TimeBlocks over a span of multiple days
137      * @param principalId
138      * @param calendarEntry
139 	 * @param assignment
140 	 * @param earnCode
141 	 * @param documentId
142 	 * @param beginDateTime
143 	 * @param endDateTime
144 	 * @param hours
145      * @param amount
146 	 * @param clockLogCreated
147      * @param lunchDeleted
148 	 * @return
149 	 */
150     //@WebMethod(operationName = "buildTimeBlocksSpanDates")
151     //@XmlElementWrapper(name = "timeBlocks", required = true)
152     //@XmlElement(name = "timeBlock", required = false)
153     //@WebResult(name = "timeBlocks")
154 	public List<TimeBlock> buildTimeBlocksSpanDates(String principalId, CalendarEntry calendarEntry, Assignment assignment, String earnCode,
155                                                     String documentId, DateTime beginDateTime, DateTime endDateTime, BigDecimal hours, BigDecimal amount,
156                                                     Boolean clockLogCreated, Boolean lunchDeleted, String userPrincipalId,
157                                                     String clockLogBeginId, String clockLogEndId);
158 	/**
159 	 * Create a TimeBlock for the given criteria
160 	 * @param principalId
161      * @param documentId
162 	 * @param beginDateTime
163 	 * @param endDateTime
164 	 * @param assignment
165 	 * @param earnCode
166 	 * @param hours
167      * @param amount
168 	 * @param clockLogCreated
169 	 * @param lunchDeleted
170 	 * @return
171 	 */
172     //@WebMethod(operationName = "createTimeBlock")
173     //@WebResult(name = "timeBlock")
174 	public TimeBlock createTimeBlock(String principalId, String documentId, DateTime beginDateTime, DateTime endDateTime,
175                                      Assignment assignment, String earnCode, BigDecimal hours, BigDecimal amount,
176                                         Boolean clockLogCreated, Boolean lunchDeleted, String userPrincipalId);
177 
178     //@WebMethod(operationName = "deleteTimeBlocksAssociatedWithDocumentId")
179     @Caching(evict = {
180             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true),
181             @CacheEvict(value={CalendarBlockPermissions.CACHE_NAME}, allEntries = true)
182     })
183 	public void deleteTimeBlocksAssociatedWithDocumentId(String documentId);
184 
185     //@WebMethod(operationName = "getTimeBlockEditable")
186     //@WebResult(name = "editable")
187 	public Boolean getTimeBlockEditable(TimeBlock tb);
188 	
189 	/*
190 	 * Get all the time blocks with the given Clock Log id as the clockLogEndId
191 	 * @param tkClockLogId
192 	 * @return List<TimeBlock>	 * 
193 	 */
194     //@WebMethod(operationName = "getTimeBlocksForClockLogEndId")
195     //@XmlElementWrapper(name = "timeBlocks", required = true)
196     //@XmlElement(name = "timeBlock", required = false)
197     //@WebResult(name = "timeBlocks")
198 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksForClockLogEndId}' + 'tkClockLogId=' + #p0")
199 	public List<TimeBlock> getTimeBlocksForClockLogEndId(String tkClockLogId);
200 
201 	/*
202 	 * Get all the time blocks with the given Clock Log id as the clockLogBeginId
203 	 * @param tkClockLogId
204 	 * @return List<TimeBlock>	 * 
205 	 */
206     //@WebMethod(operationName = "getTimeBlocksForClockLogBeginId")
207     //@XmlElementWrapper(name = "timeBlocks", required = true)
208     //@XmlElement(name = "timeBlock", required = false)
209     //@WebResult(name = "timeBlocks")
210 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getTimeBlocksForClockLogBeginId}' + 'tkClockLogId=' + #p0")
211 	public List<TimeBlock> getTimeBlocksForClockLogBeginId(String tkClockLogId);
212 
213     //@WebMethod(operationName = "getLatestEndTimestampForEarnCode")
214     //@XmlElementWrapper(name = "timeBlocks", required = true)
215     //@XmlElement(name = "timeBlock", required = false)
216     //@WebResult(name = "timeBlocks")
217 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getLatestEndTimestampForEarnCode}' + 'earnCode=' + #p0")
218 	public List<TimeBlock> getLatestEndTimestampForEarnCode(String earnCode);
219 
220     /**
221      * Get overnight timeblocks by the clock log begin id
222      * @param clockLogEndId
223      * @return
224      */
225     //@WebMethod(operationName = "getOvernightTimeBlocks")
226     //@XmlElementWrapper(name = "timeBlocks", required = true)
227     //@XmlElement(name = "timeBlock", required = false)
228     //@WebResult(name = "timeBlocks")
229 	@Cacheable(value= TimeBlock.CACHE_NAME, key="'{getOvernightTimeBlocks}' + 'clockLogEndId=' + #p0")
230 	public List<TimeBlock> getOvernightTimeBlocks(String clockLogEndId);
231 
232     //@WebMethod(operationName = "isOvernightTimeBlock")
233     //@WebResult(name = "overnightBlock")
234     @Cacheable(value= TimeBlock.CACHE_NAME, key="'{isOvernightTimeBlock}' + 'clockLogEndId=' + #p0")
235     public boolean isOvernightTimeBlock(String clockLogEndId);
236 
237     //@WebMethod(operationName = "updateTimeBlock")
238     //@WebResult(name = "timeBlock")
239     @Caching(evict = {
240             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true),
241             @CacheEvict(value={CalendarBlockPermissions.CACHE_NAME}, key="'{time}' + #p0.tkTimeBlockId")
242     })
243 	public TimeBlock updateTimeBlock(TimeBlock tb);
244 	
245     //@WebMethod(operationName = "deleteLunchDeduction")
246     @Caching(evict = {
247             @CacheEvict(value={TimeBlock.CACHE_NAME}, allEntries = true)
248     })
249     void deleteLunchDeduction(String tkTimeHourDetailId);
250 
251     //@WebMethod(operationName = "applyHolidayPremiumEarnCode")
252     //@XmlElementWrapper(name = "timeBlocks", required = true)
253     //@XmlElement(name = "timeBlock", required = false)
254     //@WebResult(name = "timeBlocks")
255 	public List<TimeBlock> applyHolidayPremiumEarnCode(String principalId, List<Assignment> timeAssignments, List<TimeBlock> appliedTimeBlocks);
256 
257 
258     public List<TimeBlock> getIntersectingTimeBlocks(String principalId, DateTime startTime, DateTime endTime);
259 }