com.mycompany.service.impl
Class CountryServiceImpl

java.lang.Object
  extended by com.mycompany.service.impl.AbstractService
      extended by com.mycompany.service.impl.CountryServiceImpl
All Implemented Interfaces:
CountryService

@Named(value="countryService")
public class CountryServiceImpl
extends AbstractService
implements CountryService

Country service implementation class.

Author:
Ian Hlavats (ian@tarantulaconsulting.com)

Constructor Summary
CountryServiceImpl()
           
 
Method Summary
 ProvinceState createProvinceState(Country country, java.lang.String name)
          Creates a ProvinceState object for a particular Country.
 java.util.List<City> findCitiesByState(ProvinceState state)
          Finds a list of City objects for the given ProvinceState.
 City findCity(java.lang.String name, ProvinceState provinceState)
          Finds a City by name in the ProvinceState.
 City findCityById(java.lang.Integer id)
          Finds a City object by ID.
 Country findCountryById(java.lang.Integer id)
          Finds a Country object by ID.
 java.util.List<ProvinceState> findProvinceStatesByCountry(Country country)
          Finds a List of ProvinceState objects for a particular Country.
 ProvinceState findStateById(java.lang.Integer id)
          Finds a ProvinceState object by ID.
 ProvinceState findStateByName(Country country, java.lang.String stateName)
          Finds a ProvinceState object by name within a particular Country.
 java.util.List<Country> getCountries()
          Returns all Country objects.
 java.util.List<ProvinceState> getProvinceStates()
          Returns all ProvinceState objects.
 void init(javax.servlet.ServletContext context)
          Invoked during the ServletContext initialization to populate the database with sample data.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CountryServiceImpl

public CountryServiceImpl()
Method Detail

createProvinceState

public ProvinceState createProvinceState(Country country,
                                         java.lang.String name)
Creates a ProvinceState object for a particular Country.

Specified by:
createProvinceState in interface CountryService
Parameters:
country - The Country in which the ProvinceState is located.
name - The name of the ProvinceState.
Returns:
The newly created ProvinceState object.

findCitiesByState

public java.util.List<City> findCitiesByState(ProvinceState state)
Finds a list of City objects for the given ProvinceState.

Specified by:
findCitiesByState in interface CountryService
Parameters:
state - The ProvinceState object for which to find cities.
Returns:
A List of City objects.

findCity

public City findCity(java.lang.String name,
                     ProvinceState provinceState)
Finds a City by name in the ProvinceState.

Specified by:
findCity in interface CountryService
Parameters:
name - The name of the city.
provinceState - The province/state in which to find the city.
Returns:
A City object.

findCityById

public City findCityById(java.lang.Integer id)
Finds a City object by ID.

Specified by:
findCityById in interface CountryService
Parameters:
id - The ID of the city.
Returns:
A City object.

findCountryById

public Country findCountryById(java.lang.Integer id)
Finds a Country object by ID.

Specified by:
findCountryById in interface CountryService
Parameters:
id - The ID of the country.
Returns:
A Country object.

findProvinceStatesByCountry

public java.util.List<ProvinceState> findProvinceStatesByCountry(Country country)
Finds a List of ProvinceState objects for a particular Country.

Specified by:
findProvinceStatesByCountry in interface CountryService
Parameters:
country - The Country object.
Returns:
A List of ProvinceState objects.

findStateById

public ProvinceState findStateById(java.lang.Integer id)
Finds a ProvinceState object by ID.

Specified by:
findStateById in interface CountryService
Parameters:
id - The ID of the ProvinceState object.
Returns:
A ProvinceState object.

findStateByName

public ProvinceState findStateByName(Country country,
                                     java.lang.String stateName)
Finds a ProvinceState object by name within a particular Country.

Specified by:
findStateByName in interface CountryService
Parameters:
country - The Country object.
stateName - The name of the ProvinceState to find.
Returns:
A ProvinceState object.

getCountries

public java.util.List<Country> getCountries()
Returns all Country objects.

Specified by:
getCountries in interface CountryService
Returns:
A List of Country objects.

getProvinceStates

public java.util.List<ProvinceState> getProvinceStates()
Returns all ProvinceState objects.

Specified by:
getProvinceStates in interface CountryService
Returns:
A List of ProvinceState objects.

init

public void init(@Observes
                 javax.servlet.ServletContext context)
          throws java.lang.Exception
Invoked during the ServletContext initialization to populate the database with sample data.

Specified by:
init in interface CountryService
Parameters:
context - The ServletContext object.
Throws:
java.lang.Exception - If something goes wrong.