1 package org.kuali.ole;
2
3
4 import org.kuali.ole.sys.OLEConstants;
5 import org.kuali.ole.workflow.WorfklowFileHandler;
6 import org.kuali.rice.coreservice.api.parameter.Parameter;
7 import org.kuali.rice.coreservice.api.parameter.ParameterType;
8 import org.kuali.rice.coreservice.framework.parameter.ParameterService;
9
10
11
12
13 public class LoadDefaultWorkflowsBean {
14 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LoadDefaultWorkflowsBean.class);
15 protected static final String LOAD_DEFAULT_WORKFLOW_IND = "LOAD_DEFAULT_WORKFLOW_IND";
16 protected ParameterService parameterService;
17 protected WorfklowFileHandler workflowFileHandler;
18
19 public void unpackWorkflows( boolean forceLoad ) {
20 if ( forceLoad || parameterService.getParameterValueAsBoolean(OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND, Boolean.TRUE) ) {
21
22 LOG.info("Starting Load of Default Workflows");
23 workflowFileHandler.execute();
24 LOG.info("Completed Load of Default Workflows");
25
26 Parameter existingParameter = parameterService.getParameter(OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND);
27 if ( existingParameter != null ) {
28 Parameter.Builder updatedParameter = Parameter.Builder.create(existingParameter);
29 updatedParameter.setValue("N");
30 parameterService.updateParameter(updatedParameter.build());
31 } else {
32 Parameter.Builder newParameter = Parameter.Builder.create(OLEConstants.APPL_ID, OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND, ParameterType.Builder.create("CONFG"));
33 newParameter.setDescription( "Set to 'Y' to have the application ingest the default circulation policies upon next startup." );
34 newParameter.setValue("N");
35 parameterService.createParameter(newParameter.build());
36 }
37 }
38 }
39
40 public void setWorkflowFileHandler(WorfklowFileHandler workflowFileHandler) {
41 this.workflowFileHandler = workflowFileHandler;
42 }
43
44 public void setParameterService(ParameterService parameterService) {
45 this.parameterService = parameterService;
46 }
47 }