1 package org.kuali.ole.ingest.action;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.DataCarrierService;
5 import org.kuali.ole.OLEConstants;
6 import org.kuali.ole.describe.service.MockDiscoveryHelperService;
7 import org.kuali.ole.describe.service.MockDocstoreHelperService;
8 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
9 import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
10 import org.kuali.rice.krms.framework.engine.Action;
11
12 /**
13 * Created with IntelliJ IDEA.
14 * User: ?
15 * Date: 12/18/12
16 * Time: 5:44 PM
17 * To change this template use File | Settings | File Templates.
18 */
19 public class MockUpdateItemAction implements Action {
20
21 private MockDocstoreHelperService docstoreHelperService;
22 private MockDiscoveryHelperService discoveryHelperService;
23
24 private static final Logger LOG = Logger.getLogger(MockUpdateItemAction.class);
25
26 /**
27 * This method takes the initial request when updating the itemAction.
28 * @param executionEnvironment
29 */
30 @Override
31 public void execute(ExecutionEnvironment executionEnvironment) {
32
33 LOG.info(" Called UpdateItemAction ---------------> ");
34
35 //TODO: Use strings from OleConstants.java; if not present add the string below to the class.
36 /*DataCarrierService dataCarrierService = getDataCarrierService();
37 BibliographicRecord bibliographicRecord = (BibliographicRecord) dataCarrierService.getData(OLEConstants.REQUEST_BIB_RECORD);
38 List bibInfoList = (List) dataCarrierService.getData(OLEConstants.BIB_INFO_LIST_FROM_SOLR_RESPONSE);
39 String bibUUID = null;
40 for (Iterator iterator = bibInfoList.iterator(); iterator.hasNext(); ) {
41 Map map = (Map) iterator.next();
42 if (map.containsKey(OLEConstants.BIB_UNIQUE_ID)) {
43 bibUUID = (String) map.get(OLEConstants.BIB_UNIQUE_ID);
44 break;
45 }
46 }
47
48 List responseFromSOLR = getDiscoveryHelperService().getResponseFromSOLR("DocType=bibliographic and id", bibUUID);
49 String instanceUUID = null;
50 for (Iterator iterator = responseFromSOLR.iterator(); iterator.hasNext(); ) {
51 Map map = (Map) iterator.next();
52 if (map.containsKey(OLEConstants.BIB_INSTANCE_ID)) {
53 List list =(List)map.get(OLEConstants.BIB_INSTANCE_ID);
54 instanceUUID =list !=null & list.size()>0 ?(String) list.get(0):null;
55 break;
56 }
57 }
58
59 List responseFromSOLR1 = getDiscoveryHelperService().getResponseFromSOLR("DocType=instance and id", instanceUUID);
60 String itemUUID = null;
61 for (Iterator iterator = responseFromSOLR1.iterator(); iterator.hasNext(); ) {
62 Map map = (Map) iterator.next();
63 if (map.containsKey(OLEConstants.BIB_ITEM_ID)) {
64 List list = (List)map.get(OLEConstants.BIB_ITEM_ID);
65 itemUUID = list !=null & list.size()>0 ?(String) list.get(0):null;
66 break;
67 }
68 }
69
70 getDocstoreHelperService().updateItem(bibliographicRecord, itemUUID);
71 executionEnvironment.getEngineResults().setAttribute(OLEConstants.UPDATE_ITEM_FLAG, true);*/
72 }
73
74 /**
75 * Gets the dataCarrierService attribute.
76 * @return Returns dataCarrierService.
77 */
78 protected DataCarrierService getDataCarrierService() {
79 return GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE);
80 }
81
82 /**
83 * This method simulate the executionEnvironment.
84 * @param executionEnvironment
85 */
86 @Override
87 public void executeSimulation(ExecutionEnvironment executionEnvironment) {
88 execute(executionEnvironment);
89 }
90
91 public MockDocstoreHelperService getDocstoreHelperService() {
92 return docstoreHelperService;
93 }
94
95 public void setDocstoreHelperService(MockDocstoreHelperService docstoreHelperService) {
96 this.docstoreHelperService = docstoreHelperService;
97 }
98
99 public MockDiscoveryHelperService getDiscoveryHelperService() {
100 return discoveryHelperService;
101 }
102
103 public void setDiscoveryHelperService(MockDiscoveryHelperService discoveryHelperService) {
104 this.discoveryHelperService = discoveryHelperService;
105 }
106 }