Java Code Examples for org.springframework.data.domain.Sort.Direction#ASC
The following examples show how to use
org.springframework.data.domain.Sort.Direction#ASC .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionBeanQuery.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Parametric Constructor. * * @param definition * QueryDefinition contains the query properties. * @param queryConfig * Implementation specific configuration. * @param sortPropertyIds * The properties participating in sort. * @param sortStates * The ascending or descending state of sort properties. */ public ActionBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, final Object[] sortPropertyIds, final boolean[] sortStates) { super(definition, queryConfig, sortPropertyIds, sortStates); if (isNotNullOrEmpty(queryConfig)) { currentSelectedConrollerId = (String) queryConfig.get(SPUIDefinitions.ACTIONS_BY_TARGET); } if (sortStates == null || sortStates.length <= 0) { return; } // Initialize sort sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); } }
Example 2
Source File: PortfolioResponseServiceImpl.java From ExecDashboard with Apache License 2.0 | 6 votes |
/** * (non-Javadoc) * * @see com.capitalone.dashboard.executive.service.PortfolioResponseService#findByExecutivesHierarchy(String, * String) * @param businessUnit * @return */ @Override public List<PortfolioResponse> findByExecutivesHierarchy(String eid, String businessUnit) { List<String> reportingEids = new ArrayList<>(); ExecutiveHierarchy executivesHierarchy = executiveHierarchyRepository.findByEid(eid); if (executivesHierarchy != null) { Map<String, List<String>> reportees = executivesHierarchy.getReportees(); if (reportees != null && !reportees.isEmpty()) { if (!ALL.equalsIgnoreCase(businessUnit)) { reportingEids.addAll(reportees.get(businessUnit)); } else { for (Map.Entry<String, List<String>> entry : reportees.entrySet()) { reportingEids.addAll(entry.getValue()); } } } } if (!reportingEids.isEmpty()) { Sort sort = new Sort(new Order(Direction.ASC, "order"), new Order(Direction.ASC, "executive.firstName")); return portfolioResponseRepository.getByEidsWithSort(reportingEids, sort); } return new ArrayList(); }
Example 3
Source File: DistributionBeanQuery.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Bean query for retrieving beans/objects of type. * * @param definition * query definition * @param queryConfig * as queryConfig * @param sortPropertyIds * property id's for sorting * @param sortStates * sort states */ public DistributionBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, final Object[] sortPropertyIds, final boolean[] sortStates) { super(definition, queryConfig, sortPropertyIds, sortStates); if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) { distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG); searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT); noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG); pinnedTarget = (TargetIdName) queryConfig.get(SPUIDefinitions.ORDER_BY_PINNED_TARGET); if (!StringUtils.isEmpty(searchText)) { searchText = String.format("%%%s%%", searchText); } } if (sortStates != null && sortStates.length > 0) { // Initalize sort sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); } } }
Example 4
Source File: ActionStatusBeanQuery.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Parametric Constructor. * * @param definition * QueryDefinition contains the query properties. * @param queryConfig * Implementation specific configuration. * @param sortPropertyIds * The properties participating in sort. * @param sortStates * The ascending or descending state of sort properties. */ public ActionStatusBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig, final Object[] sortPropertyIds, final boolean[] sortStates) { super(definition, queryConfig, sortPropertyIds, sortStates); if (isNotNullOrEmpty(queryConfig)) { currentSelectedActionId = (Long) queryConfig.get(SPUIDefinitions.ACTIONSTATES_BY_ACTION); } if (sortStates != null && sortStates.length > 0) { // Initialize sort sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); } } }
Example 5
Source File: ProjectInfoServiceApi.java From cicada with MIT License | 6 votes |
/** * 查询apps分页. */ @RequestMapping(value = "/projects/apps", method = RequestMethod.GET) @ApiOperation(value = ApiDocs.SEARCH_APPS_PAGE, notes = ApiDocs.SEARCH_APPS_PAGE) public Page<AppInfo> searchApps(@RequestParam("searchText") final String searchText, // @PageableDefault(page = DEFAULT_PAGE_NUM, size = DEFAULT_PAGE_SIZE, // sort = "id", direction = Direction.ASC) final Pageable pageable) { final Page<AppInfo> pageResult; if (StringUtils.isBlank(searchText)) { pageResult = appService.fetchAppInfos(pageable); } else { pageResult = appService.findByAppNameLike(searchText, pageable); } return pageResult; }
Example 6
Source File: AbstractPaginateList.java From plumdo-work with Apache License 2.0 | 6 votes |
@SuppressWarnings("rawtypes") private void setQueryOrder(Sort sort, Query query, Map<String, QueryProperty> properties) { if (sort == null || properties.isEmpty()) { return; } for (Order order : sort) { QueryProperty qp = properties.get(order.getProperty()); if (qp == null) { throw new FlowableIllegalArgumentException("Value for param 'sort' is not valid, '" + sort + "' is not a valid property"); } query.orderBy(qp); if (order.getDirection() == Direction.ASC) { query.asc(); } else { query.desc(); } } }
Example 7
Source File: PagingUtility.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
static Sort sanitizeDistributionSetSortParam(final String sortParam) { if (sortParam == null) { // default return new Sort(Direction.ASC, DistributionSetFields.ID.getFieldName()); } return new Sort(SortUtility.parse(DistributionSetFields.class, sortParam)); }
Example 8
Source File: MarketController.java From cloudstreetmarket.com with GNU General Public License v3.0 | 5 votes |
@RequestMapping(method=GET) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "Get list of markets", notes = "Return a page of markets") public PagedResources<MarketResource> getSeveral( @ApiIgnore @PageableDefault(size=10, page=0, sort={"name"}, direction=Direction.ASC) Pageable pageable){ return pagedAssembler.toResource(marketService.getAll(pageable), assembler); }
Example 9
Source File: ManageDistBeanQuery.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
private void setupSorting(final Object[] sortPropertyIds, final boolean[] sortStates) { if (sortStates != null && sortStates.length > 0) { // Initialize sort sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { sort = sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); } } }
Example 10
Source File: DatatablesSortHandlerMethodArgumentResolver.java From springlets with Apache License 2.0 | 5 votes |
/** * Returns the ordering {@link Direction} to apply to the property * in the given ordering position. * @param pos the ordering position * @return the ordering {@link Direction} */ Direction getOrderDirection(int pos) { String direction = getParameter(Datatables.orderDirectionParameter(pos)); if ("desc".equals(direction)) { return Direction.DESC; } return Direction.ASC; }
Example 11
Source File: PagingUtility.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
static Sort sanitizeRolloutGroupSortParam(final String sortParam) { if (sortParam == null) { // default return new Sort(Direction.ASC, RolloutGroupFields.ID.getFieldName()); } return new Sort(SortUtility.parse(RolloutGroupFields.class, sortParam)); }
Example 12
Source File: PagingUtility.java From hawkbit with Eclipse Public License 1.0 | 5 votes |
static Sort sanitizeSoftwareModuleSortParam(final String sortParam) { if (sortParam == null) { // default return new Sort(Direction.ASC, SoftwareModuleFields.ID.getFieldName()); } return new Sort(SortUtility.parse(SoftwareModuleFields.class, sortParam)); }
Example 13
Source File: MarketController.java From cloudstreetmarket.com with GNU General Public License v3.0 | 5 votes |
@RequestMapping(value="/{market}", method=GET) @ApiOperation(value = "Get one markets", notes = "Return a market") public MarketResource get( @ApiParam(value="Market code: EUROPE") @PathVariable(value="market") MarketId marketId, @ApiIgnore @PageableDefault(size=10, page=0, sort={"name"}, direction=Direction.ASC) Pageable pageable){ return assembler.toResource(marketService.get(marketId)); }
Example 14
Source File: SysDbmsChartDimensionService.java From danyuan-application with Apache License 2.0 | 5 votes |
/** * 方法名 : findAll * 功 能 : TODO(这里用一句话描述这个方法的作用) * 参 数 : @param info * 参 数 : @return * 参 考 : @see com.shumeng.application.common.base.BaseService#findAll(java.lang.Object) * 作 者 : Administrator */ @Override public List<SysDbmsChartDimension> findAll(SysDbmsChartDimension info) { Example<SysDbmsChartDimension> example = Example.of(info); Order order = new Order(Direction.ASC, "dimeOrder"); Sort sort = Sort.by(order); return sysDbmsChartDimensionDao.findAll(example, sort); }
Example 15
Source File: AbstractModelsResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected Sort getSort(String sort, boolean prefixWithProcessModel) { String propName; Direction direction; if (SORT_NAME_ASC.equals(sort)) { if (prefixWithProcessModel) { propName = "model.name"; } else { propName = "name"; } direction = Direction.ASC; } else if (SORT_NAME_DESC.equals(sort)) { if (prefixWithProcessModel) { propName = "model.name"; } else { propName = "name"; } direction = Direction.DESC; } else if (SORT_MODIFIED_ASC.equals(sort)) { if (prefixWithProcessModel) { propName = "model.lastUpdated"; } else { propName = "lastUpdated"; } direction = Direction.ASC; } else { // Default sorting if (prefixWithProcessModel) { propName = "model.lastUpdated"; } else { propName = "lastUpdated"; } direction = Direction.DESC; } return new Sort(direction, propName); }
Example 16
Source File: ResourceServiceImpl.java From SpringBoot-Base-System with GNU Lesser General Public License v3.0 | 5 votes |
@Override @Cacheable(value = "resourceCache", key = "'tree' + #roleId") // 指定缓存在哪个Cache上[使用自定义的key] public List<ZtreeView> tree(int roleId) { log.info("tree:" + roleId); List<ZtreeView> resulTreeNodes = new ArrayList<ZtreeView>(); Role role = roleService.find(roleId); Set<Resource> roleResources = role.getResources(); resulTreeNodes.add(new ZtreeView(0L, null, "系统菜单", true)); ZtreeView node; Sort sort = new Sort(Direction.ASC, "parent", "id", "sort"); List<Resource> all = resourceDao.findAll(sort); for (Resource resource : all) { node = new ZtreeView(); node.setId(Long.valueOf(resource.getId())); if (resource.getParent() == null) { node.setpId(0L); } else { node.setpId(Long.valueOf(resource.getParent().getId())); } node.setName(resource.getName()); if (roleResources != null && roleResources.contains(resource)) { node.setChecked(true); } resulTreeNodes.add(node); } return resulTreeNodes; }
Example 17
Source File: LinqTests.java From linq with Apache License 2.0 | 4 votes |
@Test @Transactional public void testFindAll() { Assert.notNull(JpaUtil.linq(User.class).list(), "Not Success."); User user = new User(); user.setId(UUID.randomUUID().toString()); user.setName("tom"); User user2 = new User(); user2.setName("kevin"); user2.setId(UUID.randomUUID().toString()); JpaUtil.persist(user); JpaUtil.persist(user2); Assert.notEmpty(JpaUtil.linq(User.class).list(), "Not Success."); Assert.isTrue(JpaUtil.linq(User.class).equal("name", "tom").list().size() == 1, "Not Success."); Pageable pageable = new PageRequest(0, 1); Page<User> page = JpaUtil.linq(User.class).paging(pageable); Assert.isTrue(page.getSize() == 1, "Not Success."); Assert.isTrue(page.getTotalElements() == 2, "Not Success."); Assert.isTrue(page.getTotalPages() == 2, "Not Success."); Pageable pageable2 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page2 = JpaUtil.linq(User.class).paging(pageable2); Assert.isTrue(page2.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page2.getSize() == 1, "Not Success."); Assert.isTrue(page2.getTotalElements() == 2, "Not Success."); Assert.isTrue(page2.getTotalPages() == 2, "Not Success."); Pageable pageable3 = new PageRequest(0, 1, Direction.ASC, "name"); Page<User> page3 = JpaUtil.linq(User.class).paging(pageable3); Assert.isTrue(page3.getContent().get(0).getName() == "kevin", "Not Success."); Assert.isTrue(page3.getSize() == 1, "Not Success."); Assert.isTrue(page3.getTotalElements() == 2, "Not Success."); Assert.isTrue(page3.getTotalPages() == 2, "Not Success."); Pageable pageable4 = new PageRequest(0, 1); Page<User> page4 = JpaUtil.linq(User.class).equal("name", "tom").paging(pageable4); Assert.isTrue(page4.getSize() == 1, "Not Success."); Assert.isTrue(page4.getTotalElements() == 1, "Not Success."); Assert.isTrue(page4.getTotalPages() == 1, "Not Success."); Pageable pageable5 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page5 = JpaUtil.linq(User.class).equal("name", "tom").paging(pageable5); Assert.isTrue(page5.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page5.getSize() == 1, "Not Success."); Assert.isTrue(page5.getTotalElements() == 1, "Not Success."); Assert.isTrue(page5.getTotalPages() == 1, "Not Success."); Pageable pageable6 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page6 = JpaUtil.linq(User.class).equal("name", "tom").paging(pageable6); Assert.isTrue(page6.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page6.getSize() == 1, "Not Success."); Assert.isTrue(page6.getTotalElements() == 1, "Not Success."); Assert.isTrue(page6.getTotalPages() == 1, "Not Success."); Page<User> page7 = JpaUtil.linq(User.class).equal("name", "tom").paging(null); Assert.isTrue(page7.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page7.getSize() == 0, "Not Success."); Assert.isTrue(page7.getTotalElements() == 1, "Not Success."); Assert.isTrue(page7.getTotalPages() == 1, "Not Success."); JpaUtil.removeAllInBatch(User.class); }
Example 18
Source File: JpaUtilTests.java From linq with Apache License 2.0 | 4 votes |
@Test @Transactional public void testFindAll() { Assert.notNull(JpaUtil.findAll(User.class), "Not Success."); User user = new User(); user.setId(UUID.randomUUID().toString()); user.setName("tom"); User user2 = new User(); user2.setName("kevin"); user2.setId(UUID.randomUUID().toString()); JpaUtil.persist(user); JpaUtil.persist(user2); Assert.notEmpty(JpaUtil.findAll(User.class), "Not Success."); EntityManager em = JpaUtil.getEntityManager(User.class); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<User> cq = cb.createQuery(User.class); Assert.isTrue(JpaUtil.findAll(cq).size() == 2, "Not Success."); cq.getRoots().clear(); Root<User> root = cq.from(User.class); Assert.isTrue(JpaUtil.findAll(cq).size() == 2, "Not Success."); cq.where(cb.equal(root.get("name"), "tom")); Assert.isTrue(JpaUtil.findAll(cq).size() == 1, "Not Success."); Pageable pageable = new PageRequest(0, 1); Page<User> page = JpaUtil.findAll(User.class, pageable); Assert.isTrue(page.getSize() == 1, "Not Success."); Assert.isTrue(page.getTotalElements() == 2, "Not Success."); Assert.isTrue(page.getTotalPages() == 2, "Not Success."); Pageable pageable2 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page2 = JpaUtil.findAll(User.class, pageable2); Assert.isTrue(page2.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page2.getSize() == 1, "Not Success."); Assert.isTrue(page2.getTotalElements() == 2, "Not Success."); Assert.isTrue(page2.getTotalPages() == 2, "Not Success."); Pageable pageable3 = new PageRequest(0, 1, Direction.ASC, "name"); Page<User> page3 = JpaUtil.findAll(User.class, pageable3); Assert.isTrue(page3.getContent().get(0).getName() == "kevin", "Not Success."); Assert.isTrue(page3.getSize() == 1, "Not Success."); Assert.isTrue(page3.getTotalElements() == 2, "Not Success."); Assert.isTrue(page3.getTotalPages() == 2, "Not Success."); Pageable pageable4 = new PageRequest(0, 1); Page<User> page4 = JpaUtil.findAll(cq, pageable4); Assert.isTrue(page4.getSize() == 1, "Not Success."); Assert.isTrue(page4.getTotalElements() == 1, "Not Success."); Assert.isTrue(page4.getTotalPages() == 1, "Not Success."); Pageable pageable5 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page5 = JpaUtil.findAll(cq, pageable5); Assert.isTrue(page5.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page5.getSize() == 1, "Not Success."); Assert.isTrue(page5.getTotalElements() == 1, "Not Success."); Assert.isTrue(page5.getTotalPages() == 1, "Not Success."); Pageable pageable6 = new PageRequest(0, 1, Direction.DESC, "name"); Page<User> page6 = JpaUtil.findAll(cq, pageable6); Assert.isTrue(page6.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page6.getSize() == 1, "Not Success."); Assert.isTrue(page6.getTotalElements() == 1, "Not Success."); Assert.isTrue(page6.getTotalPages() == 1, "Not Success."); Page<User> page7 = JpaUtil.findAll(cq, null); Assert.isTrue(page7.getContent().get(0).getName() == "tom", "Not Success."); Assert.isTrue(page7.getSize() == 0, "Not Success."); Assert.isTrue(page7.getTotalElements() == 1, "Not Success."); Assert.isTrue(page7.getTotalPages() == 1, "Not Success."); JpaUtil.removeAllInBatch(User.class); }
Example 19
Source File: PageableDataProvider.java From spring-data-provider with Apache License 2.0 | 4 votes |
private static Order queryOrderToSpringOrder(QuerySortOrder queryOrder) { return new Order(queryOrder.getDirection() == SortDirection.ASCENDING ? Direction.ASC : Direction.DESC, queryOrder.getSorted()); }
Example 20
Source File: StudentServiceImpl.java From Demo with Apache License 2.0 | 4 votes |
/** * 查询所有学生信息列表 * @return */ @Override public List<Student> findStudentList() { Sort sort = new Sort(Direction.ASC,"id"); return studentRepository.findAll(sort); }