1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.position;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.kpme.core.bo.HrBusinessObject;
23 import org.kuali.kpme.pm.PMConstants;
24 import org.kuali.kpme.pm.api.pstnqlfrtype.PstnQlfrTypeContract;
25 import org.kuali.kpme.pm.service.base.PmServiceLocator;
26 import org.kuali.rice.core.api.util.ConcreteKeyValue;
27 import org.kuali.rice.core.api.util.KeyValue;
28 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
29 import org.kuali.rice.krad.uif.field.InputField;
30 import org.kuali.rice.krad.uif.view.ViewModel;
31 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
32
33 public class PositionQualifierValueKeyValueFinder extends UifKeyValuesFinderBase {
34
35 private static final long serialVersionUID = 1L;
36
37 @Override
38 public List<KeyValue> getKeyValues(ViewModel model) {
39 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
40 List<KeyValue> options = new ArrayList<KeyValue>();
41
42 PositionQualificationBo aQualification = (PositionQualificationBo) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList");
43 if(aQualification != null) {
44 String aTypeId = aQualification.getQualificationType();
45 PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
46 if(aTypeObj != null) {
47 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)){
48 String[] aCol = aTypeObj.getSelectValues().split(",");
49 for(String aString : aCol){
50 aString = StringUtils.strip(aString);
51 options.add(new ConcreteKeyValue(aString, aString));
52 }
53 } else{
54 return new ArrayList<KeyValue>();
55 }
56 }
57 }
58 return options;
59 }
60
61
62 @Override
63 public List<KeyValue> getKeyValues(ViewModel model, InputField field){
64
65 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
66 HrBusinessObject anHrObject = (HrBusinessObject) docForm.getDocument().getNewMaintainableObject().getDataObject();
67 List<KeyValue> options = new ArrayList<KeyValue>();
68
69 if (field.getId().contains("add")) {
70
71 options = getKeyValues(model);
72 } else {
73
74 String fieldId = field.getId();
75 int line_index = fieldId.indexOf("line");
76 int index = Integer.parseInt(fieldId.substring(line_index+4));
77
78 PositionBo aPosition = (PositionBo)anHrObject;
79 List<PositionQualificationBo> qualificationList = aPosition.getQualificationList();
80 PositionQualificationBo posQualification = (PositionQualificationBo)qualificationList.get(index);
81 String aTypeId = posQualification.getQualificationType();
82
83 PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);;
84 if(aTypeObj != null) {
85 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)){
86 String[] aCol = aTypeObj.getSelectValues().split(",");
87 for(String aString : aCol){
88 aString = StringUtils.strip(aString);
89 options.add(new ConcreteKeyValue(aString, aString));
90 }
91 } else{
92 return new ArrayList<KeyValue>();
93 }
94 }
95 }
96
97 return options;
98
99 }
100
101 }