com.gisgraphy.domain.repository
Interface IAdmDao

All Superinterfaces:
IDao<Adm,Long>, IGisDao<Adm>
All Known Implementing Classes:
AdmDao

public interface IAdmDao
extends IGisDao<Adm>

Interface for Adm data access

Author:
David Masclet

Method Summary
 long countByLevel(int level)
           
 int deleteAllByLevel(int level)
           
 Adm getAdm(String countryCode, String adm1Code, String adm2Code, String adm3Code, String adm4Code)
          Retrieve the Adm of the highest level according to the AdmXcode.
 Adm getAdm1(String countryCode, String adm1Code)
           
 Adm getAdm2(String countryCode, String adm1Code, String adm2Code)
           
 Adm getAdm3(String countryCode, String adm1Code, String adm2Code, String adm3Code)
           
 Adm getAdm4(String countryCode, String adm1Code, String adm2Code, String adm3Code, String adm4Code)
           
 List<Adm> getAdmByCountryAndCodeAndLevel(String countryCode, String admCode, int level)
          Returns The Adm with the specified code and the specified level for the specified country code.
 Adm getAdmOrFirstValidParentIfNotFound(String countryCode, String adm1Code, String adm2Code, String adm3Code, String adm4Code)
          Return The Adm for the specified Code in the same way of getAdm(String, String, String, String, String) or the first valid parent if no Adm is found with the specified codes.
 List<Adm> getAllbyLevel(int level)
           
 List<Adm> getUnused()
           
 List<Long> listFeatureIdByLevel(int level)
          List all the featureId of the Adms of a specified level
 Adm suggestMostAccurateAdm(String countryCode, String adm1Code, String adm2Code, String adm3Code, 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 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 getAdmOrFirstValidParentIfNotFound(String, String, String, String, String) : return Adm with the highest not null level If a parent Adm is found (see 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 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 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, deleteAll, exists, flushAndClear, get, getAll, getAllPaginate, getPersistenceClass, remove, save, setFlushMode
 

Method Detail

getAllbyLevel

List<Adm> getAllbyLevel(int level)
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

getAdm1

Adm getAdm1(String countryCode,
            String adm1Code)
Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - 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
Throws:
IllegalArgumentException - if any of the parameters are null
See Also:
getAdm(String, String, String, String, String), getAdmByCountryAndCodeAndLevel(String, String, int)

getAdm2

Adm getAdm2(String countryCode,
            String adm1Code,
            String adm2Code)
Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - 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.
Throws:
IllegalArgumentException - if any of the parameters are null
See Also:
getAdm(String, String, String, String, String), getAdmByCountryAndCodeAndLevel(String, String, int)

getAdm3

Adm getAdm3(String countryCode,
            String adm1Code,
            String adm2Code,
            String adm3Code)
Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - The Adm2Code of the Adm to retrieve
adm3Code - 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.
Throws:
IllegalArgumentException - if any of the parameters are null
See Also:
getAdm(String, String, String, String, String), getAdmByCountryAndCodeAndLevel(String, String, int)

getAdm4

Adm getAdm4(String countryCode,
            String adm1Code,
            String adm2Code,
            String adm3Code,
            String adm4Code)
Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - The Adm2Code of the Adm to retrieve
adm3Code - The Adm3Code of the Adm to retrieve
adm4Code - 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.
Throws:
IllegalArgumentException - if any of the parameters are null
See Also:
getAdm(String, String, String, String, String)

getAdm

Adm getAdm(String countryCode,
           String adm1Code,
           String adm2Code,
           String adm3Code,
           String adm4Code)
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 getAdm1(String, String), getAdm2(String, String, String), getAdm3(String, String, String, String), and 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.

Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - The Adm2Code of the Adm to retrieve
adm3Code - The Adm3Code of the Adm to retrieve
adm4Code - 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
Throws:
IllegalArgumentException - if the countryCode is null
See Also:
getAdm1(String, String), getAdm2(String, String, String), getAdm3(String, String, String, String), getAdm4(String, String, String, String, String), getAdmByCountryAndCodeAndLevel(String, String, int), Adm.getProcessedLevelFromCodes(String, String, String, String)

getAdmByCountryAndCodeAndLevel

List<Adm> getAdmByCountryAndCodeAndLevel(String countryCode,
                                         String admCode,
                                         int level)
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

Parameters:
countryCode - The countryCode that the Adm must belongs to
admCode - The code of the Adm for the specified level
level - 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
Throws:
IllegalArgumentException - if countryCode or AdmCode is null

getAdmOrFirstValidParentIfNotFound

Adm getAdmOrFirstValidParentIfNotFound(String countryCode,
                                       String adm1Code,
                                       String adm2Code,
                                       String adm3Code,
                                       String adm4Code)
Return The Adm for the specified Code in the same way of 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 suggestMostAccurateAdm(String, String, String, String, String, GisFeature)

Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - The Adm2Code of the Adm to retrieve
adm3Code - The Adm3Code of the Adm to retrieve
adm4Code - The Adm4Code of the Adm to retrieve
Returns:
The Adm for the specified Code in the same way of getAdm(String, String, String, String, String) or the first valid parent if no Adm is found with the specified codes
Throws:
IllegalArgumentException - if the countryCode is null
See Also:
getAdmByCountryAndCodeAndLevel(String, String, int), Adm.getProcessedLevelFromCodes(String, String, String, String)

suggestMostAccurateAdm

Adm suggestMostAccurateAdm(String countryCode,
                           String adm1Code,
                           String adm2Code,
                           String adm3Code,
                           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:

Parameters:
countryCode - The country code of the Adm to retrieve
adm1Code - The Adm1Code of the Adm to retrieve
adm2Code - The Adm2Code of the Adm to retrieve
adm3Code - The Adm3Code of the Adm to retrieve
adm4Code - The Adm4Code of the Adm to retrieve
gisFeature - 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
Throws:
IllegalArgumentException - if the countryCode is null
See Also:
getAdmOrFirstValidParentIfNotFound(String, String, String, String, String)

countByLevel

long countByLevel(int level)
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

getUnused

List<Adm> getUnused()
Returns:
Adm Which are not used by any GisFeature

deleteAllByLevel

int deleteAllByLevel(int level)
Parameters:
level - the level we want to delete Adm return the number of deleted Adm

listFeatureIdByLevel

List<Long> listFeatureIdByLevel(int level)
List all the featureId of the Adms of a specified level

Parameters:
level - the level
Returns:
a list of all featureId


Copyright © 2012. All Rights Reserved.