001package org.kuali.ole; 002 003 004import org.kuali.ole.sys.OLEConstants; 005import org.kuali.ole.workflow.WorfklowFileHandler; 006import org.kuali.rice.coreservice.api.parameter.Parameter; 007import org.kuali.rice.coreservice.api.parameter.ParameterType; 008import org.kuali.rice.coreservice.framework.parameter.ParameterService; 009 010/** 011 * 012 */ 013public class LoadDefaultWorkflowsBean { 014 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LoadDefaultWorkflowsBean.class); 015 protected static final String LOAD_DEFAULT_WORKFLOW_IND = "LOAD_DEFAULT_WORKFLOW_IND"; 016 protected ParameterService parameterService; 017 protected WorfklowFileHandler workflowFileHandler; 018 019 public void unpackWorkflows( boolean forceLoad ) { 020 if ( forceLoad || parameterService.getParameterValueAsBoolean(OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND, Boolean.TRUE) ) { 021 022 LOG.info("Starting Load of Default Workflows"); 023 workflowFileHandler.execute(); 024 LOG.info("Completed Load of Default Workflows"); 025 026 Parameter existingParameter = parameterService.getParameter(OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND); 027 if ( existingParameter != null ) { 028 Parameter.Builder updatedParameter = Parameter.Builder.create(existingParameter); 029 updatedParameter.setValue("N"); 030 parameterService.updateParameter(updatedParameter.build()); 031 } else { 032 Parameter.Builder newParameter = Parameter.Builder.create(OLEConstants.APPL_ID, OLEConstants.OLE_NMSPC, OLEConstants.OLE_CMPNT, LOAD_DEFAULT_WORKFLOW_IND, ParameterType.Builder.create("CONFG")); 033 newParameter.setDescription( "Set to 'Y' to have the application ingest the default circulation policies upon next startup." ); 034 newParameter.setValue("N"); 035 parameterService.createParameter(newParameter.build()); 036 } 037 } 038 } 039 040 public void setWorkflowFileHandler(WorfklowFileHandler workflowFileHandler) { 041 this.workflowFileHandler = workflowFileHandler; 042 } 043 044 public void setParameterService(ParameterService parameterService) { 045 this.parameterService = parameterService; 046 } 047}