com.gisgraphy.domain.repository
Class CountryDao

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by com.gisgraphy.domain.repository.GenericDao<T,java.lang.Long>
              extended by com.gisgraphy.domain.repository.GenericGisDao<Country>
                  extended by com.gisgraphy.domain.repository.CountryDao
All Implemented Interfaces:
ICountryDao, IDao<Country,java.lang.Long>, IGisDao<Country>, org.springframework.beans.factory.InitializingBean

@Repository
public class CountryDao
extends GenericGisDao<Country>
implements ICountryDao

A data access object for Country

Author:
David Masclet

Field Summary
 
Fields inherited from class com.gisgraphy.domain.repository.GenericGisDao
GEOMETRY_TYPE, MAX_FULLTEXT_RESULTS
 
Fields inherited from class com.gisgraphy.domain.repository.GenericDao
persistentClass
 
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
 
Constructor Summary
CountryDao()
          Default Constructor
 
Method Summary
 int deleteAll()
          Delete all the object from the datastore
 java.util.List<Country> getAllSortedByName()
           
 Country getByIso3166Alpha2Code(java.lang.String iso3166Alpha2Code)
          Get By ISO 3166 Alpha 2 (2-letter) code NOTE : The country code will be automaticaly converted in upperCase
 Country getByIso3166Alpha3Code(java.lang.String iso3166Alpha3Code)
          Get by ISO 639 Alpha 3 (3-letter) code NOTE : The country code will be automaticaly converted in upperCase
 Country getByIso3166Code(java.lang.String iso3166Code)
          Wrapper method around ICountryDao.getByIso3166Alpha2Code(String) and ICountryDao.getByIso3166Alpha3Code(String).
 Country getByName(java.lang.String name)
          returns the country for the specified name
 java.util.List<java.lang.Long> listFeatureIds()
          List all the featureId of countries
 Country save(Country country)
          Saves the passed object, and returns an attached entity.
 
Methods inherited from class com.gisgraphy.domain.repository.GenericGisDao
createGISTIndexForLocationColumn, deleteAll, getByFeatureId, getDirties, getEager, getNearestAndDistanceFrom, getNearestAndDistanceFrom, getNearestAndDistanceFrom, getNearestAndDistanceFromGisFeature, getNearestAndDistanceFromGisFeature, listByFeatureIds, listByName, listFromText, listFromText, remove, setEventManager
 
Methods inherited from class com.gisgraphy.domain.repository.GenericDao
count, exists, flushAndClear, get, getAll, getAllPaginate, getPersistenceClass, setFlushMode
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.gisgraphy.domain.repository.IGisDao
createGISTIndexForLocationColumn, getByFeatureId, getDirties, getEager, getNearestAndDistanceFrom, getNearestAndDistanceFrom, getNearestAndDistanceFromGisFeature, getNearestAndDistanceFromGisFeature, listByFeatureIds, listByName, listFromText
 
Methods inherited from interface com.gisgraphy.domain.repository.IDao
count, deleteAll, exists, flushAndClear, get, getAll, getAllPaginate, getPersistenceClass, remove, setFlushMode
 

Constructor Detail

CountryDao

public CountryDao()
Default Constructor

Method Detail

save

public Country save(Country country)
Description copied from interface: IDao
Saves the passed object, and returns an attached entity. It is very very very important to use the returned entity, because of the way the underlying mechanism possibly works. For instance, when using Db4o, this is completly useless, but when using JPA and the merge method of the EntityManager, things are going to be buggy (Duplicate Key exceptions) if you don't use the returned object. Please consult EJB3 (or the concrete persistence framework doc) Spec for more information about the way the merge method works.

Specified by:
save in interface IDao<Country,java.lang.Long>
Overrides:
save in class GenericGisDao<Country>
Parameters:
country - the country to save
Returns:
The saved instance
Throws:
DuplicateNameException - If a country with the same name already exists in the datastore

getByIso3166Alpha2Code

public Country getByIso3166Alpha2Code(java.lang.String iso3166Alpha2Code)
Description copied from interface: ICountryDao
Get By ISO 3166 Alpha 2 (2-letter) code NOTE : The country code will be automaticaly converted in upperCase

Specified by:
getByIso3166Alpha2Code in interface ICountryDao
Parameters:
iso3166Alpha2Code - The ISO 3166 Alpha 2 code in upper case
Returns:
The expected country for the specified alpha 2 code or null if the iso639Alpha2LanguageCode is null
See Also:
ICountryDao.getByIso3166Alpha3Code(String), ICountryDao.getByIso3166Code(String)

getByIso3166Alpha3Code

public Country getByIso3166Alpha3Code(java.lang.String iso3166Alpha3Code)
Description copied from interface: ICountryDao
Get by ISO 639 Alpha 3 (3-letter) code NOTE : The country code will be automaticaly converted in upperCase

Specified by:
getByIso3166Alpha3Code in interface ICountryDao
Parameters:
iso3166Alpha3Code - The ISO 3166 Alpha 2 code in upper case
Returns:
The expected country for the specified alpha 3 code or null if the iso639Alpha3Code is null
See Also:
ICountryDao.getByIso3166Alpha2Code(String), ICountryDao.getByIso3166Code(String)

getByIso3166Code

public Country getByIso3166Code(java.lang.String iso3166Code)
Description copied from interface: ICountryDao
Wrapper method around ICountryDao.getByIso3166Alpha2Code(String) and ICountryDao.getByIso3166Alpha3Code(String). This method is to use when you want to get the country with an iso 3166 code that you don't know if it is an alpha 2 or 3 Get by ISO 639 Alpha 2 or 3 code

Specified by:
getByIso3166Code in interface ICountryDao
Parameters:
iso3166Code - the iso 3166 Code
Returns:
the expected country or null if the code is null or it is not a 2 or 3 char code
See Also:
ICountryDao.getByIso3166Alpha3Code(String), ICountryDao.getByIso3166Alpha2Code(String)

getByName

public Country getByName(java.lang.String name)
Description copied from interface: ICountryDao
returns the country for the specified name

Specified by:
getByName in interface ICountryDao
Parameters:
name - the name of the country to retrieve
Returns:
the expected country or null if the code is null or it is not a 2 or 3 char code

deleteAll

public int deleteAll()
Description copied from interface: IDao
Delete all the object from the datastore

Specified by:
deleteAll in interface IDao<Country,java.lang.Long>
Overrides:
deleteAll in class GenericGisDao<Country>
Returns:
the number of deleted objects

getAllSortedByName

public java.util.List<Country> getAllSortedByName()
Specified by:
getAllSortedByName in interface ICountryDao
Returns:
all the countries sorted by name, never return null but an empty list

listFeatureIds

public java.util.List<java.lang.Long> listFeatureIds()
Description copied from interface: ICountryDao
List all the featureId of countries

Specified by:
listFeatureIds in interface ICountryDao
Returns:
a list of all featureId for all the countries


Copyright © 2010. All Rights Reserved.