spring pageabe使用

Java Code Examples for org.springframework.data.web.PageableDefault
The following are top voted examples for showing how to use org.springframework.data.web.PageableDefault. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.
+ Save this class to your library
Example 1
Project: mini-geocoder File: ReverseGeocodeController.java View source code 9 votes vote down vote up
@RequestMapping(value="/all")
public List<ReverseGeocodeResult> getGeocoding(
@RequestParam(value = "lat", required = true) double latitude,
@RequestParam(value = "lon", required = true) double longitude,
@PageableDefault(sort = {"distance", "street", "housenumber"}) Pageable pageable) {

return geocodeRepository.findReverseAll(longitude, latitude, pageable.getSort());
}



Example 2
Project: terasoluna-gfw-functionaltest File: ElDateTimeFormatController.java View source code 7 votes vote down vote up
@RequestMapping(value = "6_13/search", method = RequestMethod.GET)
public String listOfJavaBeanQueryString(DateForm5 dateForm5,
@PageableDefault Pageable pageable, Model model) {

// Create Dummy Data
List<String> dummyList = new ArrayList<String>();
for (int i = 1; i <= 10; i++) {
dummyList.add("Dummy");
}

Page<String> dummyPage = new PageImpl<String>(dummyList, pageable, 100);
model.addAttribute("page", dummyPage);

return "el/dateTimeFormatQueryOutput";
}

Example 3
Project: demo-application File: AccountsController.java View source code 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public String list(final @Validated AccountsSearchQuery query, final BindingResult bindingResult, final @PageableDefault(size = 15) Pageable pageable, final Model model) {
if (bindingResult.hasErrors()) {
return "account/list";
}
final AccountsSearchCriteria criteria = beanMapper.map(query, AccountsSearchCriteria.class);
final Page<Account> page = accountService.searchAccounts(criteria, pageable);
model.addAttribute("page", page);
return "account/list";
}



Example 4
Project: build-monitor File: BuildController.java View source code 6 votes vote down vote up
@Transactional(readOnly = true)
@RequestMapping(method = RequestMethod.GET, value = "", produces = MEDIA_TYPE)
ResponseEntity<?> readAll(@PathVariable Project project, @PageableDefault(size = 10) Pageable pageable) {
if (project == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

Page<Build> builds = this.repository.findAllByProjectOrderByCreatedDesc(project, pageable);
PagedResources<Resource<Build>> resources = this.pagedResourcesAssembler.toResource(builds,
this.resourceAssembler);

return new ResponseEntity<>(resources, HttpStatus.OK);
}

Example 5
Project: JiwhizBlogWeb File: AuthorBlogCommentRestController.java View source code 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_AUTHOR_BLOGS_BLOG_COMMENTS)
public HttpEntity<PagedResources<AuthorBlogCommentResource>> getCommentPostsByBlogPostId(
@PathVariable("blogId") String blogId,
@PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable,
PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException {
getBlogByIdAndCheckAuthor(blogId);

Page<CommentPost> commentPosts = commentPostRepository.findByBlogPostIdOrderByCreatedTimeDesc(blogId, pageable);
return new ResponseEntity<>(assembler.toResource(commentPosts, authorBlogCommentResourceAssembler), HttpStatus.OK);
}

Example 6
Project: twitter-like-example File: MessageRestController.java View source code 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public HttpEntity<PagedResources<MessageResource>> findFollowedMessages(
@AuthenticationPrincipal UserDetails userDetails,
@PageableDefault(size = 10, page = 0, direction = Sort.Direction.DESC, sort = "createdDate") Pageable pageable,
PagedResourcesAssembler<Message> assembler)
throws ResourceNotFoundException {
return doReturnMessagePagedResult(
assembler,
messageRepository.findFollowedMessages(
userDetails.getUsername(), pageable));
}



Example 7
Project: wallride File: IndexController.java View source code 6 votes vote down vote up
@RequestMapping
public String index(
@PageableDefault(10) Pageable pageable,
BlogLanguage blogLanguage,
Model model) {
ArticleSearchForm form = new ArticleSearchForm() {};
form.setLanguage(blogLanguage.getLanguage());

Page<Article> articles = articleService.readArticles(form.toArticleSearchRequest(), pageable);
model.addAttribute("articles", articles);
model.addAttribute("pageable", pageable);
model.addAttribute("pagination", new Pagination<>(articles));
return "index";
//
//
// Blog blog = blogService.readBlogById(Blog.DEFAULT_ID);
// String defaultLanguage = blog.getDefaultLanguage();
// redirectAttributes.addAttribute("language", defaultLanguage);
// return "redirect:/{language}/";
}

Example 8
Project: tasq File: ProjectController.java View source code 6 votes vote down vote up
@RequestMapping(value = "projectEvents", method = RequestMethod.GET)
public @ResponseBody Page<DisplayWorkLog> getProjectEvents(@RequestParam(value = "id") String id,
@PageableDefault(size = 25, page = 0, sort = "time", direction = Direction.DESC) Pageable p) {
Project project = projSrv.findByProjectId(id);
if (project == null) {
// NULL
return null;
}
if (!project.getParticipants().contains(Utils.getCurrentAccount()) && !Roles.isAdmin()) {
throw new TasqAuthException(msg, "role.error.project.permission");
}
// Fetch events
Page<WorkLog> page = wrkLogSrv.findByProjectId(project.getId(), p);
List<DisplayWorkLog> list = new LinkedList<DisplayWorkLog>();
for (WorkLog workLog : page) {
list.add(new DisplayWorkLog(workLog));
}
Page<DisplayWorkLog> result = new PageImpl<DisplayWorkLog>(list, p, page.getTotalElements());
return result;
}

Example 9
Project: weplantaforest File: ProjectController.java View source code 6 votes vote down vote up
@RequestMapping(value = "/rest/v1/projects", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON })
public PagedResources<ProjectDto> get(@PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0, sort = { "_name" }) Pageable pageable,
@Nullable PagedResourcesAssembler assembler) {
Page<ProjectDto> projects = _projectService.findAll(pageable);
PagedResources<ProjectDto> pagedResource = null;
if (null != assembler) {
pagedResource = assembler.toResource(projects, _projectResourceAssembler);
} else {
pagedResource = new PagedResources<ProjectDto>(new ArrayList<ProjectDto>(), null);
}
return pagedResource;
}

