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.job.service;
017    
018    import org.kuali.hr.job.Job;
019    import org.springframework.cache.annotation.CacheEvict;
020    import org.springframework.cache.annotation.Cacheable;
021    
022    import java.math.BigDecimal;
023    import java.util.Date;
024    import java.util.List;
025    
026    public interface JobService {
027    
028            /**
029             * Updates or saves a job
030             * @param job
031             */
032        @CacheEvict(value={Job.CACHE_NAME}, allEntries = true)
033            public void saveOrUpdate(Job job);
034            
035            /**
036             * Updates or saves a list of jobs
037             * @param jobList
038             */
039        @CacheEvict(value={Job.CACHE_NAME}, allEntries = true)
040            public void saveOrUpdate(List<Job> jobList);
041            
042            /**
043             * Provides a list of current jobs that are valid relative to the provided effective date.  
044             * Timestamp of row creation is taken into account when two rows with the same job number
045             * have the same effective date.
046             * 
047             * Assignments are NOT populated on this object.  We may want to consider removing 
048             * getAssignments().
049             * 
050             * @param principalId
051             * @param asOfDate
052             * @return
053             */
054        @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
055            public List<Job> getJobs(String principalId, Date asOfDate);
056            
057            /**
058             * Provides a job by specific job number, principal ID and as of Date combination. 
059             */
060        @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2")
061            public Job getJob(String principalId, Long jobNumber, Date asOfDate);
062            
063            /**
064             * Provides a job by specific job number, principal ID and as of Date combination, and check details will throw error if required. 
065             */
066        @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2 + '|' + 'chkDetails=' + #p3")
067            public Job getJob(String principalId, Long jobNumber, Date asOfDate, boolean chkDetails);
068            
069            /**
070             * For a given principal ID, the job that is marked "primary" is returned 
071             * here.
072             * 
073             * @param principalId The principal under investigation
074             * @param asOfDate Run the request as of this date. 
075             * @return
076             */
077        @Cacheable(value= Job.CACHE_NAME, key="'{getPrimaryJob}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
078            public Job getPrimaryJob(String principalId, Date asOfDate);
079            
080            /**
081             * 
082             * @param positionNbr
083             * @param asOfDate
084             * @return
085             */
086        @Cacheable(value= Job.CACHE_NAME, key="'positionNbr=' + #p0 + '|' + 'asOfDate=' + #p1")
087            public List<Job> getActiveJobsForPosition(String positionNbr, Date asOfDate);
088            
089            /**
090             * 
091             * @param hrPayType
092             * @param asOfDate
093             * @return
094             */
095        @Cacheable(value= Job.CACHE_NAME, key="'hrPayType=' + #p0 + '|' + 'asOfDate=' + #p1")
096            public List<Job> getActiveJobsForPayType(String hrPayType, Date asOfDate);
097            
098            /**
099             * Get job by the unique id
100             * @param hrJobId
101             * @return
102             */
103        @Cacheable(value= Job.CACHE_NAME, key="'hrJobId=' + #p0")
104            public Job getJob(String hrJobId);
105            
106            /**
107             * Get the max jobnumber job for this principal
108             * @param principalId
109             * @return
110             */
111        @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0")
112            public Job getMaxJob(String principalId);
113    
114        List<Job> getJobs(String principalId, String firstName, String lastName, String jobNumber,
115                          String dept, String positionNbr, String payType,
116                          java.sql.Date fromEffdt, java.sql.Date toEffdt, String active, String showHistory);
117        
118        public int getJobCount(String principalId, Long jobNumber, String dept);
119        
120            /**
121             * Get list of active jobs eligible for leave for given principal and date
122             * @param principalId
123             * @param asOfDate
124             * @return
125             */
126        public List<Job> getActiveLeaveJobs(String principalId, Date asOfDate);
127        
128        /**
129             * Get sum of fte of given jobs
130             * @param jobs
131             * @return
132             */
133        public BigDecimal getFteSumForJobs(List<Job> jobs);
134        
135        /**
136         * Returns FTE for all active LM eligible jobs.
137         * @param PrincipalId
138         * @return
139         */
140        public BigDecimal getFteSumForAllActiveLeaveEligibleJobs(String PrincipalId, Date asOfDate);
141        /**
142             * Get sum of standard hours of given jobs
143             * @param jobs
144             * @return
145             */
146        public BigDecimal getStandardHoursSumForJobs(List<Job> jobs);
147        
148        /**
149             * Get list of all active jobs eligible for leave for given principal and date range
150             * @param principalId
151             * @param asOfDate
152             * @return
153             */
154        public List<Job> getAllActiveLeaveJobs(String principalId, Date asOfDate);
155        
156        public List<Job> getInactiveLeaveJobs(Long jobNumber, Date startDate, Date endDate);
157        
158        public List<Job> getAllInActiveLeaveJobsInRange(String principalId, Date startDate, Date endDate);
159        
160        /*
161         * Get the job entry with the max timestamp for given pricipalId
162         */
163        public Job getMaxTimestampJob(String principalId);
164        
165    }