1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.pm.util;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Map;
21
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.classification.ClassificationBo;
26 import org.kuali.kpme.pm.classification.qual.ClassificationQualificationBo;
27 import org.kuali.kpme.pm.service.base.PmServiceLocator;
28 import org.kuali.rice.core.api.util.ConcreteKeyValue;
29 import org.kuali.rice.core.api.util.KeyValue;
30 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
31 import org.kuali.rice.krad.uif.field.InputField;
32 import org.kuali.rice.krad.uif.view.ViewModel;
33 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
34
35 public class PositionClassQualifierKeyValueFinder extends UifKeyValuesFinderBase{
36 private static final long serialVersionUID = 1L;
37
38 @Override
39 public List<KeyValue> getKeyValues() {
40 List<KeyValue> keyValues = new ArrayList<KeyValue>();
41 for (Map.Entry entry : PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.entrySet()) {
42 keyValues.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue()));
43 }
44 return keyValues;
45 }
46
47 @Override
48 public List<KeyValue> getKeyValues(ViewModel model) {
49 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
50 List<KeyValue> options = new ArrayList<KeyValue>();
51
52 ClassificationQualificationBo aQualification = (ClassificationQualificationBo) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList");
53 if(aQualification != null) {
54 String aTypeId = aQualification.getQualificationType();
55 PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
56 if(aTypeObj != null) {
57 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_TEXT)
58 || aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) {
59 options.add(new ConcreteKeyValue(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL, PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.get(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL)));
60 } else if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_NUMBER)){
61 options = this.getKeyValues();
62 }
63 }
64
65 }
66
67 return options;
68 }
69
70
71 @Override
72 public List<KeyValue> getKeyValues(ViewModel model, InputField field){
73
74 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
75 HrBusinessObject anHrObject = (HrBusinessObject) docForm.getDocument().getNewMaintainableObject().getDataObject();
76 List<KeyValue> options = new ArrayList<KeyValue>();
77
78 if (field.getId().contains("add")) {
79
80 options = getKeyValues(model);
81 } else {
82
83 String fieldId = field.getId();
84 int line_index = fieldId.indexOf("line");
85 int index = Integer.parseInt(fieldId.substring(line_index+4));
86
87 ClassificationBo aClass = (ClassificationBo)anHrObject;
88 List<ClassificationQualificationBo> qualificationList = aClass.getQualificationList();
89 ClassificationQualificationBo aQualification = (ClassificationQualificationBo)qualificationList.get(index);
90 if(aQualification != null) {
91 String aTypeId = aQualification.getQualificationType();
92 PstnQlfrTypeContract aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
93 if(aTypeObj != null) {
94 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_TEXT)
95 || aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) {
96 options.add(new ConcreteKeyValue(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL, PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.get(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL)));
97 } else if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_NUMBER)){
98 options = this.getKeyValues();
99 }
100 }
101 }
102 }
103
104 return options;
105
106 }
107
108
109 }