View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.workschedule.service;
17  
18  import java.sql.Date;
19  import java.util.List;
20  
21  import org.kuali.hr.time.workschedule.WorkScheduleAssignment;
22  import org.kuali.hr.time.workschedule.dao.WorkScheduleAssignmentDao;
23  
24  public class WorkScheduleAssignmentServiceImpl implements WorkScheduleAssignmentService {
25  
26      private WorkScheduleAssignmentDao workScheduleAssignmentDao;
27  
28      @Override
29      public void saveOrUpdate(WorkScheduleAssignment wsa) {
30          workScheduleAssignmentDao.saveOrUpdate(wsa);
31      }
32  
33      @Override
34      public List<WorkScheduleAssignment> getWorkScheduleAssignments(String principalId, String department, Long workArea, Date asOfDate) {
35          List<WorkScheduleAssignment> list = null;
36          // wild-cards, 2^3 again ...
37  
38          // principal, dept, workArea
39          list = workScheduleAssignmentDao.getWorkScheduleAssignments(principalId, department, workArea, asOfDate);
40  
41          // principal, dept, -1
42          if (list.isEmpty())
43              list = workScheduleAssignmentDao.getWorkScheduleAssignments(principalId, department, -1L, asOfDate);
44  
45          // principal, *, workArea
46          if (list.isEmpty())
47              list = workScheduleAssignmentDao.getWorkScheduleAssignments(principalId, "%", workArea, asOfDate);
48  
49          // principal, *, -1
50          if (list.isEmpty())
51              list = workScheduleAssignmentDao.getWorkScheduleAssignments(principalId, "%", -1L, asOfDate);
52  
53          // *, dept, workArea
54          if (list.isEmpty())
55              list = workScheduleAssignmentDao.getWorkScheduleAssignments("%", department, workArea, asOfDate);
56  
57          // *, dept, -1
58          if (list.isEmpty())
59              list = workScheduleAssignmentDao.getWorkScheduleAssignments("%", department, -1L, asOfDate);
60  
61          // *, *, workArea
62          if (list.isEmpty())
63              list = workScheduleAssignmentDao.getWorkScheduleAssignments("%", "%", workArea, asOfDate);
64  
65          // *, *, -1
66          if (list.isEmpty())
67              list = workScheduleAssignmentDao.getWorkScheduleAssignments("%", "%", -1L, asOfDate);
68  
69          return list;
70      }
71  
72      public void setWorkScheduleAssignmentDao(WorkScheduleAssignmentDao workScheduleAssignmentDao) {
73          this.workScheduleAssignmentDao = workScheduleAssignmentDao;
74      }
75  }