InventoryServiceBase.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::inventory::InventoryService
* STEREOTYPE: Service
*/
package org.andromda.samples.carrental.inventory;
import java.security.Principal;
import java.util.Collection;
import java.util.Locale;
import org.andromda.samples.carrental.BeanLocator;
import org.andromda.samples.carrental.PrincipalStore;
import org.springframework.context.MessageSource;
/**
* <p>
* Spring Service base class for <code>InventoryService</code>,
* provides access to all services and entities referenced by this service.
* </p>
*
* @see InventoryService
*/
public abstract class InventoryServiceBase
implements InventoryService
{
private CarDao carDao;
/**
* Sets the reference to <code>car</code>'s DAO.
* @param carDaoIn
*/
public void setCarDao(CarDao carDaoIn)
{
this.carDao = carDaoIn;
}
/**
* Gets the reference to <code>car</code>'s DAO.
* @return carDao
*/
protected CarDao getCarDao()
{
return this.carDao;
}
private CarAccessoryDao carAccessoryDao;
/**
* Sets the reference to <code>carAccessory</code>'s DAO.
* @param carAccessoryDaoIn
*/
public void setCarAccessoryDao(CarAccessoryDao carAccessoryDaoIn)
{
this.carAccessoryDao = carAccessoryDaoIn;
}
/**
* Gets the reference to <code>carAccessory</code>'s DAO.
* @return carAccessoryDao
*/
protected CarAccessoryDao getCarAccessoryDao()
{
return this.carAccessoryDao;
}
private CarAccessoryTypeDao carAccessoryTypeDao;
/**
* Sets the reference to <code>carAccessoryType</code>'s DAO.
* @param carAccessoryTypeDaoIn
*/
public void setCarAccessoryTypeDao(CarAccessoryTypeDao carAccessoryTypeDaoIn)
{
this.carAccessoryTypeDao = carAccessoryTypeDaoIn;
}
/**
* Gets the reference to <code>carAccessoryType</code>'s DAO.
* @return carAccessoryTypeDao
*/
protected CarAccessoryTypeDao getCarAccessoryTypeDao()
{
return this.carAccessoryTypeDao;
}
private CarTypeDao carTypeDao;
/**
* Sets the reference to <code>carType</code>'s DAO.
* @param carTypeDaoIn
*/
public void setCarTypeDao(CarTypeDao carTypeDaoIn)
{
this.carTypeDao = carTypeDaoIn;
}
/**
* Gets the reference to <code>carType</code>'s DAO.
* @return carTypeDao
*/
protected CarTypeDao getCarTypeDao()
{
return this.carTypeDao;
}
/**
* {@inheritDoc}
*/
@Override
public String createCarType(final CarTypeData typeData)
throws InventoryException
{
if (typeData == null)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCarType(CarTypeData typeData) - 'typeData' can not be null");
}
if (typeData.getManufacter() == null || typeData.getManufacter().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCarType(CarTypeData typeData) - 'typeData.manufacter' can not be null or empty");
}
if (typeData.getIdentifier() == null || typeData.getIdentifier().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCarType(CarTypeData typeData) - 'typeData.identifier' can not be null or empty");
}
if (typeData.getOrderNo() == null || typeData.getOrderNo().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCarType(CarTypeData typeData) - 'typeData.orderNo' can not be null or empty");
}
if (typeData.getComfortClass() == null || typeData.getComfortClass().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCarType(CarTypeData typeData) - 'typeData.comfortClass' can not be null or empty");
}
try
{
return this.handleCreateCarType(typeData);
}
catch (InventoryException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new InventoryServiceException(
"Error performing 'InventoryService.createCarType(CarTypeData typeData)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #createCarType(CarTypeData)}
* @param typeData CarTypeData <p>
TODO: Model Documentation for typeData
</p>
* @return String
* @throws Exception
*/
protected abstract String handleCreateCarType(CarTypeData typeData)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public String createCar(final CarData carData, final String carTypeId)
throws InventoryException
{
if (carData == null)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCar(CarData carData, String carTypeId) - 'carData' can not be null");
}
if (carData.getRegistrationNo() == null || carData.getRegistrationNo().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCar(CarData carData, String carTypeId) - 'carData.registrationNo' can not be null or empty");
}
if (carData.getInventoryNo() == null || carData.getInventoryNo().trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCar(CarData carData, String carTypeId) - 'carData.inventoryNo' can not be null or empty");
}
if (carTypeId == null || carTypeId.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.createCar(CarData carData, String carTypeId) - 'carTypeId' can not be null or empty");
}
try
{
return this.handleCreateCar(carData, carTypeId);
}
catch (InventoryException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new InventoryServiceException(
"Error performing 'InventoryService.createCar(CarData carData, String carTypeId)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #createCar(CarData, String)}
* @param carData CarData <p>
TODO: Model Documentation for carData
</p>
* @param carTypeId String <p>
TODO: Model Documentation for carTypeId
</p>
* @return String
* @throws Exception
*/
protected abstract String handleCreateCar(CarData carData, String carTypeId)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public Collection searchCarByComfortClass(final String comfortClass)
throws InventoryException
{
if (comfortClass == null || comfortClass.trim().length() == 0)
{
throw new IllegalArgumentException(
"org.andromda.samples.carrental.inventory.InventoryService.searchCarByComfortClass(String comfortClass) - 'comfortClass' can not be null or empty");
}
try
{
return this.handleSearchCarByComfortClass(comfortClass);
}
catch (InventoryException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new InventoryServiceException(
"Error performing 'InventoryService.searchCarByComfortClass(String comfortClass)' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchCarByComfortClass(String)}
* @param comfortClass String <p>
TODO: Model Documentation for comfortClass
</p>
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchCarByComfortClass(String comfortClass)
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public Collection searchAllCarTypes()
throws InventoryException
{
try
{
return this.handleSearchAllCarTypes();
}
catch (InventoryException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new InventoryServiceException(
"Error performing 'InventoryService.searchAllCarTypes()' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchAllCarTypes()}
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchAllCarTypes()
throws Exception;
/**
* {@inheritDoc}
*/
@Override
public Collection searchAllCars()
throws InventoryException
{
try
{
return this.handleSearchAllCars();
}
catch (InventoryException ex)
{
throw ex;
}
catch (Throwable th)
{
throw new InventoryServiceException(
"Error performing 'InventoryService.searchAllCars()' --> " + th,
th);
}
}
/**
* Performs the core logic for {@link #searchAllCars()}
* @return Collection
* @throws Exception
*/
protected abstract Collection handleSearchAllCars()
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
}