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.pm.PMConstants;
23 import org.kuali.kpme.pm.classification.qual.ClassificationQualification;
24 import org.kuali.kpme.pm.pstnqlfrtype.PstnQlfrType;
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.view.ViewModel;
30 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
31
32 public class PositionClassQualifierKeyValueFinder extends UifKeyValuesFinderBase{
33 private static final long serialVersionUID = 1L;
34
35 @Override
36 public List<KeyValue> getKeyValues() {
37 List<KeyValue> keyValues = new ArrayList<KeyValue>();
38 for (Map.Entry entry : PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.entrySet()) {
39 keyValues.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue()));
40 }
41 return keyValues;
42 }
43
44 @Override
45 public List<KeyValue> getKeyValues(ViewModel model) {
46 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
47 List<KeyValue> options = new ArrayList<KeyValue>();
48
49 ClassificationQualification aQualification = (ClassificationQualification) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.qualificationList");
50 if(aQualification != null) {
51 String aTypeId = aQualification.getQualificationType();
52 PstnQlfrType aTypeObj = PmServiceLocator.getPstnQlfrTypeService().getPstnQlfrTypeById(aTypeId);
53 if(aTypeObj != null) {
54 if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_TEXT)
55 || aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_SELECT)) {
56 options.add(new ConcreteKeyValue(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL, PMConstants.PSTN_CLSS_QLFR_VALUE_MAP.get(PMConstants.PSTN_CLSS_QLFR_VALUE.EQUAL)));
57 } else if(aTypeObj.getTypeValue().equals(PMConstants.PSTN_QLFR_NUMBER)){
58 options = this.getKeyValues();
59 }
60 }
61
62 }
63
64 return options;
65 }
66 }