@Override protected List<ProxyAction> loadBeans(final int startIndex, final int count) { Slice<Action> actionBeans; if (startIndex == 0) { if (firstPageActions == null) { firstPageActions = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, PageRequest.of(0, SPUIDefinitions.PAGE_SIZE, sort)); } actionBeans = firstPageActions; } else { actionBeans = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, PageRequest.of(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); } return createProxyActions(actionBeans); }
@Override protected List<ProxyAction> loadBeans(final int startIndex, final int count) { Slice<Action> actionBeans; if (startIndex == 0) { if (firstPageActions == null) { firstPageActions = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); } actionBeans = firstPageActions; } else { actionBeans = getDeploymentManagement().findActionsByTarget(currentSelectedConrollerId, new PageRequest(startIndex / SPUIDefinitions.PAGE_SIZE, SPUIDefinitions.PAGE_SIZE, sort)); } return createProxyActions(actionBeans); }
/** * Append {@link ActionStatus} to all {@link Action}s of given * {@link Target}s. * * @param targets * to add {@link ActionStatus} * @param status * to add * @param msgs * to add * * @return updated {@link Action}. */ public List<Action> sendUpdateActionStatusToTargets(final Collection<Target> targets, final Status status, final Collection<String> msgs) { final List<Action> result = new ArrayList<>(); for (final Target target : targets) { final List<Action> findByTarget = deploymentManagement .findActionsByTarget(target.getControllerId(), new PageRequest(0, 400)).getContent(); for (final Action action : findByTarget) { result.add(sendUpdateActionStatusToTarget(status, action, msgs)); } } return result; }
/** * Append {@link ActionStatus} to all {@link Action}s of given * {@link Target}s. * * @param targets * to add {@link ActionStatus} * @param status * to add * @param msgs * to add * * @return updated {@link Action}. */ public List<Action> sendUpdateActionStatusToTargets(final Collection<Target> targets, final Status status, final Collection<String> msgs) { final List<Action> result = new ArrayList<>(); for (final Target target : targets) { final List<Action> findByTarget = deploymentManagement .findActionsByTarget(target.getControllerId(), PageRequest.of(0, 400)).getContent(); for (final Action action : findByTarget) { result.add(sendUpdateActionStatusToTarget(status, action, msgs)); } } return result; }
@Override public ResponseEntity<PagedList<MgmtAction>> getActionHistory(@PathVariable("targetId") final String targetId, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = MgmtRestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, @RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { findTargetWithExceptionIfNotFound(targetId); final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); final Sort sorting = PagingUtility.sanitizeActionSortParam(sortParam); final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Slice<Action> activeActions; final Long totalActionCount; if (rsqlParam != null) { activeActions = this.deploymentManagement.findActionsByTarget(rsqlParam, targetId, pageable); totalActionCount = this.deploymentManagement.countActionsByTarget(rsqlParam, targetId); } else { activeActions = this.deploymentManagement.findActionsByTarget(targetId, pageable); totalActionCount = this.deploymentManagement.countActionsByTarget(targetId); } return ResponseEntity.ok( new PagedList<>(MgmtTargetMapper.toResponse(targetId, activeActions.getContent()), totalActionCount)); }