1 package com.sri.emo.wizard.selection.management; 2 3 import com.jcorporate.expresso.core.controller.ControllerException; 4 import com.jcorporate.expresso.core.controller.ExpressoRequest; 5 import com.jcorporate.expresso.core.controller.ExpressoResponse; 6 import com.jcorporate.expresso.core.db.DBException; 7 import com.sri.common.controller.StateHandler; 8 import com.sri.emo.dbobj.WizStep; 9 10 11 /*** 12 * Base class for step definitions. This is the final step in defining 13 * a wizard step and it takes Title, Directive, and Helptext as a minimum 14 * for data entry. 15 * 16 * @author Michael Rimov 17 */ 18 abstract public class StepDefinition extends AbstractStepHandler implements StateHandler { 19 20 /*** 21 * The parameter name of the title parameter. 22 */ 23 public static final String PARAM_NAME_ID = "title"; 24 25 /*** 26 * The parameter name of the directive parameter. 27 */ 28 public static final String PARAM_DIRECTIVE_ID = "directive"; 29 30 /*** 31 * The parameter name of the helptext parameter. 32 */ 33 public static final String PARAM_HELPTEXT_ID = "helpText"; 34 35 /*** 36 * The step definition so far. 37 */ 38 private WizStep stepDefinition; 39 40 /*** 41 * Default Constructor. 42 * 43 * @param wizId the Wizard id we're working with. 44 * @param stepId the Step Id we're working with. (May be null for no step) 45 * @throws DBException upon DBObject construction/retrieval error. 46 */ 47 public StepDefinition(final String wizId, final String stepId) throws DBException { 48 super(wizId, stepId); 49 } 50 51 /*** 52 * Base class parses some parameters and loads the step definition based on that. 53 * 54 * @param request ControllerRequest 55 * @param response ControllerResponse 56 * @throws DBException upon database error. 57 * @throws ControllerException upon controller error. 58 */ 59 public void handleRequest(final ExpressoRequest request, final ExpressoResponse response) 60 throws DBException, ControllerException { 61 62 int wizId = Integer.parseInt(request.getParameter(WizStep.FLD_ID)); 63 if (wizId != 0) { 64 stepDefinition = new WizStep(); 65 stepDefinition.setId(wizId); 66 stepDefinition.retrieve(); 67 } 68 } 69 70 /*** 71 * Retrieve the current step. Returns null if none is defined (which is fine for 'add' situations) 72 * 73 * @return WizStep 74 */ 75 protected WizStep getStep() { 76 return stepDefinition; 77 } 78 79 80 }