com.gisgraphy.domain.repository
Class AdmDao
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate3.support.HibernateDaoSupport
com.gisgraphy.domain.repository.GenericDao<T,java.lang.Long>
com.gisgraphy.domain.repository.GenericGisDao<Adm>
com.gisgraphy.domain.repository.AdmDao
- All Implemented Interfaces:
- IAdmDao, IDao<Adm,java.lang.Long>, IGisDao<Adm>, org.springframework.beans.factory.InitializingBean
@Repository
public class AdmDao
- extends GenericGisDao<Adm>
- implements IAdmDao
A data access object for Adm
- Author:
- David Masclet
Fields inherited from class org.springframework.dao.support.DaoSupport |
logger |
Method Summary |
long |
countByLevel(int level)
|
int |
deleteAllByLevel(int level)
|
Adm |
getAdm(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
Retrieve the Adm of the highest level according to the AdmXcode. |
Adm |
getAdm1(java.lang.String countryCode,
java.lang.String adm1Code)
|
Adm |
getAdm2(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code)
|
Adm |
getAdm3(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code)
|
Adm |
getAdm4(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
|
java.util.List<Adm> |
getAdmByCountryAndCodeAndLevel(java.lang.String countryCode,
java.lang.String admCode,
int level)
Returns The Adm with the specified code and the specified level for the
specified country code. |
Adm |
getAdmOrFirstValidParentIfNotFound(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
Return The Adm for the specified Code in the same way of
IAdmDao.getAdm(String, String, String, String, String) or the first
valid parent if no Adm is found with the specified codes. |
java.util.List<Adm> |
getAllbyLevel(int level)
|
java.util.List<Adm> |
getDirties()
Returns inconsistant object (in most case object With featureid < 0) |
java.util.List<Adm> |
getUnused()
|
java.util.List<java.lang.Long> |
listFeatureIdByLevel(int level)
List all the featureId of the Adms of a specified level |
Adm |
save(Adm adm)
Check that codes are consistent according the level (see
Adm.isConsistentForLevel() and save it in the datastore |
Adm |
suggestMostAccurateAdm(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code,
GisFeature gisfeature)
This method is used when
ImporterConfig.isTryToDetectAdmIfNotFound() is true or when error
correction is needed. the algorithm will return an Adm according the
specified rules:
If an Adm with the specified code is found (see
IAdmDao.getAdm(String, String, String, String, String) ) : retrun it
If an Adm with the highest not null level is found for the specified
country (e.g : if adm1,2,3 are specified and adm4 is null and it exist an
adm with level 3 for the specified adm3Code then it will be return)
If no parent Adm is found (see
IAdmDao.getAdmOrFirstValidParentIfNotFound(String, String, String, String, String) :
return Adm with the highest not null level
If a parent Adm is found (see
IAdmDao.getAdmOrFirstValidParentIfNotFound(String, String, String, String, String) :
If the difference beetween the Adm and The parent Adm is <=2 : we
assume that it is an error with only one code and return the Adm with the
highest not null level
If the difference is >1 we assume that there is too much error and
return the nearest parent
If No Adm with the highest not null level is found for the specified
country
If a parent Adm is found (see
IAdmDao.getAdmOrFirstValidParentIfNotFound(String, String, String, String, String) :
return Adm with the highest not null level : return the Parent
If no parent is found : return null
|
Methods inherited from class com.gisgraphy.domain.repository.GenericGisDao |
createGISTIndexForLocationColumn, deleteAll, deleteAll, getByFeatureId, getEager, getNearestAndDistanceFrom, getNearestAndDistanceFrom, getNearestAndDistanceFrom, getNearestAndDistanceFromGisFeature, getNearestAndDistanceFromGisFeature, listByFeatureIds, listByName, listFromText, listFromText, remove, setEventManager |
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.IDao |
count, deleteAll, deleteAll, exists, flushAndClear, get, getAll, getAllPaginate, getPersistenceClass, remove, setFlushMode |
AdmDao
public AdmDao()
save
public Adm save(Adm adm)
- Check that codes are consistent according the level (see
Adm.isConsistentForLevel()
and save it in the datastore
- Specified by:
save
in interface IDao<Adm,java.lang.Long>
- Overrides:
save
in class GenericGisDao<Adm>
- Parameters:
adm
- The Adm to save
- Returns:
- the saved instance
- See Also:
Adm.isConsistentForLevel()
getAdm1
public Adm getAdm1(java.lang.String countryCode,
java.lang.String adm1Code)
- Specified by:
getAdm1
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieve
- Returns:
- The Adm with level 1 for the specified countrycode and adm1Code
NOTE : The countryCode will be automaticaly converted in
upperCase
- See Also:
IAdmDao.getAdm(String, String, String, String, String)
,
IAdmDao.getAdmByCountryAndCodeAndLevel(String, String, int)
getAdm2
public Adm getAdm2(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code)
- Specified by:
getAdm2
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieve NOTE : The
countryCode will be automaticaly converted in upperCase
- Returns:
- The Adm with level 2 for the specified countrycode, adm1Code, and
adm2Code. If adm1code is equals to 00 it will be ignore and more
than one result could be found, in that case it will return null.
- See Also:
IAdmDao.getAdm(String, String, String, String, String)
,
IAdmDao.getAdmByCountryAndCodeAndLevel(String, String, int)
getAdm3
public Adm getAdm3(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code)
- Specified by:
getAdm3
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieveadm3Code
- The Adm3Code of the Adm to retrieve NOTE : The
countryCode will be automaticaly converted in upperCase
- Returns:
- The Adm with level 3 for the specified countrycode, adm1Code,
adm2Code and adm3Code. If adm1code is equals to 00 it will be
ignore and more than one result could be found, in that case it
will return null.
- See Also:
IAdmDao.getAdm(String, String, String, String, String)
,
IAdmDao.getAdmByCountryAndCodeAndLevel(String, String, int)
getAdm4
public Adm getAdm4(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
- Specified by:
getAdm4
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieveadm3Code
- The Adm3Code of the Adm to retrieveadm4Code
- The Adm4Code of the Adm to retrieve NOTE : The
countryCode will be automaticaly converted in upperCase
- Returns:
- The Adm with level 4 for the specified countrycode, adm1Code,
adm2Code, adm3Code and adm4Code.If adm1code is equals to 00 it
will be ignore and more than one result could be found, in that
case it will return null.
- See Also:
IAdmDao.getAdm(String, String, String, String, String)
getAdm
public Adm getAdm(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
- Description copied from interface:
IAdmDao
- Retrieve the Adm of the highest level according to the AdmXcode. The
level will be determine with the highest AdmXcode which is not null (e.g :
if adm1 and adm2 are not null, and adm3 and adm4 are null then the Adm of
Level 2 will be retrieved) This method is a wrapper around
IAdmDao.getAdm1(String, String)
,
IAdmDao.getAdm2(String, String, String)
,
IAdmDao.getAdm3(String, String, String, String)
, and
IAdmDao.getAdm4(String, String, String, String, String)
. Use This
Method ONLY if you've got some AdmXcode and you don't know the Level.
you'll have better performance with the getAdmX() methods.
- Specified by:
getAdm
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieveadm3Code
- The Adm3Code of the Adm to retrieveadm4Code
- The Adm4Code of the Adm to retrieve NOTE : The
countryCode will be automaticaly converted in upperCase
- Returns:
- The Adm with the specified countrycode, adm1Code, adm2Code,
adm3Code and adm4Code
- See Also:
IAdmDao.getAdm1(String, String)
,
IAdmDao.getAdm2(String, String, String)
,
IAdmDao.getAdm3(String, String, String, String)
,
IAdmDao.getAdm4(String, String, String, String, String)
,
IAdmDao.getAdmByCountryAndCodeAndLevel(String, String, int)
,
Adm.getProcessedLevelFromCodes(String, String, String, String)
getUnused
public java.util.List<Adm> getUnused()
- Specified by:
getUnused
in interface IAdmDao
- Returns:
- Adm Which are not used by any GisFeature
getDirties
public java.util.List<Adm> getDirties()
- Description copied from interface:
IGisDao
- Returns inconsistant object (in most case object With featureid < 0)
- Specified by:
getDirties
in interface IGisDao<Adm>
- Overrides:
getDirties
in class GenericGisDao<Adm>
- Returns:
- List of populated objects (never return null, but an empty list)
getAllbyLevel
public java.util.List<Adm> getAllbyLevel(int level)
- Specified by:
getAllbyLevel
in interface IAdmDao
- Parameters:
level
- The level of the Adms to retrieve. The Level is not
checked (not necessary beetween 1 and 4)
- Returns:
- all the Adm for the specified level or an Empty List if no Adm
are found
countByLevel
public long countByLevel(int level)
- Specified by:
countByLevel
in interface IAdmDao
- Parameters:
level
- The level we want the Adm to count The Level is not
checked (not necessary beetween 1 and 4)
- Returns:
- how many Adm exists for the specified level
getAdmByCountryAndCodeAndLevel
public java.util.List<Adm> getAdmByCountryAndCodeAndLevel(java.lang.String countryCode,
java.lang.String admCode,
int level)
- Description copied from interface:
IAdmDao
- Returns The Adm with the specified code and the specified level for the
specified country code. The level determine the admXcode to search for.
(e.g : if level=3 and admCode="C3", the adm with level 3 and adm3Code=c3"
will be retrieved from the datastore NOTE : The countryCode will
be automaticaly converted in upperCase
- Specified by:
getAdmByCountryAndCodeAndLevel
in interface IAdmDao
- Parameters:
countryCode
- The countryCode that the Adm must belongs toadmCode
- The code of the Adm for the specified levellevel
- The level of the Adm : The Level is not checked (not
necessary beetween 1 and 4)
- Returns:
- The list of Adm with the specified code and the specified level
for the specified country code, never return null but an empty
list
getAdmOrFirstValidParentIfNotFound
public Adm getAdmOrFirstValidParentIfNotFound(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code)
- Description copied from interface:
IAdmDao
- Return The Adm for the specified Code in the same way of
IAdmDao.getAdm(String, String, String, String, String)
or the first
valid parent if no Adm is found with the specified codes.
e.g : If no Adm is found with adm1code="AA", adm2Code="BB", and
Adm3Code="CC" but if it exist an Adm with level 2 with the specified
Adm1Code or Adm2Code : the adm with level 2 will be return. If no adm2 is
found and there is an existing Adm with level 1 and adm1code="AA" : the
adm with level 1 will be return this method is to used when you want to
do error correcting (see also
IAdmDao.suggestMostAccurateAdm(String, String, String, String, String, GisFeature)
- Specified by:
getAdmOrFirstValidParentIfNotFound
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieveadm3Code
- The Adm3Code of the Adm to retrieveadm4Code
- The Adm4Code of the Adm to retrieve
- Returns:
- The Adm for the specified Code in the same way of
IAdmDao.getAdm(String, String, String, String, String)
or the
first valid parent if no Adm is found with the specified codes - See Also:
IAdmDao.getAdmByCountryAndCodeAndLevel(String, String, int)
,
Adm.getProcessedLevelFromCodes(String, String, String, String)
suggestMostAccurateAdm
public Adm suggestMostAccurateAdm(java.lang.String countryCode,
java.lang.String adm1Code,
java.lang.String adm2Code,
java.lang.String adm3Code,
java.lang.String adm4Code,
GisFeature gisfeature)
- Description copied from interface:
IAdmDao
- This method is used when
ImporterConfig.isTryToDetectAdmIfNotFound()
is true or when error
correction is needed. the algorithm will return an Adm according the
specified rules:
- If an Adm with the specified code is found (see
IAdmDao.getAdm(String, String, String, String, String)
) : retrun it
- If an Adm with the highest not null level is found for the specified
country (e.g : if adm1,2,3 are specified and adm4 is null and it exist an
adm with level 3 for the specified adm3Code then it will be return)
- If No Adm with the highest not null level is found for the specified
country
- Specified by:
suggestMostAccurateAdm
in interface IAdmDao
- Parameters:
countryCode
- The country code of the Adm to retrieveadm1Code
- The Adm1Code of the Adm to retrieveadm2Code
- The Adm2Code of the Adm to retrieveadm3Code
- The Adm3Code of the Adm to retrieveadm4Code
- The Adm4Code of the Adm to retrievegisfeature
- The gisFeature is not really used in the algorithm, but it
can be useful to have it for logs or for specific
algorithm implementation.(It is only used for logs)
- Returns:
- The most accurate Adm for the gisFeature
- See Also:
IAdmDao.getAdmOrFirstValidParentIfNotFound(String, String, String, String,
String)
deleteAllByLevel
public int deleteAllByLevel(int level)
- Specified by:
deleteAllByLevel
in interface IAdmDao
- Parameters:
level
- the level we want to delete Adm return the number of
deleted Adm
listFeatureIdByLevel
public java.util.List<java.lang.Long> listFeatureIdByLevel(int level)
- Description copied from interface:
IAdmDao
- List all the featureId of the Adms of a specified level
- Specified by:
listFeatureIdByLevel
in interface IAdmDao
- Parameters:
level
- the level
- Returns:
- a list of all featureId
Copyright © 2010. All Rights Reserved.