1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.ld.businessobject.inquiry;
20
21 import java.text.SimpleDateFormat;
22 import java.util.ArrayList;
23 import java.util.Calendar;
24 import java.util.Date;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.kuali.kfs.integration.ld.businessobject.inquiry.AbstractPositionDataDetailsInquirableImpl;
29 import org.kuali.kfs.module.ld.LaborConstants;
30 import org.kuali.kfs.module.ld.LaborPropertyConstants;
31 import org.kuali.kfs.module.ld.businessobject.PositionData;
32 import org.kuali.rice.krad.bo.BusinessObject;
33
34
35
36
37
38
39
40 public class PositionDataDetailsInquirableImpl extends AbstractPositionDataDetailsInquirableImpl {
41
42 @Override
43 protected String getPositionNumberKeyValue() {
44 return LaborConstants.getDashPositionNumber();
45 }
46
47 @Override
48 protected String getFinancialBalanceTypeCodeKeyValue() {
49 return LaborConstants.BalanceInquiries.BALANCE_TYPE_AC_AND_A21;
50 }
51
52 @Override
53 protected String getEffectiveDateKey() {
54 return LaborPropertyConstants.EFFECTIVE_DATE;
55 }
56
57 @Override
58 protected Class getInquiryBusinessObjectClass(String attributeName) {
59 return PositionData.class;
60 }
61
62 @Override
63 public BusinessObject getBusinessObject(Map fieldValues) {
64 List<PositionData> positionList = new ArrayList<PositionData>(getLookupService().findCollectionBySearch(PositionData.class, fieldValues));
65 SimpleDateFormat formatter = new SimpleDateFormat("MMddyyyy");
66
67 Date today = Calendar.getInstance().getTime();
68 Date maxEffectiveDate = null;
69
70 PositionData lookupValue = null;
71 for (PositionData position : positionList) {
72 Date effectiveDate = position.getEffectiveDate();
73 if (effectiveDate.compareTo(today) <= 0 && (maxEffectiveDate == null || effectiveDate.compareTo(maxEffectiveDate) > 0)) {
74 maxEffectiveDate = effectiveDate;
75 lookupValue = position;
76 }
77 }
78
79 return lookupValue;
80 }
81
82 }