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.rice.core.api.util.ConcreteKeyValue;
25 import org.kuali.rice.core.api.util.KeyValue;
26 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
27 import org.kuali.rice.krad.uif.view.ViewModel;
28 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
29
30 public class StatusKeyValueFinder extends UifKeyValuesFinderBase {
31
32 private static final long serialVersionUID = 1L;
33
34 @Override
35 public List<KeyValue> getKeyValues() {
36 List<KeyValue> keyValues = new ArrayList<KeyValue>();
37 for (Map.Entry entry : PMConstants.PSTN_STATUS_MAP.entrySet()) {
38 keyValues.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue()));
39 }
40 return keyValues;
41 }
42
43 @Override
44 public List<KeyValue> getKeyValues(ViewModel model) {
45 List<KeyValue> options = new ArrayList<KeyValue>();
46 if (model instanceof MaintenanceDocumentForm) {
47 MaintenanceDocumentForm docForm = (MaintenanceDocumentForm) model;
48 HrBusinessObject anHrObject = (HrBusinessObject) docForm.getDocument().getNewMaintainableObject().getDataObject();
49
50 if(anHrObject.getEffectiveDate() != null) {
51 options = this.getKeyValues();
52 } else {
53 options.add(new ConcreteKeyValue(PMConstants.PSTN_STATUS.NEW, PMConstants.PSTN_STATUS.NEW));
54 }
55 } else {
56 for (Map.Entry entry : PMConstants.PSTN_STATUS_MAP.entrySet()) {
57 options.add(new ConcreteKeyValue((String) entry.getKey(), (String) entry.getValue()));
58 }
59 }
60 return options;
61 }
62 }