HandOutCarController.java
// license-header java merge-point
// Generated by andromda-jsf cartridge (controllers\Controller.java.vsl) DO NOT EDIT!
package org.andromda.samples.carrental.contracts.web.handOut;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.andromda.samples.carrental.ControllerBase;
import org.andromda.samples.carrental.JsfUtils;
import org.andromda.samples.carrental.ServiceLocator;
import org.andromda.samples.carrental.admins.web.main.AdministrationController;
import org.andromda.samples.carrental.contracts.ContractService;
/**
* <p>
* This controller allows the user to Hand out a Car. It calls the Contract Service on the server
* side
* </p>
* <p>
* @author Carlos Cuenca
* </p>
*/
public abstract class HandOutCarController
extends ControllerBase
implements Serializable
{
/**
* The serial version UID of this class. Needed for serialization.
*/
private static final long serialVersionUID = 1L;
/**
* Returns an instance from the JSF context
*
*/
public static HandOutCarController instance()
{
return (HandOutCarController)JsfUtils.resolveVariable("handOutCarController");
}
/**
* Populate action form and page variables
*
* @param currentView the current view
* @param forward the forward view
* @param sourceForm the source form
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
*/
private void populateActionFormsAndPageVariables(final String currentView, String forward, final Object sourceForm) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
if(forward == null)
{
forward=currentView;
}
final Map<String,Object> pageVariables=this.getPageVariables(forward);
if("/org/andromda/samples/carrental/contracts/web/handOut/choose-comfort-class.jsf".equals(forward))
{
HandOutCarViewPopulator.populateForm(sourceForm,this.getChooseComfortClassSelectReservationForm());
HandOutCarViewPopulator.populateChooseComfortClassPageVariables(sourceForm,pageVariables);
}
else
if("/org/andromda/samples/carrental/contracts/web/handOut/choose-car.jsf".equals(forward))
{
HandOutCarViewPopulator.populateForm(sourceForm,this.getChooseCarSelectCarForm());
HandOutCarViewPopulator.populateChooseCarPageVariables(sourceForm,pageVariables);
}
else
if("/org/andromda/samples/carrental/contracts/web/handOut/hand-out-doc.jsf".equals(forward))
{
HandOutCarViewPopulator.populateForm(sourceForm,this.getHandOutDocContinueForm());
}
else
if("/org/andromda/samples/carrental/contracts/web/handOut/contract.jsf".equals(forward))
{
HandOutCarViewPopulator.populateForm(sourceForm,this.getContractFinishReservationForm());
}
ControllerBase.getUseCaseScope().put(CURRENT_PAGE_VARIABLES_KEY, pageVariables);
}
/**
* <p>
* TODO: Model Documentation for
* org.andromda.samples.carrental.contracts.web.handOut.loadAvailableCars
* </p>
*
* @param form the associated form
* @throws Throwable
*/
public abstract String loadAvailableCars(LoadAvailableCarsForm form)
throws Throwable;
/**
* <p>
* TODO: Model Documentation for
* org.andromda.samples.carrental.contracts.web.handOut.searchForReservationsOfCustomer
* </p>
*
* @param form the associated form
* @throws Throwable
*/
public abstract void searchForReservationsOfCustomer(SearchForReservationsOfCustomerForm form)
throws Throwable;
/**
* <p>
* TODO: Model Documentation for
* org.andromda.samples.carrental.contracts.web.handOut.saveSelectedCar
* </p>
*
* @param form the associated form
* @throws Throwable
*/
public abstract void saveSelectedCar(SaveSelectedCarForm form)
throws Throwable;
/**
* Retrieves the {@link ChooseComfortClassSelectReservationFormImpl} form instance
*
* @return ChooseComfortClassSelectReservationFormImpl
*/
protected ChooseComfortClassSelectReservationFormImpl getChooseComfortClassSelectReservationForm()
{
return (ChooseComfortClassSelectReservationFormImpl)JsfUtils.resolveVariable("handOutCarChooseComfortClassSelectReservationForm");
}
/**
* <p>
* TODO: Model Documentation for selectReservation
* </p>
* This method is called when 'selectReservation' is triggered in the view 'Choose Comfort Class'.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _chooseComfortClass_selectReservation(ChooseComfortClassSelectReservationFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves chooseComfortClassSelectReservation()
*
* @return chooseComfortClassSelectReservation
* @throws Throwable
*/
public String chooseComfortClassSelectReservation()
throws Throwable
{
this.setLastPostedFormClientId("handOutCarChooseComfortClassSelectReservationForm");
String forward=null;
final ChooseComfortClassSelectReservationFormImpl form =
this.getChooseComfortClassSelectReservationForm();
//trigger method execution
_chooseComfortClass_selectReservation(form);
forward = _loadAvailableCars(form);
populateActionFormsAndPageVariables("/org/andromda/samples/carrental/contracts/web/handOut/choose-comfort-class.jsf",forward,form);
if(forward != null)
{
if("/org/andromda/samples/carrental/contracts/web/handOut/choose-comfort-class.jsf".equals(forward))
{
forward = null; //the destination form is the same, stay on the current view
}
}
return forward;
}
/**
* <p>
* TODO: Model Documentation for load Available Cars
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _loadAvailableCars(final ChooseComfortClassSelectReservationFormImpl form)
throws Throwable
{
String forward = null;
loadAvailableCars(form);
forward = "/org/andromda/samples/carrental/contracts/web/handOut/choose-car.jsf";
return forward;
}
/**
* Retrieves the {@link ChooseCarSelectCarFormImpl} form instance
*
* @return ChooseCarSelectCarFormImpl
*/
protected ChooseCarSelectCarFormImpl getChooseCarSelectCarForm()
{
return (ChooseCarSelectCarFormImpl)JsfUtils.resolveVariable("handOutCarChooseCarSelectCarForm");
}
/**
* <p>
* TODO: Model Documentation for Select car
* </p>
* This method is called when 'Select car' is triggered in the view 'Choose Car'.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _chooseCar_selectCar(ChooseCarSelectCarFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves chooseCarSelectCar()
*
* @return chooseCarSelectCar
* @throws Throwable
*/
public String chooseCarSelectCar()
throws Throwable
{
this.setLastPostedFormClientId("handOutCarChooseCarSelectCarForm");
String forward=null;
final ChooseCarSelectCarFormImpl form =
this.getChooseCarSelectCarForm();
//trigger method execution
_chooseCar_selectCar(form);
forward = _saveSelectedCar(form);
populateActionFormsAndPageVariables("/org/andromda/samples/carrental/contracts/web/handOut/choose-car.jsf",forward,form);
if(forward != null)
{
if("/org/andromda/samples/carrental/contracts/web/handOut/choose-car.jsf".equals(forward))
{
forward = null; //the destination form is the same, stay on the current view
}
}
return forward;
}
/**
* <p>
* TODO: Model Documentation for save selected Car
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _saveSelectedCar(final ChooseCarSelectCarFormImpl form)
throws Throwable
{
String forward = null;
saveSelectedCar(form);
forward = "/org/andromda/samples/carrental/contracts/web/handOut/hand-out-doc.jsf";
return forward;
}
/**
* Retrieves the {@link HandOutDocContinueFormImpl} form instance
*
* @return HandOutDocContinueFormImpl
*/
protected HandOutDocContinueFormImpl getHandOutDocContinueForm()
{
return (HandOutDocContinueFormImpl)JsfUtils.resolveVariable("handOutCarHandOutDocContinueForm");
}
/**
* <p>
* TODO: Model Documentation for continue
* </p>
* This method is called when 'continue' is triggered in the view 'Hand Out Doc'.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _handOutDoc_continue(HandOutDocContinueFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves handOutDocContinue()
*
* @return handOutDocContinue
* @throws Throwable
*/
public String handOutDocContinue()
throws Throwable
{
this.setLastPostedFormClientId("handOutCarHandOutDocContinueForm");
String forward=null;
final HandOutDocContinueFormImpl form =
this.getHandOutDocContinueForm();
//trigger method execution
_handOutDoc_continue(form);
forward = _createHandOutDoc(form);
populateActionFormsAndPageVariables("/org/andromda/samples/carrental/contracts/web/handOut/hand-out-doc.jsf",forward,form);
if(forward != null)
{
if("/org/andromda/samples/carrental/contracts/web/handOut/hand-out-doc.jsf".equals(forward))
{
forward = null; //the destination form is the same, stay on the current view
}
}
return forward;
}
/**
* <p>
* TODO: Model Documentation for Create Hand Out Doc
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _createHandOutDoc(final HandOutDocContinueFormImpl form)
throws Throwable
{
String forward = null;
forward = "/org/andromda/samples/carrental/contracts/web/handOut/contract.jsf";
return forward;
}
/**
* Retrieves the {@link ContractFinishReservationFormImpl} form instance
*
* @return ContractFinishReservationFormImpl
*/
protected ContractFinishReservationFormImpl getContractFinishReservationForm()
{
return (ContractFinishReservationFormImpl)JsfUtils.resolveVariable("handOutCarContractFinishReservationForm");
}
/**
* <p>
* TODO: Model Documentation for finishReservation
* </p>
* This method is called when 'finishReservation' is triggered in the view 'Contract'.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _contract_finishReservation(ContractFinishReservationFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves contractFinishReservation()
*
* @return contractFinishReservation
* @throws Throwable
*/
public String contractFinishReservation()
throws Throwable
{
this.setLastPostedFormClientId("handOutCarContractFinishReservationForm");
String forward=null;
final ContractFinishReservationFormImpl form =
this.getContractFinishReservationForm();
//trigger method execution
_contract_finishReservation(form);
forward = _createContract(form);
populateActionFormsAndPageVariables("/org/andromda/samples/carrental/contracts/web/handOut/contract.jsf",forward,form);
if(forward != null)
{
if("/org/andromda/samples/carrental/contracts/web/handOut/contract.jsf".equals(forward))
{
forward = null; //the destination form is the same, stay on the current view
}
}
return forward;
}
/**
* <p>
* TODO: Model Documentation for Create Contract
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _createContract(final ContractFinishReservationFormImpl form)
throws Throwable
{
String forward = null;
forward = ((AdministrationController)JsfUtils.resolveVariable("administrationController")).startUseCase();
return forward;
}
/**
* Retrieves the {@link HandOutCarFormImpl} form instance
*
* @return HandOutCarFormImpl
*/
protected HandOutCarFormImpl getHandOutCarForm()
{
return (HandOutCarFormImpl)JsfUtils.resolveVariable("handOutCarHandOutCarForm");
}
/**
* This method is called when the use case 'Hand out Car' starts.
* It can be safely overridden in descendant classes.
*
* @param form the associated form
*/
protected void _handOutCar_started(HandOutCarFormImpl form)
{
//this method can be overridden
}
/**
* Retrieves the internal start use case
*
* @return handOutCar
* @throws Throwable
*/
protected String internalStartUseCase(Map<String,Object> useCaseParameters)
throws Throwable
{
this.setLastPostedFormClientId("handOutCarHandOutCarForm");
String forward=null;
final HandOutCarFormImpl form =
this.getHandOutCarForm();
//copy parameters form caller use case
form.copyFrom(useCaseParameters);
//trigger method execution
_handOutCar_started(form);
forward = _loadCustomerReservations(form);
populateActionFormsAndPageVariables(null,forward,form);
return forward;
}
/**
* <p>
* TODO: Model Documentation for load customer reservations
* </p>
*
* @param form the associated form
* @return the forward view
* @throws Throwable
*/
protected String _loadCustomerReservations(final HandOutCarFormImpl form)
throws Throwable
{
String forward = null;
searchForReservationsOfCustomer(form);
forward = "/org/andromda/samples/carrental/contracts/web/handOut/choose-comfort-class.jsf";
return forward;
}
/**
* Returns a reference to the ContractService back-end service.
*
* @return ServiceLocator.instance().getContractService()
*/
protected final ContractService getContractService()
{
try
{
return ServiceLocator.instance().getContractService();
}
catch (final Throwable throwable)
{
throw new RuntimeException(throwable);
}
}
}