com.gisgraphy.domain.repository

## Class GenericGisDao<T extends GisFeature>

- java.lang.Object
- - org.springframework.dao.support.DaoSupport
  - - org.springframework.orm.hibernate3.support.HibernateDaoSupport
    - - com.gisgraphy.domain.repository.GenericDao<T,Long>
      - - com.gisgraphy.domain.repository.GenericGisDao<T>

- Type Parameters:
    `T` -
  All Implemented Interfaces:
    IDao<T,Long>, IGisDao<T>, org.springframework.beans.factory.InitializingBean
  Direct Known Subclasses:
    AdmBuildingDao, AdmDao, AirportDao, AmbulanceDao, AmuseParkDao, AqueducDao, ATMDao, BankDao, BarDao, BayDao, BeachDao, BenchDao, BridgeDao, BuildingDao, BusStationDao, CampDao, CampingDao, CanyonDao, CasinoDao, CastleDao, CaveDao, CemeteryDao, CinemaDao, CirqueDao, CityDao, CityHallDao, CitySubdivisionDao, CliffDao, CoastDao, ContinentDao, CountryDao, CourtHouseDao, CraftDao, CustomsPostDao, DamDao, DentistDao, DesertDao, DoctorDao, EmergencyPhoneDao, FactoryDao, FallsDao, FarmDao, FerryTerminalDao, FieldDao, FireStationDao, FishingAreaDao, FjordDao, ForestDao, FountainDao, FuelDao, GardenDao, GisFeatureDao, GolfDao, GorgeDao, GrassLandDao, GulfDao, HillDao, HospitalDao, HotelDao, HouseDao, IceDao, IslandDao, LakeDao, LibraryDao, LightHouseDao, MallDao, MarshDao, MetroStationDao, MilitaryDao, MillDao, MineDao, MoleDao, MonumentDao, MoundDao, MountainDao, MuseumDao, NightClubDao, OasisDao, ObservatoryPointDao, OceanDao, OperaHouseDao, ParkDao, ParkingDao, PharmacyDao, PicnicDao, PlantationDao, PolicePostDao, PoliticalEntityDao, PondDao, PortDao, PostOfficeDao, PrisonDao, PyramidDao, QuayDao, RailDao, RailRoadStationDao, RanchDao, RavinDao, ReefDao, ReligiousDao, RentalDao, ReserveDao, RestAreaDao, RestaurantDao, RoadDao, SchoolDao, SeaDao, ShopDao, SportDao, SpringDao, StadiumDao, StraitDao, StreamDao, StreetDao, SwimmingPoolDao, TaxiDao, TelephoneDao, TheaterDao, ToiletDao, TourismDao, TourismInfoDao, TowerDao, TreeDao, TunnelDao, UnderSeaDao, VendingMachineDao, VeterinaryDao, VineyardDao, VolcanoDao, WaterBodyDao, ZooDao

      public class GenericGisDao<T extends GisFeature>
      extends GenericDao<T,Long>
      implements IGisDao<T>

  Author:
    gisgraphy

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static org.hibernate.type.Type` | `GEOMETRY_TYPE`
    `static int` | `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

    Constructors
    Constructor and Description
    `GenericGisDao(Class<T> persistentClass)` Constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `createGISTIndexForLocationColumn()` Create the database GIST index for the column 'location' for this entity if it doesn't already exists
    `void` | `createGISTIndexForShapeColumn()` create the shape index for the entity if it doesn't already exists.
    `int` | `deleteAll()` Delete all the object from the datastore
    `void` | `deleteAll(List<T> list)` Delete all the specified object from the datastore
    `T` | `getByFeatureId(Long featureId)` It is not the same as `IDao.get(java.io.Serializable)` which retrieve an object from his PK.
    `List<T>` | `getDirties()` Returns inconsistant object (in most case object With featureid < 0)
    `T` | `getEager(Long id)` Same as IDao#get(java.io.Serializable) but load the AlternateNames and The linked Adm
    `T` | `getNearest(com.vividsolutions.jts.geom.Point location, String countryCode, boolean filterMunicipality, int distance)`
    `List<com.gisgraphy.domain.valueobject.GisFeatureDistance>` | `getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point, double distance)` same as `IGisDao.getNearestAndDistanceFromGisFeature(GisFeature, double, int, int, boolean)` but without paginate
    `List<com.gisgraphy.domain.valueobject.GisFeatureDistance>` | `getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point, double distance, int firstResult, int maxResults, boolean includeDistanceField, boolean isMunicipality)`
    `protected List<com.gisgraphy.domain.valueobject.GisFeatureDistance>` | `getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point, Long pointId, double distance, int firstResult, int maxResults, boolean includeDistanceField, Class<? extends GisFeature> requiredClass, boolean isMunicipality)` base method for all findNearest*
    `List<com.gisgraphy.domain.valueobject.GisFeatureDistance>` | `getNearestAndDistanceFromGisFeature(GisFeature gisFeature, double distance, boolean includeDistanceField)`
    `List<com.gisgraphy.domain.valueobject.GisFeatureDistance>` | `getNearestAndDistanceFromGisFeature(GisFeature gisFeature, double distance, int firstResult, int maxResults, boolean includeDistanceField)`
    `String` | `getShapeAsWKTByFeatureId(Long featureId)`
    `List<T>` | `listByFeatureIds(List<Long> ids)` return all the Object with the specified featureIds (not ids :id is the PK (aka datastore id), featureId is the domain value). return an emptylist if the list of ids is null or empty).
    `List<T>` | `listByName(String name)` retrieve the Objects with the specified name (not the ASCII one)
    `List<T>` | `listFromText(String name, boolean includeAlternateNames)` Do a full text search for the given name.
    `protected List<T>` | `listFromText(String name, boolean includeAlternateNames, Class<T> clazz)` Do a full text search for the given name.
    `void` | `remove(T gisFeature)` remove the object from the datastore
    `T` | `save(T GisFeature)` Saves the passed object, and returns an attached entity.
    `void` | `setEventManager(EventManager eventManager)`

    - ### 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.IDao

      `count, exists, flushAndClear, get, getAll, getAllPaginate, getPersistenceClass, setFlushMode`

