1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.impl.repository; |
17 | |
|
18 | |
import org.apache.cxf.common.util.StringUtils; |
19 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
20 | |
import org.kuali.rice.core.api.util.KeyValue; |
21 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
22 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
23 | |
import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; |
24 | |
import org.kuali.rice.krad.uif.view.ViewModel; |
25 | |
import org.kuali.rice.krad.web.form.MaintenanceForm; |
26 | |
import org.kuali.rice.krad.web.form.UifFormBase; |
27 | |
import org.kuali.rice.krms.impl.ui.AgendaEditor; |
28 | |
|
29 | |
import java.util.ArrayList; |
30 | |
import java.util.Collection; |
31 | |
import java.util.Collections; |
32 | |
import java.util.List; |
33 | |
import java.util.Map; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class AgendaTypeValuesFinder extends UifKeyValuesFinderBase { |
39 | |
|
40 | |
private boolean blankOption; |
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
public boolean isBlankOption() { |
46 | 0 | return this.blankOption; |
47 | |
} |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
public void setBlankOption(boolean blankOption) { |
53 | 0 | this.blankOption = blankOption; |
54 | 0 | } |
55 | |
|
56 | |
@Override |
57 | |
public List<KeyValue> getKeyValues(ViewModel model) { |
58 | 0 | List<KeyValue> keyValues = new ArrayList<KeyValue>(); |
59 | |
|
60 | 0 | MaintenanceForm maintenanceForm = (MaintenanceForm) model; |
61 | 0 | AgendaEditor agendaEditor = ((AgendaEditor) maintenanceForm.getDocument().getNewMaintainableObject().getDataObject()); |
62 | |
|
63 | |
|
64 | 0 | if (agendaEditor.getAgenda() != null && !StringUtils.isEmpty(agendaEditor.getAgenda().getContextId())) { |
65 | |
|
66 | |
|
67 | |
|
68 | 0 | String contextId = agendaEditor.getAgenda().getContextId(); |
69 | |
|
70 | 0 | if(blankOption){ |
71 | 0 | keyValues.add(new ConcreteKeyValue("", "")); |
72 | |
} |
73 | |
|
74 | 0 | Map<String, String> criteria = Collections.singletonMap("contextId", contextId); |
75 | 0 | Collection<ContextValidAgendaBo> contextValidAgendas = |
76 | |
KRADServiceLocator.getBusinessObjectService().findMatchingOrderBy( |
77 | |
ContextValidAgendaBo.class, criteria, "agendaType.name", true |
78 | |
); |
79 | |
|
80 | 0 | for (ContextValidAgendaBo contextValidAgenda : contextValidAgendas) { |
81 | 0 | keyValues.add(new ConcreteKeyValue(contextValidAgenda.getAgendaType().getId(), contextValidAgenda.getAgendaType().getName())); |
82 | |
} |
83 | |
} |
84 | |
|
85 | 0 | return keyValues; |
86 | |
} |
87 | |
} |