View Javadoc
1   package org.kuali.ole.ncip.service.impl;
2   
3   import org.kuali.ole.OLEConstants;
4   import org.kuali.ole.module.purap.PurapParameterConstants;
5   import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
6   import org.kuali.ole.ncip.bo.OLENCIPConstants;
7   import org.kuali.ole.ncip.service.OLESIAPIHelperService;
8   import org.kuali.ole.sys.context.SpringContext;
9   import org.kuali.rice.coreservice.framework.parameter.ParameterService;
10  import org.kuali.rice.krad.service.BusinessObjectService;
11  
12  import java.util.HashMap;
13  
14  /**
15   * Created with IntelliJ IDEA.
16   * User: suryar
17   * Date: 20/9/13
18   * Time: 5:00 PM
19   * To change this template use File | Settings | File Templates.
20   */
21  public class OLESIAPIHelperServiceImpl implements OLESIAPIHelperService {
22  
23      private ParameterService parameterService;
24  
25      public HashMap<String, String> getAgencyPropertyMap(String namespaceCode, String componentCode, String parameterName, String agencyId, HashMap<String, String> agencyPropertyMap) {
26          String paramValue = getParameterService().getParameterValueAsString(namespaceCode, componentCode, parameterName);
27          String[] agencyRecordArray = paramValue.split(";");
28          String[] agencyValueArray = null;
29          HashMap<String, HashMap<String, String>> agencyRecordMap = new HashMap<String, HashMap<String, String>>();
30  
31          for (int agencyRecordCounter = 0; agencyRecordCounter < agencyRecordArray.length; agencyRecordCounter++) {
32              HashMap<String, String> agencyValueMap = new HashMap<String, String>();
33              agencyValueArray = agencyRecordArray[agencyRecordCounter].split(",");
34              agencyValueMap.put(OLENCIPConstants.OPERATOR_ID, agencyValueArray[1]);
35              agencyValueMap.put(OLENCIPConstants.ITEM_TYPE, agencyValueArray[2]);
36              agencyValueMap.put(OLENCIPConstants.ITEM_LOCATION, agencyValueArray[3]);
37              agencyValueMap.put(OLENCIPConstants.REQUEST_TYPE, agencyValueArray[4]);
38              agencyRecordMap.put(agencyValueArray[0], agencyValueMap);
39          }
40          if (agencyRecordMap.containsKey(agencyId)) {
41              HashMap<String, String> agencyValueMap = agencyRecordMap.get(agencyId);
42              agencyPropertyMap.put(OLENCIPConstants.OPERATOR_ID, agencyValueMap.get(OLENCIPConstants.OPERATOR_ID));
43              agencyPropertyMap.put(OLENCIPConstants.ITEM_TYPE, agencyValueMap.get(OLENCIPConstants.ITEM_TYPE));
44              agencyPropertyMap.put(OLENCIPConstants.ITEM_LOCATION, agencyValueMap.get(OLENCIPConstants.ITEM_LOCATION));
45              agencyPropertyMap.put(OLENCIPConstants.REQUEST_TYPE, agencyValueMap.get(OLENCIPConstants.REQUEST_TYPE));
46          }
47          return agencyPropertyMap;
48      }
49  
50      public ParameterService getParameterService() {
51          if (parameterService == null) {
52              parameterService = SpringContext.getBean(ParameterService.class);
53          }
54          return parameterService;
55      }
56  
57      public void setParameterService(ParameterService parameterService) {
58          this.parameterService = parameterService;
59      }
60  
61  }