1 package org.kuali.ole.ingest.function;
2
3 import org.kuali.ole.DataCarrierService;
4 import org.kuali.ole.OLEConstants;
5 import org.kuali.ole.service.impl.OverlayMatchingServiceImpl;
6 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
7 import org.kuali.rice.krms.framework.engine.Function;
8
9 import java.util.ArrayList;
10 import java.util.Iterator;
11 import java.util.List;
12 import java.util.Map;
13
14
15
16
17
18
19
20
21 public class VendorLineItemReferenceFunction implements Function {
22
23
24 @Override
25 public Object invoke(Object... arguments) {
26 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE);
27 String existingDocstoreField = (String)(arguments[0]);
28 String vendorLineItemReferenceNumber = (String)(arguments[1]);
29 if(vendorLineItemReferenceNumber != null){
30 try {
31 List list = new OverlayMatchingServiceImpl().getInstanceCollectionOnVendorLineItemIdentifierMatch(vendorLineItemReferenceNumber);
32 if(list.size() >= 1){
33 for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
34 Map map = (Map) iterator.next();
35 if (map.containsKey(OLEConstants.BIB_UNIQUE_ID)) {
36 map.remove(OLEConstants.BIB_UNIQUE_ID);
37 }
38 List<String> bibIdList = (List<String>) map.get(OLEConstants.BIB_IDENTIFIER);
39 map.put(OLEConstants.BIB_UNIQUE_ID,bibIdList.get(0));
40 }
41 dataCarrierService.addData(OLEConstants.BIB_INFO_LIST_FROM_SOLR_RESPONSE, list);
42 return true;
43 }
44 } catch (Exception e) {
45 e.printStackTrace();
46 }
47 }
48 return false;
49 }
50 }