int count = toDelete.getContent().size(); if (count > 0) { long total = tt.execute(t -> mySearchDao.count());
List<List<Long>> partitions = Lists.partition(resourceIds.getContent(), 800); for (List<Long> nextPartition : partitions) { ourLog.info("Expunging any search results pointing to {} resources", nextPartition.size());
private void deleteSearch(final Long theSearchPid) { mySearchDao.findById(theSearchPid).ifPresent(searchToDelete -> { mySearchIncludeDao.deleteForSearch(searchToDelete.getId()); /* * Note, we're only deleting up to 500 results in an individual search here. This * is to prevent really long running transactions in cases where there are * huge searches with tons of results in them. By the time we've gotten here * we have marked the parent Search entity as deleted, so it's not such a * huge deal to be only partially deleting search results. They'll get deleted * eventually */ int max = ourMaximumResultsToDeleteInOnePass; Slice<Long> resultPids = mySearchResultDao.findForSearch(PageRequest.of(0, max), searchToDelete.getId()); if (resultPids.hasContent()) { List<List<Long>> partitions = Lists.partition(resultPids.getContent(), ourMaximumResultsToDeleteInOneStatement); for (List<Long> nextPartition : partitions) { mySearchResultDao.deleteByIds(nextPartition); } } // Only delete if we don't have results left in this search if (resultPids.getNumberOfElements() < max) { ourLog.info("Deleting search {}/{} - Created[{}] -- Last returned[{}]", searchToDelete.getId(), searchToDelete.getUuid(), new InstantType(searchToDelete.getCreated()), new InstantType(searchToDelete.getSearchLastReturned())); mySearchDao.deleteByPid(searchToDelete.getId()); } else { ourLog.info("Purged {} search results for deleted search {}/{}", resultPids.getSize(), searchToDelete.getId(), searchToDelete.getUuid()); } }); }
private static Slice<SoftwareModuleType> convertPage(final Slice<JpaSoftwareModuleType> findAll, final Pageable pageable) { return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0); }
private static Slice<DistributionSetTag> convertDsPage(final Slice<JpaDistributionSetTag> findAll, final Pageable pageable) { return new PageImpl<>(Collections.unmodifiableList(findAll.getContent()), pageable, 0); }
@Override protected List<ProxyBaseSwModuleItem> loadBeans(final int startIndex, final int count) { return getSoftwareModuleManagement() .findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type) .getContent().stream().map(SwModuleBeanQuery::getProxyBean).collect(Collectors.toList()); }
@Override protected List<ProxyBaseSwModuleItem> loadBeans(final int startIndex, final int count) { return getSoftwareModuleManagement() .findAllOrderBySetAssignmentAndModuleNameAscModuleVersionAsc( new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type) .getContent().stream().map(SwModuleBeanQuery::getProxyBean).collect(Collectors.toList()); }
private void setRolloutStatusDetails(final Slice<JpaRollout> rollouts) { final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList()); final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout( rolloutIds); if (allStatesForRollout != null) { rollouts.forEach(rollout -> { final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus( allStatesForRollout.get(rollout.getId()), rollout.getTotalTargets()); rollout.setTotalTargetCountStatus(totalTargetCountStatus); }); } }
@Override protected List<ProxyBaseSoftwareModuleItem> loadBeans(final int startIndex, final int count) { final Slice<SoftwareModule> swModuleBeans; if (type == null && StringUtils.isEmpty(searchText)) { swModuleBeans = getSoftwareManagementService().findAll(new OffsetBasedPageRequest(startIndex, count, sort)); } else { swModuleBeans = getSoftwareManagementService() .findByTextAndType(new OffsetBasedPageRequest(startIndex, count, sort), searchText, type); } return swModuleBeans.getContent().stream().map(this::getProxyBean).collect(Collectors.toList()); }
@Override protected List<ProxyBaseSoftwareModuleItem> loadBeans(final int startIndex, final int count) { final Slice<SoftwareModule> swModuleBeans; if (type == null && StringUtils.isEmpty(searchText)) { swModuleBeans = getSoftwareManagementService().findAll(new OffsetBasedPageRequest(startIndex, count, sort)); } else { swModuleBeans = getSoftwareManagementService() .findByTextAndType(new OffsetBasedPageRequest(startIndex, count, sort), searchText, type); } return swModuleBeans.getContent().stream().map(this::getProxyBean).collect(Collectors.toList()); }
private void setRolloutStatusDetails(final Slice<JpaRollout> rollouts) { final List<Long> rolloutIds = rollouts.getContent().stream().map(Rollout::getId).collect(Collectors.toList()); final Map<Long, List<TotalTargetCountActionStatus>> allStatesForRollout = getStatusCountItemForRollout( rolloutIds); if (allStatesForRollout != null) { rollouts.forEach(rollout -> { final TotalTargetCountStatus totalTargetCountStatus = new TotalTargetCountStatus( allStatesForRollout.get(rollout.getId()), rollout.getTotalTargets()); rollout.setTotalTargetCountStatus(totalTargetCountStatus); }); } }
@Override protected List<SoftwareModuleType> loadBeans(final int startIndex, final int count) { return getSoftwareModuleTypeManagement().findAll(new OffsetBasedPageRequest(startIndex, count, sort)) .getContent(); }
@Override @Transactional public NeedInformationService.PagedResource<Dataset, URI> listConnectionURIsBefore( URI beforeConnURI, final Integer preferredSize, Date timeSpot, boolean deep) throws NoSuchConnectionException { Slice<URI> slice = needInformationService.listConnectionURIsBefore(beforeConnURI, preferredSize, timeSpot); NeedInformationService.PagedResource<Dataset, URI> containerPage = toContainerPage(this.connectionResourceURIPrefix + "/", slice); if (deep) { addDeepConnectionData(containerPage.getContent(), slice.getContent()); } return containerPage; }
@Override @Transactional public NeedInformationService.PagedResource<Dataset, URI> listConnectionURIsAfter( URI afterConnURI, final Integer preferredSize, Date timeSpot, boolean deep) throws NoSuchConnectionException { Slice<URI> slice = needInformationService.listConnectionURIsAfter(afterConnURI, preferredSize, timeSpot); NeedInformationService.PagedResource<Dataset, URI> containerPage = toContainerPage( this.connectionResourceURIPrefix + "/", slice); if (deep) { addDeepConnectionData(containerPage.getContent(), slice.getContent()); } return containerPage; }
@Override @Transactional public NeedInformationService.PagedResource<Dataset, URI> listConnectionURIs(final int page, final Integer preferredSize, Date timeSpot, final boolean deep) throws NoSuchConnectionException { Slice<URI> slice = needInformationService.listConnectionURIs(page, preferredSize, timeSpot); NeedInformationService.PagedResource<Dataset, URI> containerPage = toContainerPage( this.connectionResourceURIPrefix + "/", slice); if (deep) { addDeepConnectionData(containerPage.getContent(), slice.getContent()); } return containerPage; }
@Override protected List<SoftwareModuleType> loadBeans(final int startIndex, final int count) { return getSoftwareModuleTypeManagement().findAll(new OffsetBasedPageRequest(startIndex, count, sort)) .getContent(); }
@Override protected void populateContainer() { container.removeAllItems(); tagDetails.clear(); distributionSetTagManagement.findAll(PageRequest.of(0, MAX_TAG_QUERY)).getContent().stream() .forEach(tag -> setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour())); }
@Override protected void populateContainer() { container.removeAllItems(); tagDetails.clear(); distributionSetTagManagement.findAll(new PageRequest(0, MAX_TAG_QUERY)).getContent().stream() .forEach(tag -> setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour())); }
private Action generateActionForTarget(final String knownControllerId, final boolean inSync, final boolean timeforced, final String maintenanceWindowSchedule, final String maintenanceWindowDuration, final String maintenanceWindowTimeZone) throws Exception { final PageRequest pageRequest = PageRequest.of(0, 1, Direction.ASC, ActionStatusFields.ID.getFieldName()); createTargetByGivenNameWithAttributes(knownControllerId, inSync, timeforced, createDistributionSet(), maintenanceWindowSchedule, maintenanceWindowDuration, maintenanceWindowTimeZone); final List<Action> actions = deploymentManagement.findActionsAll(pageRequest).getContent(); assertThat(actions).hasSize(1); return actions.get(0); } }
private void feedbackToByInSync(final DistributionSet savedSet) { final Action action = deploymentManagement.findActionsByDistributionSet(PAGE, savedSet.getId()).getContent() .get(0); controllerManagement .addUpdateActionStatus(entityFactory.actionStatus().create(action.getId()).status(Status.FINISHED)); }