当前位置: 首页>>代码示例>>Java>>正文


Java Slice类代码示例

本文整理汇总了Java中org.springframework.data.domain.Slice的典型用法代码示例。如果您正苦于以下问题:Java Slice类的具体用法?Java Slice怎么用?Java Slice使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Slice类属于org.springframework.data.domain包,在下文中一共展示了Slice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteScheduledActions

import org.springframework.data.domain.Slice; //导入依赖的package包/类
private void deleteScheduledActions(final JpaRollout rollout, final Slice<JpaAction> scheduledActions) {
    final boolean hasScheduledActions = scheduledActions.getNumberOfElements() > 0;

    if (hasScheduledActions) {
        try {
            final Iterable<JpaAction> iterable = scheduledActions::iterator;
            final List<Long> actionIds = StreamSupport.stream(iterable.spliterator(), false).map(Action::getId)
                    .collect(Collectors.toList());
            actionRepository.deleteByIdIn(actionIds);
            afterCommit.afterCommit(() -> eventPublisher.publishEvent(
                    new RolloutUpdatedEvent(rollout, EventPublisherHolder.getInstance().getApplicationId())));
        } catch (final RuntimeException e) {
            LOGGER.error("Exception during deletion of actions of rollout {}", rollout, e);
        }
    }
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:17,代码来源:JpaRolloutManagement.java

示例2: useSliceToLoadContent

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Test
public void useSliceToLoadContent() {

	repository.deleteAll();

	// int repository with some values that can be ordered
	int totalNumberUsers = 11;
	List<User> source = new ArrayList<User>(totalNumberUsers);

	for (int i = 1; i <= totalNumberUsers; i++) {

		User user = new User();
		user.setLastname(this.user.getLastname());
		user.setUsername(user.getLastname() + "-" + String.format("%03d", i));
		source.add(user);
	}

	repository.save(source);

	Slice<User> users = repository.findByLastnameOrderByUsernameAsc(this.user.getLastname(), new PageRequest(1, 5));

	assertThat(users, contains(source.subList(5, 10).toArray()));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:24,代码来源:SimpleUserRepositoryTests.java

示例3: home

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@RequestMapping(value = "/", method = GET)
public String home(Model model) {
    String springVersion = webUI.parameterizedMessage("home.spring.version", SpringBootVersion.getVersion());
    model.addAttribute("springVersion", springVersion);

    GitHubStats gitHubStats = webUI.getCurrentGitHubStats();
    if (gitHubStats != null) {
        model.addAttribute("showGitHubStats", true);
        model.addAttribute("gitHubStats", gitHubStats);
    }

    if (webUI.isNixMash()) {
        SiteImage siteImage = siteService.getHomeBanner();
        model.addAttribute("siteImage", siteImage);
    }

    Slice<Post> posts = postService.getPublishedPosts(0, 10);
    if (posts.getContent().size() > 0)
        model.addAttribute("posts", posts);

    return HOME_VIEW;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:23,代码来源:GeneralController.java

示例4: getQuickSearchPosts

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@RequestMapping(value = "/quicksearch/page/{pageNumber}",
        produces = "text/html;charset=UTF-8")
public String getQuickSearchPosts(@PathVariable int pageNumber,
                                  HttpServletRequest request,
                                  CurrentUser currentUser) {
    String search = (String) WebUtils.getSessionAttribute(request, SESSION_QUICKSEARCH_QUERY);
    String result;
    List<PostDoc> postDocs = postDocService.doQuickSearch(search);
    if (postDocs.size() == 0) {
        result = fmService.getNoResultsMessage(search);
    } else {
        Slice<PostDoc> posts = postDocService.doPagedQuickSearch(search, pageNumber, POST_PAGING_SIZE);
        result = populatePostDocStream(posts.getContent(), currentUser);
        WebUtils.setSessionAttribute(request, SESSION_ATTRIBUTE_QUICKSEARCH_POSTS, posts.getContent());
    }
    return result;
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:18,代码来源:PostsRestController.java

示例5: list

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Transactional(readOnly = true)
public Slice<ListAnnouncementDTO> list(final ListAnnouncementRequest request, final Pageable pageRequest) {
    final ListAnnouncementFilter filter = new ListAnnouncementFilter(occupationRepository);

    if (!activeUserService.isModeratorOrAdmin()) {
        filter.withSubscriberPerson(activeUserService.requireActivePerson());
    }

    final Optional<Organisation> maybeOrganisation = resolveOrganisation(request);

    switch (request.getDirection()) {
        case SENT:
            maybeOrganisation.ifPresent(filter::withFromOrganisation);
            break;
        case RECEIVED:
            maybeOrganisation.ifPresent(filter::withSubscriberOrganisation);
            break;
        default:
            throw new IllegalArgumentException("Invalid direction");
    }

    return filter.buildPredicate()
            .map(predicate -> announcementRepository.findAllAsSlice(predicate, pageRequest))
            .map(slice -> transform(pageRequest, slice))
            .orElseGet(() -> new SliceImpl<>(emptyList()));
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:27,代码来源:ListAnnouncementFeature.java

示例6: findAll

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Override
public Slice<SoftwareModule> findAll(final Pageable pageable) {

    final List<Specification<JpaSoftwareModule>> specList = new ArrayList<>(2);

    Specification<JpaSoftwareModule> spec = SoftwareModuleSpecification.isDeletedFalse();
    specList.add(spec);

    spec = (root, query, cb) -> {
        if (!query.getResultType().isAssignableFrom(Long.class)) {
            root.fetch(JpaSoftwareModule_.type);
        }
        return cb.conjunction();
    };

    specList.add(spec);

    return convertSmPage(findByCriteriaAPI(pageable, specList), pageable);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:20,代码来源:JpaSoftwareModuleManagement.java

示例7: findActionStatusByActionId

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Test
@Description("Test verifies that action-states of an action are found by using id-based search.")
public void findActionStatusByActionId() {
    final DistributionSet testDs = testdataFactory.createDistributionSet("TestDs", "1.0",
            new ArrayList<DistributionSetTag>());
    final List<Target> testTarget = testdataFactory.createTargets(1);
    // one action with one action status is generated
    final Long actionId = assignDistributionSet(testDs, testTarget).getActions().get(0);
    final Slice<Action> actions = deploymentManagement.findActionsByTarget(testTarget.get(0).getControllerId(),
            PAGE);
    final ActionStatus expectedActionStatus = ((JpaAction) actions.getContent().get(0)).getActionStatus().get(0);

    // act
    final Page<ActionStatus> actionStates = deploymentManagement.findActionStatusByAction(PAGE, actionId);

    assertThat(actionStates.getContent()).hasSize(1);
    assertThat(actionStates.getContent().get(0)).as("Action-status of action").isEqualTo(expectedActionStatus);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:19,代码来源:DeploymentManagementTest.java

示例8: verifyThatTargetsHaveDistributionSetAssignment

import org.springframework.data.domain.Slice; //导入依赖的package包/类
/**
 * @param set
 *            the expected distribution set
 * @param targets
 *            the targets that should have it
 */
@Step
private void verifyThatTargetsHaveDistributionSetAssignment(final DistributionSet set, final List<Target> targets,
        final int count) {
    final List<Long> targetIds = targets.stream().map(Target::getId).collect(Collectors.toList());

    final Slice<Target> targetsAll = targetManagement.findAll(PAGE);
    assertThat(targetsAll).as("Count of targets").hasSize(count);

    for (final Target target : targetsAll) {
        if (targetIds.contains(target.getId())) {
            assertThat(deploymentManagement.getAssignedDistributionSet(target.getControllerId()).get())
                    .as("assigned DS").isEqualTo(set);
        }
    }

}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:23,代码来源:AutoAssignCheckerTest.java

示例9: createMultipleTargetsWithSameIdForDifferentTenant

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Test
@Description(value = "Ensures that multiple targets with same controller-ID can be created for different tenants.")
public void createMultipleTargetsWithSameIdForDifferentTenant() throws Exception {
    // known controller ID for overall tenants same
    final String knownControllerId = "controllerId";

    // known tenant names
    final String tenant = "aTenant";
    final String anotherTenant = "anotherTenant";
    // create targets
    createTargetForTenant(knownControllerId, tenant);
    createTargetForTenant(knownControllerId, anotherTenant);

    // ensure both tenants see their target
    final Slice<Target> findTargetsForTenant = findTargetsForTenant(tenant);
    assertThat(findTargetsForTenant).hasSize(1);
    assertThat(findTargetsForTenant.getContent().get(0).getTenant().toUpperCase()).isEqualTo(tenant.toUpperCase());
    final Slice<Target> findTargetsForAnotherTenant = findTargetsForTenant(anotherTenant);
    assertThat(findTargetsForAnotherTenant).hasSize(1);
    assertThat(findTargetsForAnotherTenant.getContent().get(0).getTenant().toUpperCase())
            .isEqualTo(anotherTenant.toUpperCase());

}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:24,代码来源:MultiTenancyEntityTest.java

示例10: queryTargetFromDifferentTenantIsNotVisible

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Test
@Description(value = "Ensures that targtes created by a tenant are not visible by another tenant.")
@WithUser(tenantId = "mytenant", allSpPermissions = true)
public void queryTargetFromDifferentTenantIsNotVisible() throws Exception {
    // create target for another tenant
    final String anotherTenant = "anotherTenant";
    final String controllerAnotherTenant = "anotherController";
    createTargetForTenant(controllerAnotherTenant, anotherTenant);

    // find all targets for current tenant "mytenant"
    final Slice<Target> findTargetsAll = targetManagement.findAll(PAGE);
    // no target has been created for "mytenant"
    assertThat(findTargetsAll).hasSize(0);

    // find all targets for anotherTenant
    final Slice<Target> findTargetsForTenant = findTargetsForTenant(anotherTenant);
    // another tenant should have targets
    assertThat(findTargetsForTenant).hasSize(1);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:20,代码来源:MultiTenancyEntityTest.java

示例11: deleteTargetFromOtherTenantIsNotPossible

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Test
@Description(value = "Ensures that targets created from a different tenant cannot be deleted from other tenants")
@WithUser(tenantId = "mytenant", allSpPermissions = true)
public void deleteTargetFromOtherTenantIsNotPossible() throws Exception {
    // create target for another tenant
    final String anotherTenant = "anotherTenant";
    final String controllerAnotherTenant = "anotherController";
    final Target createTargetForTenant = createTargetForTenant(controllerAnotherTenant, anotherTenant);

    // ensure target cannot be deleted by 'mytenant'
    try {
        targetManagement.delete(Arrays.asList(createTargetForTenant.getId()));
        fail("mytenant should not have been able to delete target of anotherTenant");
    } catch (final EntityNotFoundException ex) {
        // ok
    }

    Slice<Target> targetsForAnotherTenant = findTargetsForTenant(anotherTenant);
    assertThat(targetsForAnotherTenant).hasSize(1);

    // ensure another tenant can delete the target
    deleteTargetsForTenant(anotherTenant, Arrays.asList(createTargetForTenant.getId()));
    targetsForAnotherTenant = findTargetsForTenant(anotherTenant);
    assertThat(targetsForAnotherTenant).hasSize(0);
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:26,代码来源:MultiTenancyEntityTest.java

示例12: loadBeans

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Override
protected List<ProxyTag> loadBeans(final int startIndex, final int count) {
    final Slice<DistributionSetTag> dsTagBeans = getTagManagement()
            .findAll(new OffsetBasedPageRequest(startIndex, count, sort));

    return dsTagBeans.getContent().stream().map(tag -> {
        final ProxyTag proxyTargetTag = new ProxyTag();
        proxyTargetTag.setColour(tag.getColour());
        proxyTargetTag.setDescription(tag.getDescription());
        proxyTargetTag.setName(tag.getName());
        proxyTargetTag.setId(tag.getId());
        final TagIdName tagIdName = new TagIdName(tag.getName(), tag.getId());
        proxyTargetTag.setTagIdName(tagIdName);

        return proxyTargetTag;

    }).collect(Collectors.toList());
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:19,代码来源:DistributionTagBeanQuery.java

示例13: createProxyActions

import org.springframework.data.domain.Slice; //导入依赖的package包/类
/**
 * Creates a list of {@link ProxyAction}s for presentation layer from slice
 * of {@link Action}s.
 *
 * @param actionBeans
 *            slice of {@link Action}s
 * @return list of {@link ProxyAction}s
 */
private static List<ProxyAction> createProxyActions(final Slice<Action> actionBeans) {
    final List<ProxyAction> proxyActions = new ArrayList<>();
    for (final Action action : actionBeans) {
        final ProxyAction proxyAction = new ProxyAction();
        final String dsNameVersion = action.getDistributionSet().getName() + ":"
                + action.getDistributionSet().getVersion();
        proxyAction.setActive(action.isActive());
        proxyAction.setIsActiveDecoration(buildIsActiveDecoration(action));
        proxyAction.setDsNameVersion(dsNameVersion);
        proxyAction.setAction(action);
        proxyAction.setId(action.getId());
        proxyAction.setLastModifiedAt(action.getLastModifiedAt());
        proxyAction.setRolloutName(action.getRollout() != null ? action.getRollout().getName() : "");
        proxyAction.setStatus(action.getStatus());

        proxyActions.add(proxyAction);
    }
    return proxyActions;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:28,代码来源:ActionBeanQuery.java

示例14: getDistributionSetTypes

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Override
public ResponseEntity<PagedList<MgmtDistributionSetType>> getDistributionSetTypes(
        @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) {

    final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
    final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
    final Sort sorting = PagingUtility.sanitizeDistributionSetTypeSortParam(sortParam);
    final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);

    final Slice<DistributionSetType> findModuleTypessAll;
    long countModulesAll;
    if (rsqlParam != null) {
        findModuleTypessAll = distributionSetTypeManagement.findByRsql(pageable, rsqlParam);
        countModulesAll = ((Page<DistributionSetType>) findModuleTypessAll).getTotalElements();
    } else {
        findModuleTypessAll = distributionSetTypeManagement.findAll(pageable);
        countModulesAll = distributionSetTypeManagement.count();
    }

    final List<MgmtDistributionSetType> rest = MgmtDistributionSetTypeMapper
            .toListResponse(findModuleTypessAll.getContent());
    return ResponseEntity.ok(new PagedList<>(rest, countModulesAll));
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:27,代码来源:MgmtDistributionSetTypeResource.java

示例15: getSoftwareModules

import org.springframework.data.domain.Slice; //导入依赖的package包/类
@Override
public ResponseEntity<PagedList<MgmtSoftwareModule>> getSoftwareModules(
        @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) {

    final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
    final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
    final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);

    final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);

    final Slice<SoftwareModule> findModulesAll;
    long countModulesAll;
    if (rsqlParam != null) {
        findModulesAll = softwareModuleManagement.findByRsql(pageable, rsqlParam);
        countModulesAll = ((Page<SoftwareModule>) findModulesAll).getTotalElements();
    } else {
        findModulesAll = softwareModuleManagement.findAll(pageable);
        countModulesAll = softwareModuleManagement.count();
    }

    final List<MgmtSoftwareModule> rest = MgmtSoftwareModuleMapper.toResponse(findModulesAll.getContent());
    return ResponseEntity.ok(new PagedList<>(rest, countModulesAll));
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:27,代码来源:MgmtSoftwareModuleResource.java


注:本文中的org.springframework.data.domain.Slice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。