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
21 import org.apache.commons.collections.CollectionUtils;
22 import org.apache.commons.lang.StringUtils;
23 import org.joda.time.LocalDate;
24 import org.kuali.kpme.core.bo.HrBusinessObject;
25 import org.kuali.kpme.pm.flag.Flag;
26 import org.kuali.kpme.pm.positionflag.PositionFlag;
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.view.ViewModel;
32 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
33
34 public class FlagNameKeyValueFinder extends UifKeyValuesFinderBase {
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 HrBusinessObject anHrObject = (HrBusinessObject) docForm.getDocument().getNewMaintainableObject().getDataObject();
42 LocalDate aDate = anHrObject.getEffectiveLocalDate() != null ? anHrObject.getEffectiveLocalDate() : null;
43
44 Flag aFlagObj = (Flag) docForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.flagList");
45 String category = null;
46 if(aFlagObj != null && StringUtils.isNotEmpty(aFlagObj.getCategory())) {
47 category = aFlagObj.getCategory();
48 }
49 List<PositionFlag> flagList = PmServiceLocator.getPositionFlagService().getAllActivePositionFlagsWithCategory(category, aDate);
50 if(CollectionUtils.isNotEmpty(flagList)) {
51 for(PositionFlag aFlag : flagList) {
52 options.add(new ConcreteKeyValue((String) aFlag.getPositionFlagName(), (String) aFlag.getPositionFlagName()));
53 }
54 }
55 return options;
56 }
57
58 }