Class LocationQuery


  • public abstract class LocationQuery
    extends Object

    Query to search locations.

    Use % as placeholder to match any string. E.g. Baar% will match Baar but also Baarerstrasse.

    Example:

     
     import ch.ivyteam.ivy.location.ILocation;
     import ch.ivyteam.ivy.location.ILocation.Type;
     ILocation location = ivy.session.getSessionUser().locations().search().type(Type.USER_POSITION).orderBy().timestamp().descending().findFirst();
     if (location != null)
     {
       ivy.log.info("Last known position of user "+ivy.session.getSessionUserName()+" was "+location.getPosition());
     }
    API:
    This is a public API.
    • Method Detail

      • type

        public LocationQuery type​(String type)

        Filters the search result for locations with the given type.

        Use % as placeholder to match any string

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         import ch.ivyteam.ivy.location.ILocation.Type;
         List<ILocation> locations = ivy.session.getSessionUser().locations().search().type(Type.USER_POSITION).findAll();
         
        Parameters:
        type - the type to search for. May contain % as placeholder
        Returns:
        query
        See Also:
        ILocation.getType(), ILocation.Type
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • name

        public LocationQuery name​(String name)

        Filters the search result for locations with the given name.

        Use % as placeholder to match any string

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         List<ILocation> locations = ivy.session.getSessionUser().locations().search().name("%Church%").findAll();
         
        Parameters:
        name - the name to search for. May contain % as placeholder
        Returns:
        query
        See Also:
        ILocation.getName()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • address

        public LocationQuery address​(String address)

        Filters the search result for locations with the given address.

        Use % as placeholder to match any string

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         List<ILocation> locations = ivy.session.getSessionUser().locations().search().address("%Zug%").findAll();
         
        Parameters:
        address - the address to search for. May contain % as placeholder
        Returns:
        query
        See Also:
        ILocation.getAddress()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • note

        public LocationQuery note​(String note)

        Filters the search result for locations with the given note.

        Use % as placeholder to match any string

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         List<ILocation> locations = ivy.session.getSessionUser().locations().search().note("%Mobile App%").findAll();
         
        Parameters:
        note - the note to search for. May contain % as placeholder
        Returns:
        query
        See Also:
        ILocation.getNote()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • nearby

        public LocationQuery nearby​(GeoPosition position,
                                    Distance distance)

        Filters the search result for locations that are within the given distance to the given position.

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         import ch.ivyteam.ivy.location.GeoPosition;
         import ch.ivyteam.ivy.location.Distance;
         
         GeoPosition ivyTeamOffice = GeoPosition.inDegrees(47.171573, 8.516835);
         Distance walkDistance = Distance.inMeters(500.0);
         
         List<ILocation> restaurants = ivy.session.getSessionUser().locations().search().nearby(ivyTeamOffice, walkDistance).findAll();
         
        Parameters:
        position - the position the locations to search for must be near by.
        distance - the maximum distance the locations to search for must be away from the given position.
        Returns:
        query
        See Also:
        ILocation.getPosition()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • orderBy

        public LocationQuery.LocationOrder orderBy()

        Orders the results of the query.

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         ILocation latestLocation = ivy.session.getSessionUser().locations().search().orderBy().timestamp().descending().findFirst();
         
        Returns:
        order
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • findFirst

        public ILocation findFirst()

        Finds a location that matches the filter criteria and is at top position in the order specified with orderBy().

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         ILocation ivyTeamHQ = ivy.session.getSessionUser().locations().search().name("ivyTeam Headquarter").findFirst();
         
        Returns:
        first location that matches the filter criteria in the specified order. Null if no location matches the filter.
        See Also:
        findAll(), findLatest()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • findLatest

        public ILocation findLatest()

        Finds a location that matches the filter criteria and is the latest location available.

        ivy.session.getSessionUser.locations().search().findLatest() is the same as
        ivy.session.getSessionUser().locations().search().orderBy().timestamp().descending().findFirst()

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         ILocation latestLocation = ivy.session.getSessionUser().locations().search().findLatest();
         
        Returns:
        latest location that matches the filter criteria. Null if no location matches the filter.
        See Also:
        findAll(), findFirst()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • findAll

        public List<ILocation> findAll()

        Finds all locations that match the filter criteria. The list is ordered as specified with orderBy().

        Example:

         
         import ch.ivyteam.ivy.location.ILocation;
         List<ILocation> allLocations = ivy.session.getSessionUser().locations().search().findAll();
         
        Returns:
        all locations that match the filter criteria in the specified order
        See Also:
        findFirst(), findLatest()
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.