|
|
|
@ -33,38 +33,29 @@ interface IotHubInstalledItemRepository extends JpaRepository<IotHubInstalledIte |
|
|
|
List<UUID> findInstalledItemIdsByTenantIdAndItemIdIn(@Param("tenantId") UUID tenantId, |
|
|
|
@Param("itemIds") Collection<UUID> itemIds); |
|
|
|
|
|
|
|
@Query(""" |
|
|
|
SELECT item FROM IotHubInstalledItemEntity item |
|
|
|
WHERE item.tenantId = :tenantId |
|
|
|
AND (:itemTypes IS NULL OR item.itemType IN :itemTypes) |
|
|
|
AND (:itemId IS NULL OR item.itemId = :itemId) |
|
|
|
AND (:textSearch IS NULL |
|
|
|
OR ilike(item.itemName, CONCAT('%', :textSearch, '%')) = true |
|
|
|
OR ilike(item.itemType, CONCAT('%', :textSearch, '%')) = true |
|
|
|
OR ilike(item.version, CONCAT('%', :textSearch, '%')) = true) |
|
|
|
""") |
|
|
|
Page<IotHubInstalledItemEntity> findByTenantId(@Param("tenantId") UUID tenantId, @Param("itemTypes") List<String> itemTypes, @Param("itemId") UUID itemId, @Param("textSearch") String textSearch, Pageable pageable); |
|
|
|
|
|
|
|
/** |
|
|
|
* As {@link #findByTenantId}, only the items with an update: an item of {@code publishedItemIds} whose installed version |
|
|
|
* is not among {@code publishedVersionIds}. Version ids are unique, so this is "not the published version of its item". |
|
|
|
* The tenant's installed items, by type, item and text. With {@code updatesOnly}, only the items with an update: an item |
|
|
|
* of {@code publishedItemIds} whose installed version is not among {@code publishedVersionIds} (version ids are unique, |
|
|
|
* so: not the published version of its item). A flag, as Hibernate can't type {@code :uuids IS NULL}. |
|
|
|
*/ |
|
|
|
@Query(""" |
|
|
|
SELECT item FROM IotHubInstalledItemEntity item |
|
|
|
WHERE item.tenantId = :tenantId |
|
|
|
AND item.itemId IN :publishedItemIds |
|
|
|
AND item.itemVersionId NOT IN :publishedVersionIds |
|
|
|
AND (:itemTypes IS NULL OR item.itemType IN :itemTypes) |
|
|
|
AND (:itemId IS NULL OR item.itemId = :itemId) |
|
|
|
AND (:updatesOnly = false |
|
|
|
OR (item.itemId IN :publishedItemIds AND item.itemVersionId NOT IN :publishedVersionIds)) |
|
|
|
AND (:textSearch IS NULL |
|
|
|
OR ilike(item.itemName, CONCAT('%', :textSearch, '%')) = true |
|
|
|
OR ilike(item.itemType, CONCAT('%', :textSearch, '%')) = true |
|
|
|
OR ilike(item.version, CONCAT('%', :textSearch, '%')) = true) |
|
|
|
""") |
|
|
|
Page<IotHubInstalledItemEntity> findByTenantIdWithUpdates(@Param("tenantId") UUID tenantId, @Param("itemTypes") List<String> itemTypes, |
|
|
|
@Param("textSearch") String textSearch, |
|
|
|
@Param("publishedItemIds") Collection<UUID> publishedItemIds, |
|
|
|
@Param("publishedVersionIds") Collection<UUID> publishedVersionIds, |
|
|
|
Pageable pageable); |
|
|
|
Page<IotHubInstalledItemEntity> findByTenantId(@Param("tenantId") UUID tenantId, @Param("itemTypes") List<String> itemTypes, |
|
|
|
@Param("itemId") UUID itemId, @Param("textSearch") String textSearch, |
|
|
|
@Param("updatesOnly") boolean updatesOnly, |
|
|
|
@Param("publishedItemIds") Collection<UUID> publishedItemIds, |
|
|
|
@Param("publishedVersionIds") Collection<UUID> publishedVersionIds, |
|
|
|
Pageable pageable); |
|
|
|
|
|
|
|
@Query(""" |
|
|
|
SELECT COUNT(item) FROM IotHubInstalledItemEntity item |
|
|
|
|