- - ### Field Detail

    - #### GEOMETRY_TYPE

          public static final org.hibernate.type.Type GEOMETRY_TYPE

    - #### MAX_FULLTEXT_RESULTS

          public static final int MAX_FULLTEXT_RESULTS

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### GenericGisDao

          public GenericGisDao(Class<T> persistentClass)

      Constructor
      Parameters:
        `persistentClass` - The specified Class for the GenericGisDao

  - ### Method Detail

    - #### getNearestAndDistanceFromGisFeature

          public List<com.gisgraphy.domain.valueobject.GisFeatureDistance> getNearestAndDistanceFromGisFeature(GisFeature gisFeature,
                                                                                                      double distance,
                                                                                                      int firstResult,
                                                                                                      int maxResults,
                                                                                                      boolean includeDistanceField)

      Specified by:
        `getNearestAndDistanceFromGisFeature` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `gisFeature` - The GisFeature from which we want to find GIS Object
        `distance` - distance The radius in meters
        `firstResult` - the firstResult index (for pagination), numbered from 1, if < 1 : it will not be taken into account
        `maxResults` - The Maximum number of results to retrieve (for pagination), if <= 0 : it will not be taken into acount
        `includeDistanceField` - Field whether or not we should process calculate the distance
      Returns:
        A List of GisFeatureDistance with the nearest elements or an emptylist (never return null), ordered by distance. note the specified gisFeature will not be included into results the results will be of the type of the currentDao
        tips : to search the nearest place use firstresult=1 and maxResults=1
      See Also:
        `GisFeatureDistance`

    - #### getNearestAndDistanceFromGisFeature

          public List<com.gisgraphy.domain.valueobject.GisFeatureDistance> getNearestAndDistanceFromGisFeature(GisFeature gisFeature,
                                                                                                      double distance,
                                                                                                      boolean includeDistanceField)

      Specified by:
        `getNearestAndDistanceFromGisFeature` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `gisFeature` - The GisFeature from which we want to find GIS Object
        `distance` - distance The radius in meters
        `includeDistanceField` - Field whether or not we should process calculate the distance
      Returns:
        A List of GisFeatureDistance with the nearest elements or an emptylist (never return null), ordered by distance. note the specified gisFeature will not be included into results the results will be of the type of the currentDao
      See Also:
        `GisFeatureDistance`

    - #### getNearestAndDistanceFrom

          public List<com.gisgraphy.domain.valueobject.GisFeatureDistance> getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point,
                                                                                            double distance)

      Description copied from interface: `IGisDao`
      same as `IGisDao.getNearestAndDistanceFromGisFeature(GisFeature, double, int, int, boolean)` but without paginate
      Specified by:
        `getNearestAndDistanceFrom` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `point` - The point from which we want to find GIS Object
        `distance` - distance The radius in meters
      Returns:
        A List of GisFeatureDistance with the nearest elements or an emptylist (never return null), ordered by distance. note the specified gisFeature will not be included into results the results will be of the type of the currentDao
      See Also:
        `GisFeatureDistance`

    - #### getNearestAndDistanceFrom

          public List<com.gisgraphy.domain.valueobject.GisFeatureDistance> getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point,
                                                                                            double distance,
                                                                                            int firstResult,
                                                                                            int maxResults,
                                                                                            boolean includeDistanceField,
                                                                                            boolean isMunicipality)

      Specified by:
        `getNearestAndDistanceFrom` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `point` - The point from which we want to find GIS Object
        `distance` - distance The radius in meters
        `firstResult` - the firstResult index (for pagination), numbered from 1, if < 1 : it will not be taken into account
        `maxResults` - The Maximum number of results to retrieve (for pagination), if <= 0 : it will not be taken into acount
        `includeDistanceField` - Field whether or not we should process calculate the distance
        `isMunicipality` - whether we should filter on city that are flag as 'municipality'. act as a filter, if false it doesn't filters( false doesn't mean that we return non municipality)
      Returns:
        A List of GisFeatureDistance with the nearest elements or an emptylist (never return null), ordered by distance. note the specified gisFeature will not be included into results the results will be of the type of the currentDao
        tips: to search the nearest place use firstresult=1 and maxResults=1
      See Also:
        `GisFeatureDistance`

    - #### getNearestAndDistanceFrom

          protected List<com.gisgraphy.domain.valueobject.GisFeatureDistance> getNearestAndDistanceFrom(com.vividsolutions.jts.geom.Point point,
                                                                                            Long pointId,
                                                                                            double distance,
                                                                                            int firstResult,
                                                                                            int maxResults,
                                                                                            boolean includeDistanceField,
                                                                                            Class<? extends GisFeature> requiredClass,
                                                                                            boolean isMunicipality)

      base method for all findNearest*
      Parameters:
        `point` - The point from which we want to find GIS Object
        `pointId` - the id of the point that we don't want to be include, it is used to not include the gisFeature from which we want to find the nearest
        `distance` - distance The radius in meters
        `firstResult` - the firstResult index (for pagination), numbered from 1, if < 1 : it will not be taken into account
        `maxResults` - The Maximum number of results to retrieve (for pagination), if <= 0 : it will not be taken into acount
        `requiredClass` - the class of the object to be retireved
        `isMunicipality` - whether we should filter on city that are flag as 'municipality'. act as a filter, if false it doesn't filters( false doesn't mean that we return non municipality)
      Returns:
        A List of GisFeatureDistance with the nearest elements or an emptylist (never return null), ordered by distance.note the specified gisFeature will not be included into results
      See Also:
        `GisFeatureDistance`

    - #### listByName

          public List<T> listByName(String name)

      Description copied from interface: `IGisDao`
      retrieve the Objects with the specified name (not the ASCII one)
      Specified by:
        `listByName` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `name` - the name of the objects to retrieve
      Returns:
        List of populated objects list (never return null, but an empty list)
      See Also:
        `IGisDao.listFromText(String, boolean)`

    - #### getByFeatureId

          public T getByFeatureId(Long featureId)

      Description copied from interface: `IGisDao`
      It is not the same as `IDao.get(java.io.Serializable)` which retrieve an object from his PK.
      Specified by:
        `getByFeatureId` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `featureId` - the featureid of the GIS object to retrieve
      Returns:
        the Gis Object with the specified GisFeature id.

    - #### getDirties

          public List<T> getDirties()

      Description copied from interface: `IGisDao`
      Returns inconsistant object (in most case object With featureid < 0)
      Specified by:
        `getDirties` in interface `IGisDao<T extends GisFeature>`
      Returns:
        List of populated objects (never return null, but an empty list)

    - #### save

          public T save(T GisFeature)

      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<T extends GisFeature,Long>`
      Overrides:
        `save` in class `GenericDao<T extends GisFeature,Long>`
      Parameters:
        `GisFeature` - The object to save
      Returns:
        The saved instance

    - #### remove

          public void remove(T gisFeature)

      Description copied from interface: `IDao`
      remove the object from the datastore
      Specified by:
        `remove` in interface `IDao<T extends GisFeature,Long>`
      Overrides:
        `remove` in class `GenericDao<T extends GisFeature,Long>`
      Parameters:
        `gisFeature` - The object to remove

    - #### listByFeatureIds

          public List<T> listByFeatureIds(List<Long> ids)

      Description copied from interface: `IGisDao`
      return all the Object with the specified featureIds (not ids :id is the PK (aka datastore id), featureId is the domain value). return an emptylist if the list of ids is null or empty). The features will be of the type of the Dao.
      Specified by:
        `listByFeatureIds` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `ids` - the list of the ids of the object to retrieve
      Returns:
        List of populated objects list (never return null, but an empty list)

    - #### listFromText

          public List<T> listFromText(String name,
                             boolean includeAlternateNames)

      Description copied from interface: `IGisDao`
      Do a full text search for the given name. The search will be case, iso-latin, comma-separated insensitive
      search for 'saint-André', 'saint-Andre', 'SaInT-andré', 'st-andré', etc will return the same results Polymorphism is not supported, e.g : if you use gisfeatureDao the results will only be of that type and no feature of type City that extends gisFeature...etc will be returned.
      Specified by:
        `listFromText` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `name` - the name or zipcode of the GisFeature to search
        `includeAlternateNames` - whether we search in the alternatenames too
      Returns:
        a list of gisFeatures of type of the class for the given text. the max list size is `MAX_FULLTEXT_RESULTS`;
      See Also:
        `IGisFeatureDao.listAllFeaturesFromText(String, boolean)`

    - #### listFromText

          protected List<T> listFromText(String name,
                             boolean includeAlternateNames,
                             Class<T> clazz)

      Do a full text search for the given name. The search will be case, iso-latin, comma-separated insensitive
      search for 'saint-André', 'saint-Andre', 'SaInT-andré', 'st-andré', etc will return the same results. note : search for zipcode too Polymorphism is not supported, e.g : if clazz=GisFeature : the results will only be of that type and no other feature type (e.g : City that extends gisFeature...etc) will be returned. The results will be sort by relevance.
      Parameters:
        `name` - The name to search for
        `includeAlternateNames` - Wether we search in the alternatenames too
        `clazz` - specify the features we want to search for, if null : no restriction is apply
      Returns:
        a list of gisFeatures of type of the class for the given text. the max list size is `MAX_FULLTEXT_RESULTS`;
      See Also:
        `IGisFeatureDao.listAllFeaturesFromText(String, boolean)`

    - #### deleteAll

          public void deleteAll(List<T> list)

      Description copied from interface: `IDao`
      Delete all the specified object from the datastore
      Specified by:
        `deleteAll` in interface `IDao<T extends GisFeature,Long>`
      Overrides:
        `deleteAll` in class `GenericDao<T extends GisFeature,Long>`
      Parameters:
        `list` - the list of element to delete

    - #### deleteAll

          public int deleteAll()

      Description copied from interface: `IDao`
      Delete all the object from the datastore
      Specified by:
        `deleteAll` in interface `IDao<T extends GisFeature,Long>`
      Overrides:
        `deleteAll` in class `GenericDao<T extends GisFeature,Long>`
      Returns:
        the number of deleted objects

    - #### getEager

          public T getEager(Long id)

      Description copied from interface: `IGisDao`
      Same as IDao#get(java.io.Serializable) but load the AlternateNames and The linked Adm
      Specified by:
        `getEager` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `id` - the id of the features to retrieve
      Returns:
        The Feature with the alternateName and the Adm loaded
      See Also:
        `IDao.get(java.io.Serializable)`

    - #### setEventManager

          public void setEventManager(EventManager eventManager)

    - #### createGISTIndexForLocationColumn

          public void createGISTIndexForLocationColumn()

      Description copied from interface: `IGisDao`
      Create the database GIST index for the column 'location' for this entity if it doesn't already exists
      Specified by:
        `createGISTIndexForLocationColumn` in interface `IGisDao<T extends GisFeature>`

    - #### getNearest

          public T getNearest(com.vividsolutions.jts.geom.Point location,
                     String countryCode,
                     boolean filterMunicipality,
                     int distance)

      Specified by:
        `getNearest` in interface `IGisDao<T extends GisFeature>`
      Parameters:
        `location` - The point from which we want to find GIS Object
        `countryCode` - restrict the search to a given country code (useful for feature near a frontier
        `filterMunicipality` - if we should filter municipality or not
        `distance` - te distance in meter
      Returns:
        the nearest city differ from getnearestAndDistance because doesn't return distance field and with zip and alternateNames are populated

    - #### createGISTIndexForShapeColumn

          public void createGISTIndexForShapeColumn()

      Description copied from interface: `IGisDao`
      create the shape index for the entity if it doesn't already exists.
      Specified by:
        `createGISTIndexForShapeColumn` in interface `IGisDao<T extends GisFeature>`

    - #### getShapeAsWKTByFeatureId

          public String getShapeAsWKTByFeatureId(Long featureId)

      Specified by:
        `getShapeAsWKTByFeatureId` in interface `IGisDao<T extends GisFeature>`
      Returns:
        the shape as wkt or null;

Copyright © 2015. All rights reserved.