@Test public void testFindDevicesByTenantId() { UUID tenantId1 = Uuids.timeBased(); UUID tenantId2 = Uuids.timeBased(); UUID customerId1 = Uuids.timeBased(); UUID customerId2 = Uuids.timeBased(); createDevices(tenantId1, tenantId2, customerId1, customerId2, 40); PageLink pageLink = new PageLink(15, 0, "SEARCH_TEXT"); PageData<Device> devices1 = deviceDao.findDevicesByTenantId(tenantId1, pageLink); assertEquals(15, devices1.getData().size()); pageLink = pageLink.nextPageLink(); PageData<Device> devices2 = deviceDao.findDevicesByTenantId(tenantId1, pageLink); assertEquals(5, devices2.getData().size()); }
@Override public PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink) { if (StringUtils.isEmpty(pageLink.getTextSearch())) { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, DaoUtil.toPageable(pageLink))); } else { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink) { if (StringUtils.isEmpty(pageLink.getTextSearch())) { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, DaoUtil.toPageable(pageLink))); } else { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } } }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink) { if (StringUtils.isEmpty(pageLink.getTextSearch())) { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, DaoUtil.toPageable(pageLink))); } else { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } }  }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink) { if (StringUtils.isEmpty(pageLink.getTextSearch())) { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, DaoUtil.toPageable(pageLink))); } else { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } }  @Override DeviceInfo findDeviceInfoById(TenantId tenantId, UUID deviceId); @Override PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds); @Override PageData<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndProfileId(UUID tenantId, UUID profileId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds); @Override Optional<Device> findDeviceByTenantIdAndName(UUID tenantId, String name); @Override PageData<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndDeviceProfileId(UUID tenantId, UUID deviceProfileId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(UUID tenantId, UUID customerId, UUID deviceProfileId, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantDeviceTypesAsync(UUID tenantId); @Override Device findDeviceByTenantIdAndId(TenantId tenantId, UUID id); @Override ListenableFuture<Device> findDeviceByTenantIdAndIdAsync(TenantId tenantId, UUID id); @Override Long countDevicesByDeviceProfileId(TenantId tenantId, UUID deviceProfileId); }
JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao { @Override public PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink) { if (StringUtils.isEmpty(pageLink.getTextSearch())) { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, DaoUtil.toPageable(pageLink))); } else { return DaoUtil.toPageData( deviceRepository.findByTenantId( tenantId, Objects.toString(pageLink.getTextSearch(), ""), DaoUtil.toPageable(pageLink))); } }  @Override DeviceInfo findDeviceInfoById(TenantId tenantId, UUID deviceId); @Override PageData<Device> findDevicesByTenantId(UUID tenantId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantId(UUID tenantId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds); @Override PageData<Device> findDevicesByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndProfileId(UUID tenantId, UUID profileId, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerId(UUID tenantId, UUID customerId, PageLink pageLink); @Override ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds); @Override Optional<Device> findDeviceByTenantIdAndName(UUID tenantId, String name); @Override PageData<Device> findDevicesByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndType(UUID tenantId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndDeviceProfileId(UUID tenantId, UUID deviceProfileId, PageLink pageLink); @Override PageData<Device> findDevicesByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndType(UUID tenantId, UUID customerId, String type, PageLink pageLink); @Override PageData<DeviceInfo> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(UUID tenantId, UUID customerId, UUID deviceProfileId, PageLink pageLink); @Override ListenableFuture<List<EntitySubtype>> findTenantDeviceTypesAsync(UUID tenantId); @Override Device findDeviceByTenantIdAndId(TenantId tenantId, UUID id); @Override ListenableFuture<Device> findDeviceByTenantIdAndIdAsync(TenantId tenantId, UUID id); @Override Long countDevicesByDeviceProfileId(TenantId tenantId, UUID deviceProfileId);  }