Example 10
Project: categolj2-backend File: FileRestController.java View source code 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, headers = Categolj2Headers.X_ADMIN)
public Page<FileResource> getFiles(@PageableDefault Pageable pageable) {
Page<UploadFileSummary> summaries = uploadFileService.findPage(pageable);
List<FileResource> resources = summaries.getContent().stream()
.map(file -> beanMapper.map(file, FileResource.class))
.collect(Collectors.toList());
return new PageImpl<>(resources, pageable, summaries.getTotalElements());
}

Example 11
Project: terasoluna-tourreservation-mybatis3 File: SearchTourController.java View source code 6 votes vote down vote up
/**
* Searches the tours based on user input. Search result is shown in the form of a List of TourInfo domain objects User
* input is mapped to form backed bean SearchTourForm
* @param searchTourForm
* @param result
* @param model
* @param pageable
* @return
*/
@RequestMapping(method = RequestMethod.GET)
public String search(@Validated SearchTourForm searchTourForm,
BindingResult result, Model model,
@PageableDefault Pageable pageable) {
if (result.hasErrors()) {
return "searchtour/searchForm";
}

if (log.isDebugEnabled()) {
log.debug("pageable={}", pageable);
}

TourInfoSearchCriteria criteria = beanMapper.map(searchTourForm, TourInfoSearchCriteria.class);

Date depDate = new LocalDate(searchTourForm.getDepYear(), searchTourForm.getDepMonth(), searchTourForm.getDepDay()).toDate();
criteria.setDepDate(depDate);

Page<TourInfo> page = tourInfoService.searchTour(criteria, pageable);
model.addAttribute("page", page);
return "searchtour/searchForm";
}

