1 package com.sri.emo.wizard.wizardgateway; 2 3 import com.jcorporate.expresso.core.controller.*; 4 import com.jcorporate.expresso.core.db.DBException; 5 import com.sri.common.controller.StateHandler; 6 import com.sri.emo.dbobj.WizDefinition; 7 import com.sri.emo.wizard.WizDefinitionRepository; 8 import com.sri.emo.wizard.expressoimpl.WizardController; 9 10 /*** 11 * Prompts to delete a wizard. 12 * 13 * @author Michael Rimov 14 */ 15 public class PromptDeleteWizard extends WizardGatewayHandler implements StateHandler { 16 17 /*** 18 * Name of the State for which this handler deals with. 19 */ 20 public static final String STATE_NAME = "promptDelete"; 21 22 23 /*** 24 * Friendly description of this handler. 25 */ 26 public static final String STATE_DESCRIPTION = "Prompt to Delete a Wizard"; 27 28 29 /*** 30 * Constructs this particular state handler. 31 * 32 * @param handlerOwner Controller the controller that is the parent of this 33 * state handler. 34 * @param myRepository WizDefinitionRepository the repository to use 35 * for data access methods. 36 */ 37 public PromptDeleteWizard(final Controller handlerOwner, final WizDefinitionRepository myRepository) { 38 super(handlerOwner, myRepository); 39 } 40 41 42 /*** 43 * Called to handle the request. 44 * 45 * @param request ControllerRequest The Function's ControllerRequest 46 * object. 47 * @param response ControllerResponse The Function's ControllerResponse 48 * object. 49 * @throws DBException upon underlying database exception error. 50 * @throws ControllerException upon underlying ControllerException error. 51 */ 52 public void handleRequest(final ExpressoRequest request, final ExpressoResponse response) throws DBException, 53 ControllerException { 54 response.setTitle("Confirm Delete Wizard"); 55 WizDefinition wizdef = getWizDef(request); 56 response.add(new Output("prompt", wizdef.getWizName())); 57 58 Transition yes = new Transition("yes", "yes", this.getOwner().getClass(), DoDeleteWizard.STATE_NAME); 59 yes.addParam(WizardController.WIZ_PARAMETER_ID, request.getParameter(WizardController.WIZ_PARAMETER_ID)); 60 response.add(yes); 61 Transition no = new Transition("no", "no", this.getOwner().getClass(), ListWizards.STATE_NAME); 62 response.add(no); 63 } 64 }