Package org.fiware.mintaka.persistence
Class TimescaleBackedEntityRepository
java.lang.Object
org.fiware.mintaka.persistence.TimescaleBackedEntityRepository
- All Implemented Interfaces:
 EntityRepository
Repository implementation for retrieving temporal entity representations from the timescale database
- 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionTimescaleBackedEntityRepository(javax.persistence.EntityManager entityManager)  - 
Method Summary
Modifier and TypeMethodDescriptionfindAttributeByEntityId(String entityId, TimeQuery timeQuery, List<String> attributes, Integer limit, boolean backwards) Find all attributes of an entity in the define timeframefindAttributesByEntityIds(List<String> entityIds, String timeQueryPart) Find all attributes for the given entities in that timequery.Retrieve the entity from the db.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.findSubAttributeInstancesForAttributeAndEntity(String entityId, String attributeInstanceId, int limit, boolean backwards) Return all sub attribute instances for the given attribute instancegetCount(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 querygetCreatedAtForAttribute(String attributeId, String entityId, boolean isSubAttribute) Get the list of timestamps that have opMode "create" for the given attribute.getEntityIfExists(String entityId) Return an entity in case there are any instances of the entity in timescale db.intGet the limit to be used for the given configurationgetPaginationInfo(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. 
- 
Field Details
- 
LOCAL_DATE_TIME_FORMATTER
 - 
EXPECTED_RESULT_SIZE
public static final int EXPECTED_RESULT_SIZE- See Also:
 
 
 - 
 - 
Constructor Details
- 
TimescaleBackedEntityRepository
public TimescaleBackedEntityRepository(@Named("default") javax.persistence.EntityManager entityManager)  
 - 
 - 
Method Details
- 
findById
Description copied from interface:EntityRepositoryRetrieve the entity from the db.- Specified by:
 findByIdin interfaceEntityRepository- Parameters:
 entityId- id of the entity to retrieve- Returns:
 - optional entity
 
 - 
findAttributeByEntityId
public LimitableResult<List<Attribute>> findAttributeByEntityId(String entityId, TimeQuery timeQuery, List<String> attributes, Integer limit, boolean backwards) Description copied from interface:EntityRepositoryFind all attributes of an entity in the define timeframe- Specified by:
 findAttributeByEntityIdin interfaceEntityRepository- Parameters:
 entityId- id to get attributes fortimeQuery- time related queryattributes- the attributes to be included, if null or empty return all- Returns:
 - list of attribute instances
 
 - 
getLimit
Description copied from interface:EntityRepositoryGet the limit to be used for the given configuration- Specified by:
 getLimitin interfaceEntityRepository- Parameters:
 entitiesNumber- - entities to be returnedattributesNumber- - attributes to be returned per entitylastN- - number of last values to be returned- Returns:
 - the limit to apply
 
 - 
findEntityIdsAndTimeframesByQuery
public 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) Description copied from interface:EntityRepositoryQuery for timeframe and entityIds where all query elements are fulfilled.- Specified by:
 findEntityIdsAndTimeframesByQueryin interfaceEntityRepositoryidPattern- pattern to check idstypes- types to includetimeQuery- timeframe definitiongeoQuery- geo related queryqueryTerm- ngsi query- Returns:
 - the list of entityIds and there timeframes
 
 - 
getCount
public Number getCount(Optional<List<String>> idList, Optional<String> idPattern, List<String> types, TimeQuery timeQuery, Optional<GeoQuery> geoQuery, Optional<QueryTerm> queryTerm) Description copied from interface:EntityRepositoryCount the number of entityId results for the given query- Specified by:
 getCountin interfaceEntityRepositoryidPattern- pattern to check idstypes- types to includetimeQuery- timeframe definitiongeoQuery- geo related queryqueryTerm- ngsi query- Returns:
 - number of matching entities
 
 - 
getPaginationInfo
public 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) Description copied from interface:EntityRepositoryGet the pagination information for the given query.- Specified by:
 getPaginationInfoin interfaceEntityRepository
 - 
findSubAttributeInstancesForAttributeAndEntity
public List<SubAttribute> findSubAttributeInstancesForAttributeAndEntity(String entityId, String attributeInstanceId, int limit, boolean backwards) Description copied from interface:EntityRepositoryReturn all sub attribute instances for the given attribute instance- Specified by:
 findSubAttributeInstancesForAttributeAndEntityin interfaceEntityRepository- Parameters:
 entityId- entity the attributes and subattributes are connected toattributeInstanceId- id of the concrete attributelimit- number of instances to be retrievedbackwards- should the instances be retrieved in reversed order.- Returns:
 - list of subattribute instances
 
 - 
findAttributesByEntityIds
Description copied from interface:EntityRepositoryFind all attributes for the given entities in that timequery.- Specified by:
 findAttributesByEntityIdsin interfaceEntityRepository- Parameters:
 entityIds- entities to be associated with the attributestimeQueryPart- timeframe to search for- Returns:
 - list of attributes
 
 - 
getCreatedAtForAttribute
public List<Instant> getCreatedAtForAttribute(String attributeId, String entityId, boolean isSubAttribute) Description copied from interface:EntityRepositoryGet the list of timestamps that have opMode "create" for the given attribute.- Specified by:
 getCreatedAtForAttributein interfaceEntityRepository- Parameters:
 attributeId- id of the attribute to find the timestamps forentityId- id of the entity that are connected with the attributeisSubAttribute- is the requestend attribute an attribute or a subattribute- Returns:
 - the list of timestamps
 
 - 
getEntityIfExists
Description copied from interface:EntityRepositoryReturn an entity in case there are any instances of the entity in timescale db.- Specified by:
 getEntityIfExistsin interfaceEntityRepository- Parameters:
 entityId- id of the entity to check- Returns:
 - NgsiEntity if one exists
 
 
 -