@Test public void testFindAssetsByTenantIdAndCustomerId() { UUID tenantId1 = UUIDs.timeBased(); UUID tenantId2 = UUIDs.timeBased(); UUID customerId1 = UUIDs.timeBased(); UUID customerId2 = UUIDs.timeBased(); for (int i = 0; i < 60; i++) { UUID assetId = UUIDs.timeBased(); UUID tenantId = i % 2 == 0 ? tenantId1 : tenantId2; UUID customerId = i % 2 == 0 ? customerId1 : customerId2; saveAsset(assetId, tenantId, customerId, "ASSET_" + i, "TYPE_1"); } TextPageLink pageLink1 = new TextPageLink(20, "ASSET_"); List<Asset> assets1 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink1); assertEquals(20, assets1.size()); TextPageLink pageLink2 = new TextPageLink(20, "ASSET_", assets1.get(19).getId().getId(), null); List<Asset> assets2 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink2); assertEquals(10, assets2.size()); TextPageLink pageLink3 = new TextPageLink(20, "ASSET_", assets2.get(9).getId().getId(), null); List<Asset> assets3 = assetDao.findAssetsByTenantIdAndCustomerId(tenantId1, customerId1, pageLink3); assertEquals(0, assets3.size()); }
@Override public List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { return DaoUtil.convertDataList(assetRepository .findByTenantIdAndCustomerId( fromTimeUUID(tenantId), fromTimeUUID(customerId), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { return DaoUtil.convertDataList(assetRepository .findByTenantIdAndCustomerId( fromTimeUUID(tenantId), fromTimeUUID(customerId), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); } }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { return DaoUtil.convertDataList(assetRepository .findByTenantIdAndCustomerId( fromTimeUUID(tenantId), fromTimeUUID(customerId), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); }  }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { return DaoUtil.convertDataList(assetRepository .findByTenantIdAndCustomerId( fromTimeUUID(tenantId), fromTimeUUID(customerId), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); }  @Override List<Asset> findAssetsByTenantId(UUID tenantId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds); @Override List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds); @Override Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name); @Override List<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); @Override List<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId); }
JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> implements AssetDao { @Override public List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink) { return DaoUtil.convertDataList(assetRepository .findByTenantIdAndCustomerId( fromTimeUUID(tenantId), fromTimeUUID(customerId), Objects.toString(pageLink.getTextSearch(), ""), pageLink.getIdOffset() == null ? NULL_UUID_STR : fromTimeUUID(pageLink.getIdOffset()), new PageRequest(0, pageLink.getLimit()))); }  @Override List<Asset> findAssetsByTenantId(UUID tenantId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds); @Override List<Asset> findAssetsByTenantIdAndCustomerId(UUID tenantId, UUID customerId, TextPageLink pageLink); @Override ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds); @Override Optional<Asset> findAssetsByTenantIdAndName(UUID tenantId, String name); @Override List<Asset> findAssetsByTenantIdAndType(UUID tenantId, String type, TextPageLink pageLink); @Override List<Asset> findAssetsByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, TextPageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantAssetTypesAsync(UUID tenantId);  }