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
-
Constructor Summary
ConstructorDescriptionTimescaleBackedEntityRepository
(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.int
Get 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:EntityRepository
Retrieve the entity from the db.- Specified by:
findById
in 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:EntityRepository
Find all attributes of an entity in the define timeframe- Specified by:
findAttributeByEntityId
in 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:EntityRepository
Get the limit to be used for the given configuration- Specified by:
getLimit
in 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:EntityRepository
Query for timeframe and entityIds where all query elements are fulfilled.- Specified by:
findEntityIdsAndTimeframesByQuery
in interfaceEntityRepository
idPattern
- 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:EntityRepository
Count the number of entityId results for the given query- Specified by:
getCount
in interfaceEntityRepository
idPattern
- 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:EntityRepository
Get the pagination information for the given query.- Specified by:
getPaginationInfo
in interfaceEntityRepository
-
findSubAttributeInstancesForAttributeAndEntity
public List<SubAttribute> findSubAttributeInstancesForAttributeAndEntity(String entityId, String attributeInstanceId, int limit, boolean backwards) Description copied from interface:EntityRepository
Return all sub attribute instances for the given attribute instance- Specified by:
findSubAttributeInstancesForAttributeAndEntity
in 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:EntityRepository
Find all attributes for the given entities in that timequery.- Specified by:
findAttributesByEntityIds
in 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:EntityRepository
Get the list of timestamps that have opMode "create" for the given attribute.- Specified by:
getCreatedAtForAttribute
in 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:EntityRepository
Return an entity in case there are any instances of the entity in timescale db.- Specified by:
getEntityIfExists
in interfaceEntityRepository
- Parameters:
entityId
- id of the entity to check- Returns:
- NgsiEntity if one exists
-