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.core.job.service;
17  
18  import java.math.BigDecimal;
19  import java.util.List;
20  
21  import org.joda.time.LocalDate;
22  import org.kuali.kpme.core.assignment.Assignment;
23  import org.kuali.kpme.core.block.CalendarBlockPermissions;
24  import org.kuali.kpme.core.job.Job;
25  import org.springframework.cache.annotation.CacheEvict;
26  import org.springframework.cache.annotation.Cacheable;
27  
28  public interface JobService {
29  
30  	/**
31  	 * Updates or saves a job
32  	 * @param job
33  	 */
34      @CacheEvict(value={Job.CACHE_NAME, Assignment.CACHE_NAME, CalendarBlockPermissions.CACHE_NAME}, allEntries = true)
35  	public void saveOrUpdate(Job job);
36  	
37  	/**
38  	 * Updates or saves a list of jobs
39  	 * @param jobList
40  	 */
41      @CacheEvict(value={Job.CACHE_NAME, Assignment.CACHE_NAME, CalendarBlockPermissions.CACHE_NAME}, allEntries = true)
42  	public void saveOrUpdate(List<Job> jobList);
43  	
44  	/**
45  	 * Provides a list of current jobs that are valid relative to the provided effective date.  
46  	 * Timestamp of row creation is taken into account when two rows with the same job number
47  	 * have the same effective date.
48  	 * 
49  	 * Assignments are NOT populated on this object.  We may want to consider removing 
50  	 * getAssignments().
51  	 * 
52  	 * @param principalId
53  	 * @param asOfDate
54  	 * @return
55  	 */
56      @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
57  	public List<Job> getJobs(String principalId, LocalDate asOfDate);
58  	
59  	/**
60  	 * Provides a job by specific job number, principal ID and as of Date combination. 
61  	 */
62      @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2")
63  	public Job getJob(String principalId, Long jobNumber, LocalDate asOfDate);
64  	
65  	/**
66  	 * Provides a job by specific job number, principal ID and as of Date combination, and check details will throw error if required. 
67  	 */
68      @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0 + '|' + 'jobNumber=' + #p1 + '|' + 'asOfDate=' + #p2 + '|' + 'chkDetails=' + #p3")
69  	public Job getJob(String principalId, Long jobNumber, LocalDate asOfDate, boolean chkDetails);
70  	
71  	/**
72  	 * For a given principal ID, the job that is marked "primary" is returned 
73  	 * here.
74  	 * 
75  	 * @param principalId The principal under investigation
76  	 * @param asOfDate Run the request as of this date. 
77  	 * @return
78  	 */
79      @Cacheable(value= Job.CACHE_NAME, key="'{getPrimaryJob}' + 'principalId=' + #p0 + '|' + 'asOfDate=' + #p1")
80  	public Job getPrimaryJob(String principalId, LocalDate asOfDate);
81  	
82  	/**
83  	 * 
84  	 * @param hrPayType
85  	 * @param asOfDate
86  	 * @return
87  	 */
88      @Cacheable(value= Job.CACHE_NAME, key="'hrPayType=' + #p0 + '|' + 'asOfDate=' + #p1")
89  	public List<Job> getActiveJobsForPayType(String hrPayType, LocalDate asOfDate);
90  	
91  	/**
92  	 * Get job by the unique id
93  	 * @param hrJobId
94  	 * @return
95  	 */
96      @Cacheable(value= Job.CACHE_NAME, key="'hrJobId=' + #p0")
97  	public Job getJob(String hrJobId);
98  	
99  	/**
100 	 * Get the max jobnumber job for this principal
101 	 * @param principalId
102 	 * @return
103 	 */
104     @Cacheable(value= Job.CACHE_NAME, key="'principalId=' + #p0")
105 	public Job getMaxJob(String principalId);
106 
107     List<Job> getJobs(String userPrincipalId, String principalId, String firstName, String lastName, String jobNumber,
108                       String dept, String positionNbr, String payType,
109                       LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory);
110     
111     public int getJobCount(String principalId, Long jobNumber, String dept);
112     
113 	/**
114 	 * Get list of active jobs eligible for leave for given principal and date
115 	 * @param principalId
116 	 * @param asOfDate
117 	 * @return
118 	 */
119     public List<Job> getActiveLeaveJobs(String principalId, LocalDate asOfDate);
120     
121     /**
122 	 * Get sum of fte of given jobs
123 	 * @param jobs
124 	 * @return
125 	 */
126     public BigDecimal getFteSumForJobs(List<Job> jobs);
127     
128     /**
129      * Returns FTE for all active LM eligible jobs.
130      * @param PrincipalId
131      * @return
132      */
133     public BigDecimal getFteSumForAllActiveLeaveEligibleJobs(String PrincipalId, LocalDate asOfDate);
134     /**
135 	 * Get sum of standard hours of given jobs
136 	 * @param jobs
137 	 * @return
138 	 */
139     public BigDecimal getStandardHoursSumForJobs(List<Job> jobs);
140     
141     /**
142 	 * Get list of all active jobs eligible for leave for given principal and date range
143 	 * @param principalId
144 	 * @param asOfDate
145 	 * @return
146 	 */
147     public List<Job> getAllActiveLeaveJobs(String principalId, LocalDate asOfDate);
148     
149     public List<Job> getInactiveLeaveJobs(Long jobNumber, LocalDate endDate);
150     
151     public List<Job> getAllInActiveLeaveJobsInRange(String principalId, LocalDate endDate);
152     
153     /*
154      * Get the job entry with the max timestamp for given pricipalId
155      */
156     public Job getMaxTimestampJob(String principalId);
157     
158 	
159 	/**
160 	 * Returns all of the principal ids actively particpating in a job in the given position number
161 	 * 
162 	 * @param positionNumber
163 	 * @param asOfDate
164 	 * @return
165 	 */
166     @Cacheable(value= Job.CACHE_NAME, key="'positionNumber=' + #p0 + '|' + 'asOfDate=' + #p1")
167 	public List<String> getPrincipalIdsInPosition(String positionNbr, LocalDate asOfDate);
168     
169 }