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.describe.service.DiscoveryHelperService;
6 import org.kuali.ole.ingest.util.OCLCUtil;
7 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
8 import org.kuali.rice.krms.framework.engine.Function;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13
14
15
16
17
18
19
20 public class OCLCFunction implements Function {
21
22 private DiscoveryHelperService discoveryHelperService;
23 @Override
24 public Object invoke(Object... arguments) {
25 DataCarrierService dataCarrierService = GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE);
26 String existingDocstoreField = (String)(arguments[0]);
27 String oclc = (String)(arguments[1]);
28 if(oclc != null){
29 String normalizedOclc = null;
30 try{
31 normalizedOclc = new OCLCUtil().normalizedOclc(oclc);
32 }
33 catch (Exception e) {
34 e.printStackTrace();
35 }
36 List list = getDiscoveryHelperService().getResponseFromSOLR(existingDocstoreField, normalizedOclc);
37 if(list.size() >= 1){
38 dataCarrierService.addData(OLEConstants.BIB_INFO_LIST_FROM_SOLR_RESPONSE, list);
39 return true;
40 }
41 }
42 return false;
43 }
44
45
46
47
48
49 public DiscoveryHelperService getDiscoveryHelperService() {
50 if (null == discoveryHelperService) {
51 discoveryHelperService = new DiscoveryHelperService();
52 }
53 return discoveryHelperService;
54 }
55
56
57
58
59
60 public void setDiscoveryHelperService(DiscoveryHelperService discoveryHelperService) {
61 this.discoveryHelperService = discoveryHelperService;
62 }
63
64 }