1 package org.kuali.ole.select.businessobject.options;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.ole.describe.bo.OleItemAvailableStatus;
5 import org.kuali.rice.core.api.util.ConcreteKeyValue;
6 import org.kuali.rice.core.api.util.KeyValue;
7 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
8 import org.kuali.rice.coreservice.api.parameter.Parameter;
9 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
10 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
11 import org.kuali.rice.krad.service.KRADServiceLocator;
12
13 import java.util.*;
14
15
16
17
18 public class OleItemStatusKeyValuesFinder extends KeyValuesBase {
19
20
21
22
23
24
25 @Override
26 public List<KeyValue> getKeyValues() {
27
28 List<KeyValue> options = new ArrayList<KeyValue>();
29 Collection<OleItemAvailableStatus> oleItemAvailableStatuses = KRADServiceLocator.getBusinessObjectService().findAll(OleItemAvailableStatus.class);
30 options.add(new ConcreteKeyValue("", ""));
31 String excludeItemStatus = getParameter(OLEConstants.EXCLUDE_ITEM_STATUS);
32 Map<String,String> map = new HashMap<>();
33 if(excludeItemStatus!=null && !excludeItemStatus.isEmpty()){
34 String[] itemStatusList = excludeItemStatus.split(",");
35 for(String itemStatus : itemStatusList){
36 map.put(itemStatus,itemStatus);
37 }
38 }
39 for (OleItemAvailableStatus type : oleItemAvailableStatuses) {
40 if (type.isActive() && !map.containsKey(type.getItemAvailableStatusCode())) {
41 options.add(new ConcreteKeyValue(type.getItemAvailableStatusCode(), type.getItemAvailableStatusName()));
42 }
43 }
44 return options;
45 }
46
47 public String getParameter(String name){
48 ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID, OLEConstants.SELECT_NMSPC, OLEConstants.SELECT_CMPNT,name);
49 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
50 return parameter!=null?parameter.getValue():null;
51 }
52 }