ContractServiceBase.java
// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by SpringServiceBase.vsl in andromda-spring-cartridge on 08/18/2014 15:29:44-0400. Do not modify by hand!.
//
/**
* TEMPLATE: SpringServiceBase.vsl in andromda-spring cartridge
* MODEL CLASS: org::andromda::samples::carrental::contracts::ContractService
* STEREOTYPE: Service
*/
package org.andromda.samples.carrental.contracts;
import java.security.Principal;
import java.util.Collection;
import java.util.Date;
import java.util.Locale;
import org.andromda.samples.carrental.BeanLocator;
import org.andromda.samples.carrental.PrincipalStore;
import org.andromda.samples.carrental.customers.CustomerDao;
import org.andromda.samples.carrental.inventory.InventoryService;
import org.springframework.context.MessageSource;
/**
* <p>
* Spring Service base class for <code>ContractService</code>,
* provides access to all services and entities referenced by this service.
* </p>
*
* @see ContractService
*/
public abstract class ContractServiceBase
implements ContractService
{
private InventoryService inventoryService;
/**
* Sets the reference to <code>inventoryService</code>.
* @param inventoryServiceIn
*/
public void setInventoryService(InventoryService inventoryServiceIn)
{
this.inventoryService = inventoryServiceIn;
}
/**
* Gets the reference to <code>inventoryService</code>.
* @return inventoryService
*/
protected InventoryService getInventoryService()
{
return this.inventoryService;
}
private ReservationDao reservationDao;
/**
* Sets the reference to <code>reservation</code>'s DAO.
* @param reservationDaoIn
*/
public void setReservationDao(ReservationDao reservationDaoIn)
{
this.reservationDao = reservationDaoIn;
}
/**
* Gets the reference to <code>reservation</code>'s DAO.
* @return reservationDao
*/
protected ReservationDao getReservationDao()
{
return this.reservationDao;
}
private ContractDao contractDao;
/**
* Sets the reference to <code>contract</code>'s DAO.
* @param contractDaoIn
*/
public void setContractDao(ContractDao contractDaoIn)
{
this.contractDao = contractDaoIn;
}
/**
* Gets the reference to <code>contract</code>'s DAO.
* @return contractDao
*/
protected ContractDao getContractDao()
{
return this.contractDao;
}
private CustomerDao customerDao;
/**
* Sets the reference to <code>customer</code>'s DAO.
* @param customerDaoIn
*/
public void setCustomerDao(CustomerDao customerDaoIn)
{
this.customerDao = customerDaoIn;
}
/**
* Gets the reference to <code>customer</code>'s DAO.
* @return customerDao
*/
protected CustomerDao getCustomerDao()
{
return this.customerDao;
}
/**
* {@inheritDoc}
*/
@Override
public Collection searchForReservationsOfCustomer(final String customerId)
throws ContractException
{
if (customerId == null || customerId.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.searchForReservationsOfCustomer(String customerId) - 'customerId' can not be null or empty");
}
try
{
return this.handleSearchForReservationsOfCustomer(customerId);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.searchForReservationsOfCustomer(String customerId)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchForReservationsOfCustomer(String)}
* @param customerId String <p>
TODO: Model Documentation for customerId
</p>
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchForReservationsOfCustomer(String customerId)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public void reserve(final String customerId, final String comfortClass, final Date reservationDate)
throws ContractException
{
if (customerId == null || customerId.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.reserve(String customerId, String comfortClass, Date reservationDate) - 'customerId' can not be null or empty");
}
if (comfortClass == null || comfortClass.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.reserve(String customerId, String comfortClass, Date reservationDate) - 'comfortClass' can not be null or empty");
}
if (reservationDate == null)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.reserve(String customerId, String comfortClass, Date reservationDate) - 'reservationDate' can not be null");
}
try
{
this.handleReserve(customerId, comfortClass, reservationDate);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.reserve(String customerId, String comfortClass, Date reservationDate)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #reserve(String, String, Date)}
* @param customerId String <p>
TODO: Model Documentation for customerId
</p>
* @param comfortClass String <p>
TODO: Model Documentation for comfortClass
</p>
* @param reservationDate Date <p>
TODO: Model Documentation for reservationDate
</p>
* @return void
* @throws Exception
*/
protected abstract void handleReserve(String customerId, String comfortClass, Date reservationDate)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String handOutReservation(final String idReservation)
throws ContractException
{
if (idReservation == null || idReservation.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.handOutReservation(String idReservation) - 'idReservation' can not be null or empty");
}
try
{
return this.handleHandOutReservation(idReservation);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.handOutReservation(String idReservation)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #handOutReservation(String)}
* @param idReservation String <p>
TODO: Model Documentation for idReservation
</p>
* @return String
* @throws Exception
*/
protected abstract String handleHandOutReservation(String idReservation)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String returnCar(final String idContract)
throws ContractException
{
if (idContract == null || idContract.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.returnCar(String idContract) - 'idContract' can not be null or empty");
}
try
{
return this.handleReturnCar(idContract);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.returnCar(String idContract)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #returnCar(String)}
* @param idContract String <p>
TODO: Model Documentation for idContract
</p>
* @return String
* @throws Exception
*/
protected abstract String handleReturnCar(String idContract)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public Collection searchForContractsOfCustomer(final String idCustomer)
throws ContractException
{
if (idCustomer == null || idCustomer.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.searchForContractsOfCustomer(String idCustomer) - 'idCustomer' can not be null or empty");
}
try
{
return this.handleSearchForContractsOfCustomer(idCustomer);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.searchForContractsOfCustomer(String idCustomer)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchForContractsOfCustomer(String)}
* @param idCustomer String <p>
TODO: Model Documentation for idCustomer
</p>
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchForContractsOfCustomer(String idCustomer)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String registerAccident(final String idContract)
throws ContractException
{
if (idContract == null || idContract.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.contracts.ContractService.registerAccident(String idContract) - 'idContract' can not be null or empty");
}
try
{
return this.handleRegisterAccident(idContract);
}
catch (ContractException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new ContractServiceException(
"Error performing 'ContractService.registerAccident(String idContract)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #registerAccident(String)}
* @param idContract String <p>
TODO: Model Documentation for idContract
</p>
* @return String
* @throws Exception
*/
protected abstract String handleRegisterAccident(String idContract)
throws Exception;
/**
* Gets the current <code>principal</code> if one has been set,
* otherwise returns <code>null</code>.
*
* @return the current principal
*/
protected Principal getPrincipal()
{
return PrincipalStore.get();
}
/**
* Gets the message source available to this service.
* @return MessageSource
*/
protected MessageSource getMessages()
{
return (MessageSource)
BeanLocator.instance().getBean("messageSource");
}
/**
* Gets the message having the given <code>key</code> in the underlying message bundle.
*
* @param key the key of the message in the messages.properties message bundle.
* @return String
*/
protected String getMessage(final String key)
{
return this.getMessages().getMessage(key, null, null);
}
/**
* Gets the message having the given <code>key</code> and <code>arguments</code> in the
* underlying message bundle.
*
* @param key the key of the message in the messages.properties message bundle.
* @param arguments any arguments to substitute when resolving the message.
* @return String
*/
protected String getMessage(final String key, final Object[] arguments)
{
return this.getMessages().getMessage(key, arguments, null);
}
/**
* Gets the message having the given <code>key</code> using the given <code>arguments</code>
* for the given <code>locale</code>.
*
* @param key the key of the message in the messages.properties message bundle.
* @param arguments any arguments to substitute when resolving the message.
* @param locale the locale of the messages to retrieve.
* @return String
*/
protected String getMessage(
final String key, final Object[] arguments,
final Locale locale)
{
return this.getMessages().getMessage(key, arguments, locale);
}
// spring-service-base merge-point
}