View Javadoc
1   package org.kuali.ole.batch.keyvalue;
2   
3   import org.apache.commons.lang.StringUtils;
4   import org.kuali.ole.OLEConstants;
5   import org.kuali.ole.batch.bo.OLEBatchProcessProfileConstantsBo;
6   import org.kuali.ole.coa.businessobject.Account;
7   import org.kuali.ole.coa.businessobject.Chart;
8   import org.kuali.ole.coa.businessobject.ObjectCode;
9   import org.kuali.ole.coa.businessobject.Organization;
10  import org.kuali.ole.describe.bo.OleItemAvailableStatus;
11  import org.kuali.ole.describe.bo.OleLocation;
12  import org.kuali.ole.describe.bo.OleLocationLevel;
13  import org.kuali.ole.module.purap.businessobject.*;
14  import org.kuali.ole.select.businessobject.OLERequestorPatronDocument;
15  import org.kuali.ole.select.businessobject.OleRequestSourceType;
16  import org.kuali.ole.select.document.service.OleSelectDocumentService;
17  import org.kuali.ole.sys.businessobject.Building;
18  import org.kuali.ole.sys.businessobject.Room;
19  import org.kuali.ole.sys.context.SpringContext;
20  import org.kuali.ole.vnd.businessobject.*;
21  import org.kuali.rice.core.api.util.ConcreteKeyValue;
22  import org.kuali.rice.core.api.util.KeyValue;
23  import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
24  import org.kuali.rice.coreservice.api.parameter.Parameter;
25  import org.kuali.rice.coreservice.api.parameter.ParameterKey;
26  import org.kuali.rice.kim.impl.identity.principal.PrincipalBo;
27  import org.kuali.rice.krad.service.BusinessObjectService;
28  import org.kuali.rice.krad.service.KRADServiceLocator;
29  import org.kuali.rice.krad.service.KeyValuesService;
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  import org.springframework.util.CollectionUtils;
34  
35  import java.util.*;
36  
37  /**
38   * Created with IntelliJ IDEA.
39   * User: syedk
40   * Date: 6/6/14
41   * Time: 7:47 PM
42   * To change this template use File | Settings | File Templates.
43   */
44  public class OLEBatchProcessOrderImportValuesFinder extends UifKeyValuesFinderBase {
45  
46      private BusinessObjectService businessObjectService;
47      private OleSelectDocumentService oleSelectDocumentService;
48  
49      public BusinessObjectService getBusinessObjectService() {
50          if(businessObjectService==null)
51              businessObjectService = KRADServiceLocator.getBusinessObjectService();
52          return businessObjectService;
53      }
54  
55      public OleSelectDocumentService getOleSelectDocumentService() {
56          if (oleSelectDocumentService == null) {
57              oleSelectDocumentService = SpringContext.getBean(OleSelectDocumentService.class);
58          }
59          return oleSelectDocumentService;
60      }
61  
62      @Override
63      public List<KeyValue> getKeyValues(ViewModel model) {
64          List<KeyValue> keyValues = new ArrayList<KeyValue>();
65          MaintenanceDocumentForm maintenanceForm = (MaintenanceDocumentForm) model;
66          OLEBatchProcessProfileConstantsBo oleBatchProcessProfileConstantsBo = null;
67          if (!CollectionUtils.isEmpty(maintenanceForm.getNewCollectionLines())) {
68              oleBatchProcessProfileConstantsBo = (OLEBatchProcessProfileConstantsBo) maintenanceForm.getNewCollectionLines().get("document.newMaintainableObject.dataObject.oleBatchProcessProfileConstantsList");
69          }
70          if (oleBatchProcessProfileConstantsBo != null) {
71              String dataType = oleBatchProcessProfileConstantsBo.getDataType();
72              if (StringUtils.isNotBlank(dataType)) {
73                  String attributeName = oleBatchProcessProfileConstantsBo.getAttributeName();
74                  String oldAttributeName = oleBatchProcessProfileConstantsBo.getOldAttributeName();
75                  if(!StringUtils.isBlank(attributeName)){
76                      if(oldAttributeName == null || !attributeName.equalsIgnoreCase(oldAttributeName)){
77                          oleBatchProcessProfileConstantsBo.setOldAttributeName(attributeName);
78                          if (dataType.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_IMPORT)) {
79                              if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.CHART_CODE)){
80                                  List<Organization> chartCodeList = (List<Organization>) KRADServiceLocator.getBusinessObjectService().findAll(Organization.class);
81                                  if(chartCodeList != null && chartCodeList.size()>0){
82                                      Set<KeyValue> chartCodes  = new HashSet<>();
83                                      for(Organization chartCode : chartCodeList) {
84                                          chartCodes.add(new ConcreteKeyValue(chartCode.getChartOfAccountsCode(), chartCode.getChartOfAccountsCode()));
85                                      }
86                                      keyValues.addAll(chartCodes);
87                                  }
88                              }
89                              else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ITEM_CHART_CODE)){
90                                  List<Chart> itemChartCodeList = (List<Chart>) KRADServiceLocator.getBusinessObjectService().findAll(Chart.class);
91                                  for (Chart itemChartCode : itemChartCodeList) {
92                                      keyValues.add(new ConcreteKeyValue(itemChartCode.getChartOfAccountsCode(), itemChartCode.getChartOfAccountsCode()));
93                                  }
94                              }
95                              else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORG_CODE)){
96                                  List<Organization> organizationCodeList = (List<Organization>) KRADServiceLocator.getBusinessObjectService().findAll(Organization.class);
97                                  if(organizationCodeList != null && organizationCodeList.size() >0){
98                                      Set<KeyValue> orgCodes  = new HashSet<>();
99                                      for (Organization organizationCode : organizationCodeList) {
100                                         orgCodes.add(new ConcreteKeyValue(organizationCode.getOrganizationCode(), organizationCode.getOrganizationCode()));
101                                     }
102                                     keyValues.addAll(orgCodes);
103                                 }
104                             }
105                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.CONTRACT_MANAGER)){
106                                 List<ContractManager> contractManagerList = (List<ContractManager>) KRADServiceLocator.getBusinessObjectService().findAll(ContractManager.class);
107                                 for (ContractManager contractManager : contractManagerList) {
108                                     keyValues.add(new ConcreteKeyValue(contractManager.getContractManagerName(), contractManager.getContractManagerName()));
109                                 }
110                             }
111                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ORDER_TYPE)){
112                                 List<PurchaseOrderType> purchaseOrderTypeList = (List<PurchaseOrderType>) KRADServiceLocator.getBusinessObjectService().findAll(PurchaseOrderType.class);
113                                 for (PurchaseOrderType purchaseOrderType : purchaseOrderTypeList) {
114                                     keyValues.add(new ConcreteKeyValue(purchaseOrderType.getPurchaseOrderType(), purchaseOrderType.getPurchaseOrderType()));
115                                 }
116                             }
117                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.FUNDING_SOURCE)){
118                                 List<FundingSource> fundingSourceList = (List<FundingSource>) KRADServiceLocator.getBusinessObjectService().findAll(FundingSource.class);
119                                 for (FundingSource fundingSource : fundingSourceList) {
120                                     keyValues.add(new ConcreteKeyValue(fundingSource.getFundingSourceCode(), fundingSource.getFundingSourceCode()));
121                                 }
122                             }
123                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DELIVERY_CAMPUS_CODE)){
124                                 List<Building> campusList = (List<Building>) KRADServiceLocator.getBusinessObjectService().findAll(Building.class);
125                                 if(campusList != null && campusList.size() >0){
126                                     Set<KeyValue> chartCodes  = new HashSet<>();
127                                     for (Building campus : campusList) {
128                                         chartCodes.add(new ConcreteKeyValue(campus.getCampusCode(), campus.getCampusCode()));
129                                     }
130                                     keyValues.addAll(chartCodes);
131                                 }
132                             }
133                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.BUILDING_CODE)){
134                                 List<Building> buildingList = (List<Building>) KRADServiceLocator.getBusinessObjectService().findAll(Building.class);
135                                 for (Building building : buildingList) {
136                                     keyValues.add(new ConcreteKeyValue(building.getBuildingCode(), building.getBuildingCode()));
137                                 }
138                             }
139                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DELIVERY_BUILDING_ROOM_NUMBER)){
140                                 List<Room> roomList = (List<Room>) KRADServiceLocator.getBusinessObjectService().findAll(Room.class);
141                                 if (roomList!=null && roomList.size()>0) {
142                                     Set<KeyValue> roomNos = new HashSet<>();
143                                     for (Room room : roomList) {
144                                         roomNos.add(new ConcreteKeyValue(room.getBuildingRoomNumber(),room.getBuildingRoomNumber()));
145                                     }
146                                     keyValues.addAll(roomNos);
147                                 }
148                             }
149                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_CHOICE)){
150                                 List<PurchaseOrderVendorChoice> purchaseOrderVendorChoiceList = (List<PurchaseOrderVendorChoice>) KRADServiceLocator.getBusinessObjectService().findAll(PurchaseOrderVendorChoice.class);
151                                 for (PurchaseOrderVendorChoice purchaseOrderVendorChoice : purchaseOrderVendorChoiceList) {
152                                     keyValues.add(new ConcreteKeyValue(purchaseOrderVendorChoice.getPurchaseOrderVendorChoiceCode(), purchaseOrderVendorChoice.getPurchaseOrderVendorChoiceCode()));
153                                 }
154                             }
155                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.COST_SOURCE)){
156                                 List<PurchaseOrderCostSource> purchaseOrderCostSourceList = (List<PurchaseOrderCostSource>) KRADServiceLocator.getBusinessObjectService().findAll(PurchaseOrderCostSource.class);
157                                 for (PurchaseOrderCostSource purchaseOrderCostSource : purchaseOrderCostSourceList) {
158                                     keyValues.add(new ConcreteKeyValue(purchaseOrderCostSource.getPurchaseOrderCostSourceCode(), purchaseOrderCostSource.getPurchaseOrderCostSourceCode()));
159                                 }
160                             }
161                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DEFAULT_LOCATION)){
162                                 List<String> locationList = getItemLocation();
163                                 for(int locationCount = 0;locationCount < locationList.size();locationCount++) {
164                                     keyValues.add(new ConcreteKeyValue(locationList.get(locationCount),locationList.get(locationCount)));
165                                 }
166                             }
167                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)){
168                                 List<VendorDetail> vendorDetailList = (List<VendorDetail>) KRADServiceLocator.getBusinessObjectService().findAll(VendorDetail.class);
169                                 for (VendorDetail vendorDetail : vendorDetailList) {
170                                     keyValues.add(new ConcreteKeyValue(vendorDetail.getVendorHeaderGeneratedIdentifier() + "-" + vendorDetail.getVendorDetailAssignedIdentifier(), vendorDetail.getVendorHeaderGeneratedIdentifier() + "-" + vendorDetail.getVendorDetailAssignedIdentifier()));
171                                 }
172                             }
173                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_CUST_NBR)){
174                                 List<VendorCustomerNumber> vendorCustomerList = (List<VendorCustomerNumber>) KRADServiceLocator.getBusinessObjectService().findAll(VendorCustomerNumber.class);
175                                 for (VendorCustomerNumber vendorCustomer : vendorCustomerList) {
176                                     keyValues.add(new ConcreteKeyValue(vendorCustomer.getVendorCustomerNumber(), vendorCustomer.getVendorCustomerNumber()));
177                                 }
178                             }
179                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.REQUESTOR_NAME)){
180                                 List<OLERequestorPatronDocument> olePatronDocumentList = getOleSelectDocumentService().getPatronDocumentListFromWebService();
181                                 if(olePatronDocumentList != null && olePatronDocumentList.size()>0){
182                                     for(int recCount = 0;recCount < olePatronDocumentList.size();recCount++) {
183                                         keyValues.add(new ConcreteKeyValue(olePatronDocumentList.get(recCount).getLastName() + ", " +  olePatronDocumentList.get(recCount).getFirstName(),olePatronDocumentList.get(recCount).getLastName() + ", " +  olePatronDocumentList.get(recCount).getFirstName()));
184                                     }
185                                 }
186                             }
187                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ITEM_STATUS)){
188                                 List<KeyValue> itemStatusList = getItemStatus();
189                                 for(int itemStatusCount = 0; itemStatusCount < itemStatusList.size(); itemStatusCount++){
190                                     keyValues.add(new ConcreteKeyValue(itemStatusList.get(itemStatusCount).getKey(),itemStatusList.get(itemStatusCount).getKey()));
191                                 }
192                             }
193                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.DISCOUNT_TYPE)){
194                                 keyValues.add(new ConcreteKeyValue("%", "%"));
195                                 keyValues.add(new ConcreteKeyValue("#", "#"));
196                             }
197                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)){
198                                 List<Account> accountNumberList = (List<Account>) KRADServiceLocator.getBusinessObjectService().findAll(Account.class);
199                                 for (Account account : accountNumberList) {
200                                     keyValues.add(new ConcreteKeyValue(account.getAccountNumber(), account.getAccountNumber()));
201                                 }
202                             }
203                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.OBJECT_CODE)){
204                                 List<ObjectCode> objectCodeList = (List<ObjectCode>) KRADServiceLocator.getBusinessObjectService().findAll(ObjectCode.class);
205                                 if(objectCodeList != null && objectCodeList.size() >0){
206                                     Set<KeyValue> objectCodes  = new HashSet<>();
207                                     for (ObjectCode objectCode : objectCodeList) {
208                                         objectCodes.add(new ConcreteKeyValue(objectCode.getFinancialObjectCode(), objectCode.getFinancialObjectCode()));
209                                     }
210                                     keyValues.addAll(objectCodes);
211                                 }
212                             }
213                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.REQUEST_SRC)){
214                                 List<OleRequestSourceType> requestSourceTypeList = (List<OleRequestSourceType>) KRADServiceLocator.getBusinessObjectService().findAll(OleRequestSourceType.class);
215                                 for (OleRequestSourceType requestSourceType : requestSourceTypeList) {
216                                     keyValues.add(new ConcreteKeyValue(requestSourceType.getRequestSourceType(),requestSourceType.getRequestSourceType()));
217                                 }
218                             }
219                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ASSIGN_TO_USER)){
220                                 List<PrincipalBo> assignedUserList = (List<PrincipalBo>) KRADServiceLocator.getBusinessObjectService().findAll(PrincipalBo.class);
221                                 for (PrincipalBo assignedUser : assignedUserList) {
222                                     keyValues.add(new ConcreteKeyValue(assignedUser.getPrincipalName(), assignedUser.getPrincipalName()));
223                                 }
224                             }
225                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.METHOD_OF_PO_TRANSMISSION)){
226                                 KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
227                                 List<PurchaseOrderTransmissionMethod> transmissionMethodList = (List<PurchaseOrderTransmissionMethod>) boService.findAll(PurchaseOrderTransmissionMethod.class);
228                                 for (PurchaseOrderTransmissionMethod transmissionMethod : transmissionMethodList) {
229                                     if(transmissionMethod.isDisplayToUser()){
230                                         keyValues.add(new ConcreteKeyValue(transmissionMethod.getPurchaseOrderTransmissionMethodDescription(), transmissionMethod.getPurchaseOrderTransmissionMethodDescription()));
231                                     }
232                                 }
233                             }
234                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.RECURRING_PAYMENT_TYP)){
235                                 KeyValuesService boService = SpringContext.getBean(KeyValuesService.class);
236                                 List<RecurringPaymentType> recurringPaymentTypeList = (List<RecurringPaymentType>) boService.findAll(RecurringPaymentType.class);
237                                 for (RecurringPaymentType recurringPaymentTypeMethod : recurringPaymentTypeList) {
238                                     if(recurringPaymentTypeMethod.isActive()){
239                                         keyValues.add(new ConcreteKeyValue(recurringPaymentTypeMethod.getRecurringPaymentTypeCode(), recurringPaymentTypeMethod.getRecurringPaymentTypeDescription()));
240                                     }
241                                 }
242                             }
243                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.RECEIVING_REQUIRED) ||
244                                     attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.USE_TAX_INDICATOR) ||
245                                     attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.PREQ_POSITIVE_APPROVAL_REQ) ||
246                                     attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.PO_CONFIRMATION_INDICATOR) ||
247                                     attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ROUTE_TO_REQUESTOR)){
248                                 keyValues.add(new ConcreteKeyValue(OLEConstants.OLEBatchProcess.TRUE,OLEConstants.OLEBatchProcess.TRUE));
249                                 keyValues.add(new ConcreteKeyValue(OLEConstants.OLEBatchProcess.FALSE,OLEConstants.OLEBatchProcess.FALSE));
250                             }
251                         }
252                         else if (dataType.equalsIgnoreCase(OLEConstants.OLEBatchProcess.INVOICE_IMPORT)) {
253                             if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.ACCOUNT_NUMBER)){
254                                 List<Account> accountNumberList = (List<Account>) KRADServiceLocator.getBusinessObjectService().findAll(Account.class);
255                                 for (Account account : accountNumberList) {
256                                     keyValues.add(new ConcreteKeyValue(account.getAccountNumber(), account.getAccountNumber()));
257                                 }
258                             }
259                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.OBJECT_CODE)){
260                                 List<ObjectCode> objectCodeList = (List<ObjectCode>) KRADServiceLocator.getBusinessObjectService().findAll(ObjectCode.class);
261                                 if(objectCodeList != null && objectCodeList.size() >0){
262                                     Set<KeyValue> objectCodes  = new HashSet<>();
263                                     for (ObjectCode objectCode : objectCodeList) {
264                                         objectCodes.add(new ConcreteKeyValue(objectCode.getFinancialObjectCode(), objectCode.getFinancialObjectCode()));
265                                     }
266                                     keyValues.addAll(objectCodes);
267                                 }
268                             }
269                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.VENDOR_NUMBER)){
270                                 List<VendorDetail> vendorDetailList = (List<VendorDetail>) KRADServiceLocator.getBusinessObjectService().findAll(VendorDetail.class);
271                                 for (VendorDetail vendorDetail : vendorDetailList) {
272                                     keyValues.add(new ConcreteKeyValue(vendorDetail.getVendorHeaderGeneratedIdentifier() + "-" + vendorDetail.getVendorDetailAssignedIdentifier(), vendorDetail.getVendorHeaderGeneratedIdentifier() + "-" + vendorDetail.getVendorDetailAssignedIdentifier()));
273                                 }
274                             }
275                             else if(attributeName.equalsIgnoreCase(OLEConstants.OLEBatchProcess.CURRENCY_TYPE)){
276                                 List<OleCurrencyType> currencyTypeList = (List<OleCurrencyType>) KRADServiceLocator.getBusinessObjectService().findAll(OleCurrencyType.class);
277                                 for (OleCurrencyType currencyType : currencyTypeList) {
278                                     keyValues.add(new ConcreteKeyValue(currencyType.getCurrencyType(), currencyType.getCurrencyType()));
279                                 }
280                             }
281                         }
282                     }
283                 }
284             }
285         Collections.sort(keyValues, new Comparator<KeyValue>() {
286             public int compare(KeyValue keyValue1, KeyValue keyValue2) {
287                 return keyValue1.getValue().compareTo(keyValue2.getValue());
288 
289             }
290         });
291     }
292         return keyValues;
293 }
294 
295     public List<String> getItemLocation() {
296         List<String> locationList = new ArrayList<String>();
297         List<KeyValue> options = new ArrayList<KeyValue>();
298         Map parentCriteria1 = new HashMap();
299         parentCriteria1.put(OLEConstants.OLEBatchProcess.LEVEL_CODE, OLEConstants.LOC_LEVEL_SHELVING);
300         List<OleLocationLevel> oleLocationLevel = (List<OleLocationLevel>) getBusinessObjectService().findMatching(OleLocationLevel.class, parentCriteria1);
301         String shelvingId = oleLocationLevel.get(0).getLevelId();
302         Map parentCriteria = new HashMap();
303         parentCriteria.put(OLEConstants.LEVEL_ID, shelvingId);
304         Collection<OleLocation> oleLocationCollection = getBusinessObjectService().findMatching(OleLocation.class, parentCriteria);
305         for (OleLocation oleLocation : oleLocationCollection) {
306             String locationName = oleLocation.getLocationName();
307             String levelCode = oleLocation.getLocationCode();
308             boolean parentId = oleLocation.getParentLocationId() != null ? true : false;
309             while (parentId) {
310                 Map criteriaMap = new HashMap();
311                 criteriaMap.put(OLEConstants.LOCATION_ID, oleLocation.getParentLocationId());
312                 OleLocation location = getBusinessObjectService().findByPrimaryKey(OleLocation.class,
313                         criteriaMap);
314                 if (locationName != null) {
315                     locationName = location.getLocationName() + OLEConstants.SLASH + locationName;
316                 }
317                 if (levelCode != null) {
318                     levelCode = location.getLocationCode() + OLEConstants.SLASH + levelCode;
319                 }
320                 parentId = location.getParentLocationId() != null ? true : false;
321                 oleLocation = location;
322             }
323             options.add(new ConcreteKeyValue(levelCode, levelCode));
324         }
325         Map<String, String> map = new HashMap<String, String>();
326         for (KeyValue option : options) {
327             map.put(option.getKey(), option.getValue());
328         }
329         Map<String, Object> map1 = sortByLocation(map);
330         for (Map.Entry<String, Object> entry : map1.entrySet()) {
331             locationList.add((String) entry.getValue());
332         }
333         return locationList;
334     }
335     private Map<String, Object> sortByLocation(Map<String, String> parentCriteria) {
336         Map<String, Object> map = new LinkedHashMap<String, Object>();
337         List<String> keyList = new ArrayList<String>(parentCriteria.keySet());
338         List<String> valueList = new ArrayList<String>(parentCriteria.values());
339         Set<String> sortedSet = new TreeSet<String>(valueList);
340         Object[] sortedArray = sortedSet.toArray();
341         int size = sortedArray.length;
342         for (int i = 0; i < size; i++) {
343             map.put(keyList.get(valueList.indexOf(sortedArray[i])), sortedArray[i]);
344         }
345         return map;
346     }
347 
348     public List<KeyValue> getItemStatus() {
349 
350         List<KeyValue> options = new ArrayList<KeyValue>();
351         Collection<OleItemAvailableStatus> oleItemAvailableStatuses = KRADServiceLocator.getBusinessObjectService().findAll(OleItemAvailableStatus.class);
352         String excludeItemStatus = getParameter(OLEConstants.EXCLUDE_ITEM_STATUS);
353         Map<String,String> map = new HashMap<>();
354         if(excludeItemStatus!=null && !excludeItemStatus.isEmpty()){
355             String[] itemStatusList = excludeItemStatus.split(",");
356             for(String itemStatus : itemStatusList){
357                 map.put(itemStatus,itemStatus);
358             }
359         }
360         for (OleItemAvailableStatus type : oleItemAvailableStatuses) {
361             if (type.isActive() && !map.containsKey(type.getItemAvailableStatusCode())) {
362                 options.add(new ConcreteKeyValue(type.getItemAvailableStatusCode(), type.getItemAvailableStatusName()));
363             }
364         }
365         return options;
366     }
367 
368     public String getParameter(String name){
369         ParameterKey parameterKey = ParameterKey.create(OLEConstants.APPL_ID, OLEConstants.SELECT_NMSPC, OLEConstants.SELECT_CMPNT,name);
370         Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
371         return parameter!=null?parameter.getValue():null;
372     }
373 }