Class PersistUtil
java.lang.Object
ch.tocco.nice2.optional.geolocation.api.util.PersistUtil
Utility class for setting and getting position values from entities.
Please consider the methods in here for setting and getting Positions
from entities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PositiongetPosition(Entity entity, String field) Reads aPositionfrom the specified entity assuming the fieldnames for latitude and longitude arefield + "_lat"andfield + "_lng", respectively.static PositiongetPosition(Entity entity, String latField, String lngField) Gets a position from the specified entity by reading the values of its longitude and latitude fields.static voidsetBoundingBoxParameter(Query q, String paramUllat, String paramUllng, String paramLrlat, String paramLrlng, Position[] box) static voidsetDistanceParameters(Query q, String paramLat, String paramLng, Position pos, String paramDst, Distance dst) static voidsetPosition(Entity entity, Position position) Finds two fields of type latitude and longitude of the specified entity and sets the given position into the entity.static voidsetPosition(Entity entity, String field, Position pos) Sets the position value into the entity assuming field names for latitude and longitude to befield + "_lat"andfield + _lng, respecitvely.static voidsetPosition(Entity entity, String latField, String lngField, Position pos) Sets the specified position into the specified entity by setting the latitude and longitude values into the specified fields.
-
Method Details
-
setDistanceParameters
public static void setDistanceParameters(Query q, String paramLat, String paramLng, Position pos, String paramDst, Distance dst) throws PersistException - Throws:
PersistException
-
setBoundingBoxParameter
public static void setBoundingBoxParameter(Query q, String paramUllat, String paramUllng, String paramLrlat, String paramLrlng, Position[] box) throws PersistException - Throws:
PersistException
-
getPosition
public static Position getPosition(Entity entity, String latField, String lngField) throws PersistException Gets a position from the specified entity by reading the values of its longitude and latitude fields.- Parameters:
entity- the entity to read fromlatField- the latitude field name of 'entity'lngField- the longitude field name of 'entity'- Returns:
- a
Positionconsisting of the latitude and longitude as specified - Throws:
PersistException
-
setPosition
public static void setPosition(Entity entity, String latField, String lngField, Position pos) throws PersistException, InterruptedException Sets the specified position into the specified entity by setting the latitude and longitude values into the specified fields.- Parameters:
entity- the entity to write tolatField- the latitude field name of 'entity'lngField- the longitude field name of 'entity'pos- thePositionobject to set- Throws:
PersistExceptionInterruptedException
-
setPosition
public static void setPosition(Entity entity, Position position) throws PersistException, InterruptedException, IllegalArgumentException Finds two fields of type latitude and longitude of the specified entity and sets the given position into the entity. The entity must have exactly one field of type latitude (resp. longitude) for one position, otherwise an exception is thrown. If you know the fieldnames upfront (which is the case most of the time, I guess), considersetPosition(ch.tocco.nice2.persist.core.api.entity.Entity, String, String, Position)as this runs faster.- Throws:
IllegalArgumentException- if no or more than one lat/lng field is found in the entityPersistExceptionInterruptedException
-
setPosition
public static void setPosition(Entity entity, String field, Position pos) throws PersistException, InterruptedException Sets the position value into the entity assuming field names for latitude and longitude to befield + "_lat"andfield + _lng, respecitvely.- Throws:
PersistExceptionInterruptedException
-
getPosition
Reads aPositionfrom the specified entity assuming the fieldnames for latitude and longitude arefield + "_lat"andfield + "_lng", respectively.- Throws:
PersistException
-