Example 12
Project: fullstop File: ViolationsController.java View source code 6 votes vote down vote up
@ApiOperation(
value = "violations", notes = "Get all violations", response = Violation.class, responseContainer = "List"
)
@ApiResponses(value = {@ApiResponse(code = 200, message = "List of all violations")})
@PreAuthorize("#oauth2.hasScope('uid')")
@RequestMapping(method = GET)
public Page<Violation> violations(
@ApiParam(value = "Include only violations in these accounts")
@RequestParam(value = "accounts", required = false)
final List<String> accounts,
@ApiParam(value = "Include only violations that happened after this point in time")
@RequestParam(value = "from", required = false)
@DateTimeFormat(iso = DATE_TIME)
DateTime from,
@ApiParam(value = "Include only violations that happened up to this point in time")
@RequestParam(value = "to", required = false)
@DateTimeFormat(iso = DATE_TIME)
DateTime to,
@ApiParam(value = "Include only violations after the one with this id")
@RequestParam(value = "last-violation", required = false)
final Long lastViolation,
@ApiParam(value = "Include only violations where checked field equals this value")
@RequestParam(value = "checked", required = false)
final Boolean checked,
@ApiParam(value = "Include only violations with a certain severity")
@RequestParam(value = "severity", required = false)
final Integer severity,
@ApiParam(value = "Include only violations that are audit relevant")
@RequestParam(value = "audit-relevant", required = false)
final Boolean auditRelevant,
@ApiParam(value = "Include only violations with a certain type")
@RequestParam(value = "type", required = false)
final String type,
@PageableDefault(page = 0, size = 10, sort = "id", direction = ASC) final Pageable pageable) throws NotFoundException {
if (from == null) {
from = DateTime.now().minusWeeks(1);
}
if (to == null) {
to = DateTime.now();
}
return mapBackendToFrontendViolations(
violationService.queryViolations(
accounts, from, to, lastViolation,
checked, severity, auditRelevant, type, pageable));
}

Example 13
Project: spring-data-examples File: UserController.java View source code 6 votes vote down vote up
/**
* Equis the model with a {@link Page} of {@link User}s. Spring Data automatically populates the {@link Pageable} from
* request data according to the setup of {@link PageableHandlerMethodArgumentResolver}. Note how the defaults can be
* tweaked by using {@link PageableDefault}.
*
* @param pageable will never be {@literal null}.
* @return
*/
@ModelAttribute("users")
public Page<User> users(@PageableDefault(size = 5) Pageable pageable) {
return userManagement.findAll(pageable);
}

Example 14
Project: spring-data-solr-showcase File: SearchController.java View source code 6 votes vote down vote up
@RequestMapping("/search")
public String search(Model model, @RequestParam(value = "q", required = false) String query, @PageableDefault(
page = 0, size = ProductService.DEFAULT_PAGE_SIZE) Pageable pageable, HttpServletRequest request) {

model.addAttribute("page", productService.findByName(query, pageable));
model.addAttribute("pageable", pageable);
model.addAttribute("query", query);
return "search";
}

Example 15
Project: fuwesta File: UserCRUDController.java View source code 6 votes vote down vote up
/**
* List all users.
*
* @param model the model.
* @param pageRequest attributes about paginating.
* @return String which defines the next page.
*/
@RequestMapping(value = { URL.User.HOME, URL.User.LIST },
method = RequestMethod.GET)
public String
list(Model model,
@PageableDefault(page = 0, value = 5, sort = { "userId" },
direction = Direction.ASC) Pageable pageRequest) {
final PageWrapper<User> userList =
new PageWrapper<User>(userService.getUser(pageRequest),
URL.User.LIST);
if (userList.getSize() == 0) {
LOG.info("No user found redirect to create");
return URL.redirect(URL.User.CREATE);
}
model.addAttribute("pageRequest", pageRequest);
model.addAttribute("userList", userList);
// model.addAttribute("viewUrl", URL.User.VIEW);
// model.addAttribute("editUrl", URL.User.EDIT);
// model.addAttribute("deleteUrl", URL.User.DELETE);
return "example/user/list";
}

Example 16
Project: freezo File: WebsitesController.java View source code 6 votes vote down vote up
@RequestMapping(method = RequestMethod.GET, params = "status")
@Transactional(readOnly = true)
public Page<Website> websitesByStatus(@RequestParam("status") final Website.Status status,
@PageableDefault(size = 10) final Pageable pageable) throws InterruptedException
{
final Pageable pageInfo = updatePageable(pageable, itemsPerPage);

LOG.debug("Websites listing filtered by status: {}, {} ", status, pageInfo);

return repository.findByStatus(status, pageInfo);
}

Example 17
Project: OLS File: OntologyController.java View source code 6 votes vote down vote up
@RequestMapping(path = "", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET)
HttpEntity<PagedResources<OntologyDocument>> getOntologies(
@PageableDefault(size = 20, page = 0) Pageable pageable,
PagedResourcesAssembler assembler
) throws ResourceNotFoundException {
Page<OntologyDocument> document = ontologyRepositoryService.getAllDocuments(pageable);
return new ResponseEntity<>( assembler.toResource(document, documentAssembler), HttpStatus.OK);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值