View Javadoc
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.ingest.pojo.ProfileAttributeBo;
7   import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
8   import org.kuali.rice.krms.api.engine.ExecutionEnvironment;
9   import org.kuali.rice.krms.framework.engine.Action;
10  
11  import java.util.List;
12  
13  /**
14   * CreateBibAction is the action class for BatchIngest(Staff upload screen) which creates a bibliographic
15   * record in Docstore.
16   */
17  public class OverlayAction implements Action {
18      private static final Logger LOG = Logger.getLogger(OverlayAction.class);
19      private UpdateBibExcludingGPFieldAction updateBibExcludingGPFieldAction;
20      private UpdateBibIncludingGPFieldAction updateBibIncludingGPFieldAction;
21      private DataCarrierService dataCarrierService;
22  
23      /**
24       *  This method takes the initial request when creating the BibAction.
25       * @param executionEnvironment
26       */
27      @Override
28      public void execute(ExecutionEnvironment executionEnvironment) {
29          dataCarrierService = getDataCarrierService();
30          List<ProfileAttributeBo> profileAttributesList = (List<ProfileAttributeBo>) dataCarrierService.getData(OLEConstants.PROFILE_ATTRIBUTE_LIST);
31  
32          String overlayOption = new String();
33          try{
34              for(ProfileAttributeBo profileAttributeBo : profileAttributesList){
35                  if(profileAttributeBo.getAttributeName().equals(OLEConstants.HIGHLEVEL_OVERLAY_OPTION)){
36                      overlayOption = profileAttributeBo.getAttributeValue();
37                  }
38              }
39              if(LOG.isDebugEnabled()){
40                  LOG.debug("overlayOption------------->"+overlayOption);
41              }
42              if(overlayOption.equals(OLEConstants.OVERLAY_OPTION_DONT_IGNORE_GPF)){
43                  getUpdateBibExcludingGPFieldAction().execute(executionEnvironment);
44              }else if(overlayOption.equals(OLEConstants.OVERLAY_OPTION_IGNORE_GPF)){
45                  getUpdateBibIncludingGPFieldAction().execute(executionEnvironment);
46              }
47              else {
48                  getUpdateBibExcludingGPFieldAction().execute(executionEnvironment);
49              }
50              executionEnvironment.getEngineResults().setAttribute(OLEConstants.OVERLAY, true);
51          }catch (Exception e){
52              executionEnvironment.getEngineResults().setAttribute(OLEConstants.OVERLAY, null);
53          }
54      }
55  
56      /**
57       *    Gets the updateBibExcludingGPFieldAction attribute.
58       * @return  updateBibExcludingGPFieldAction.
59       */
60      public UpdateBibExcludingGPFieldAction getUpdateBibExcludingGPFieldAction() {
61          if (null == updateBibExcludingGPFieldAction) {
62              updateBibExcludingGPFieldAction = new UpdateBibExcludingGPFieldAction();
63          }
64          return updateBibExcludingGPFieldAction;
65      }
66  
67      /**
68       *    Gets the updateBibExcludingGPFieldAction attribute.
69       * @return  updateBibExcludingGPFieldAction.
70       */
71      public UpdateBibIncludingGPFieldAction getUpdateBibIncludingGPFieldAction() {
72          if (null == updateBibIncludingGPFieldAction) {
73              updateBibIncludingGPFieldAction = new UpdateBibIncludingGPFieldAction();
74          }
75          return updateBibIncludingGPFieldAction;
76      }
77  
78      /**
79       *  Gets the dataCarrierService attribute.
80       * @return  Returns dataCarrierService.
81       */
82      protected DataCarrierService getDataCarrierService() {
83          return GlobalResourceLoader.getService(OLEConstants.DATA_CARRIER_SERVICE);
84      }
85      /**
86       *   This method simulate the executionEnvironment.
87       * @param executionEnvironment
88       */
89  
90      @Override
91      public void executeSimulation(ExecutionEnvironment executionEnvironment) {
92          execute(executionEnvironment);
93      }
94  
95  }