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.timeblock.service;
017    
018    import org.kuali.hr.time.assignment.Assignment;
019    import org.kuali.hr.time.timeblock.TimeBlock;
020    import org.kuali.hr.time.timeblock.TimeBlockHistory;
021    import org.kuali.hr.time.timesheet.TimesheetDocument;
022    
023    import java.math.BigDecimal;
024    import java.sql.Date;
025    import java.sql.Timestamp;
026    import java.util.List;
027    
028    public interface TimeBlockService {
029            /**
030             * Fetch a TimeBlock by a given ID
031             * @param timeBlockId
032             * @return
033             */
034            public TimeBlock getTimeBlock(String timeBlockId);
035    
036            /**
037             * Delete a given TimeBlock
038             * @param timeBlock
039             */
040            public void deleteTimeBlock(TimeBlock timeBlock);
041            /**
042             * Build a TimeBlock with the given criteria
043             * @param assignment
044             * @param earnCode
045             * @param timesheetDocument
046             * @param beginTimestamp
047             * @param endTimestamp
048             * @param hours
049         * @param amount
050             * @param isClockLogCreated
051         * @param isLunchDeleted
052             * @return
053             */
054            public List<TimeBlock> buildTimeBlocks(Assignment assignment, String earnCode, TimesheetDocument timesheetDocument,
055                                                                                            Timestamp beginTimestamp, Timestamp endTimestamp, BigDecimal hours, BigDecimal amount,
056                                                Boolean isClockLogCreated, Boolean isLunchDeleted);
057            /**
058             * Save a list of new TimeBlocks
059             * does a comparison for the old versus the new and only saves changed/new/deleted TimeBlocks
060             * @param oldTimeBlocks
061             * @param newTimeBlocks
062             */
063            public void saveTimeBlocks(List<TimeBlock> oldTimeBlocks, List<TimeBlock> newTimeBlocks);
064    
065            /**
066             * Save a list of new TimeBlocks
067             * @param tbList
068             */
069            public void saveTimeBlocks(List<TimeBlock> tbList);
070            /**
071             * Reset the TimeHourDetail object associated with the TimeBlock object on a List of TimeBlocks
072             * @param origTimeBlocks
073             */
074            public void resetTimeHourDetail(List<TimeBlock> origTimeBlocks);
075            /**
076             * Get the List of TimeBlock of a given document id
077             * @param documentId
078             * @return
079             */
080            public List<TimeBlock> getTimeBlocks(String documentId);  
081            /**
082             * Get the List of TimeBlock of a given Assignment
083             * @param assign
084             * @return List<TimeBlock>
085             */
086             public List<TimeBlock> getTimeBlocksForAssignment(Assignment assign);
087            /**
088             * Build a List of TimeBlocks over a span of multiple days
089             * @param assignment
090             * @param earnCode
091             * @param timesheetDocument
092             * @param beginTimestamp
093             * @param endTimestamp
094             * @param hours
095         * @param amount
096             * @param isClockLogCreated
097         * @param isLunchDeleted
098         * @param spanningWeeks
099             * @return
100             */
101            public List<TimeBlock> buildTimeBlocksSpanDates(Assignment assignment, String earnCode, TimesheetDocument timesheetDocument,
102                                                                                                    Timestamp beginTimestamp, Timestamp endTimestamp, BigDecimal hours, BigDecimal amount,
103                                                    Boolean isClockLogCreated, Boolean isLunchDeleted, String spanningWeeks);
104            /**
105             * Create a TimeBlock for the given criteria
106             * @param timesheetDocument
107             * @param beginTime
108             * @param endTime
109             * @param assignment
110             * @param earnCode
111             * @param hours
112         * @param amount
113             * @param isClockLogCreated
114             * @param isLunchDeleted
115             * @return
116             */
117            public TimeBlock createTimeBlock(TimesheetDocument timesheetDocument, Timestamp beginTime, Timestamp endTime,
118                                                                                    Assignment assignment, String earnCode, BigDecimal hours, BigDecimal amount,
119                                            Boolean isClockLogCreated, Boolean isLunchDeleted);
120    
121            public void deleteTimeBlocksAssociatedWithDocumentId(String documentId);
122    
123            public Boolean isTimeBlockEditable(TimeBlock tb);
124            
125            /*
126             * Get all the time blocks with the given Clock Log id as the clockLogEndId
127             * @param tkClockLogId
128             * @return List<TimeBlock>         * 
129             */
130            public List<TimeBlock> getTimeBlocksForClockLogEndId(String tkClockLogId);
131            /*
132             * Get all the time blocks with the given Clock Log id as the clockLogBeginId
133             * @param tkClockLogId
134             * @return List<TimeBlock>         * 
135             */
136            public List<TimeBlock> getTimeBlocksForClockLogBeginId(String tkClockLogId);
137            
138            public List<TimeBlock> getTimeBlocks();
139            public List<TimeBlock> getLatestEndTimestamp();
140    
141        /**
142         * Get overnight timeblocks by the clock log begin id
143         * @param clockLogEndId
144         * @return
145         */
146        public List<TimeBlock> getOvernightTimeBlocks(String clockLogEndId);
147    
148            public void updateTimeBlock(TimeBlock tb);
149            
150            public List<TimeBlockHistory> createTimeBlockHistories(TimeBlock tb, String actionHistory);
151    
152        void deleteLunchDeduction(String tkTimeHourDetailId);
153            /*
154             * Get all the active time blocks with the given earn code and effectiveDate
155             * @param earnCode
156             * @param effDate
157             * @return List<TimeBlock>         * 
158             */
159        public List<TimeBlock> getTimeBlocksWithEarnCode(String earnCode, Date effDate);
160    }