Interface EntityRepository

All Known Implementing Classes:
TimescaleBackedEntityRepository

public interface EntityRepository
Interface for entity retrieval
  • Method Details

    • findById

      Optional<NgsiEntity> findById(String entityId, TimeQuery timeQuery)
      Retrieve the entity from the db.
      Parameters:
      entityId - id of the entity to retrieve
      Returns:
      optional entity
    • findAttributeByEntityId

      LimitableResult<List<Attribute>> findAttributeByEntityId(String entityId, TimeQuery timeQuery, List<String> attributes, Integer limit, boolean backwards)
      Find all attributes of an entity in the define timeframe
      Parameters:
      entityId - id to get attributes for
      timeQuery - time related query
      attributes - the attributes to be included, if null or empty return all
      Returns:
      list of attribute instances
    • getLimit

      int getLimit(int entitiesNumber, int attributesNumber, Integer lastN)
      Get the limit to be used for the given configuration
      Parameters:
      entitiesNumber - - entities to be returned
      attributesNumber - - attributes to be returned per entity
      lastN - - number of last values to be returned
      Returns:
      the limit to apply
    • findEntityIdsAndTimeframesByQuery

      List<EntityIdTempResults> findEntityIdsAndTimeframesByQuery(Optional<List<String>> idList, Optional<String> idPattern, List<String> types, TimeQuery timeQuery, Optional<GeoQuery> geoQuery, Optional<QueryTerm> queryTerm, int pageSize, Optional<String> anchor)
      Query for timeframe and entityIds where all query elements are fulfilled.
      Parameters:
      idPattern - pattern to check ids
      types - types to include
      timeQuery - timeframe definition
      geoQuery - geo related query
      queryTerm - ngsi query
      Returns:
      the list of entityIds and there timeframes
    • getCount

      Number getCount(Optional<List<String>> idList, Optional<String> idPattern, List<String> types, TimeQuery timeQuery, Optional<GeoQuery> geoQuery, Optional<QueryTerm> queryTerm)
      Count the number of entityId results for the given query
      Parameters:
      idPattern - pattern to check ids
      types - types to include
      timeQuery - timeframe definition
      geoQuery - geo related query
      queryTerm - ngsi query
      Returns:
      number of matching entities
    • getPaginationInfo

      PaginationInformation getPaginationInfo(Optional<List<String>> idList, Optional<String> idPattern, List<String> types, TimeQuery timeQuery, Optional<GeoQuery> geoQuery, Optional<QueryTerm> queryTerm, int pageSize, Optional<String> anchor)
      Get the pagination information for the given query.
    • findSubAttributeInstancesForAttributeAndEntity

      List<SubAttribute> findSubAttributeInstancesForAttributeAndEntity(String entityId, String attributeInstanceId, int limit, boolean backwards)
      Return all sub attribute instances for the given attribute instance
      Parameters:
      entityId - entity the attributes and subattributes are connected to
      attributeInstanceId - id of the concrete attribute
      limit - number of instances to be retrieved
      backwards - should the instances be retrieved in reversed order.
      Returns:
      list of subattribute instances
    • findAttributesByEntityIds

      List<String> findAttributesByEntityIds(List<String> entityIds, String timeQueryPart)
      Find all attributes for the given entities in that timequery.
      Parameters:
      entityIds - entities to be associated with the attributes
      timeQueryPart - timeframe to search for
      Returns:
      list of attributes
    • getCreatedAtForAttribute

      List<Instant> getCreatedAtForAttribute(String attributeId, String entityId, boolean isSubAttribute)
      Get the list of timestamps that have opMode "create" for the given attribute.
      Parameters:
      attributeId - id of the attribute to find the timestamps for
      entityId - id of the entity that are connected with the attribute
      isSubAttribute - is the requestend attribute an attribute or a subattribute
      Returns:
      the list of timestamps
    • getEntityIfExists

      Optional<NgsiEntity> getEntityIfExists(String entityId)
      Return an entity in case there are any instances of the entity in timescale db.
      Parameters:
      entityId - id of the entity to check
      Returns:
      NgsiEntity if one exists