org.springframework.data.web.PagedResourcesAssembler Java Examples
The following examples show how to use
org.springframework.data.web.PagedResourcesAssembler.
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: EventController.java From sos with Apache License 2.0 | 6 votes |
@GetMapping("events") HttpEntity<Resources<?>> events(PagedResourcesAssembler<AbstractEvent<?>> assembler, @SortDefault("publicationDate") Pageable pageable, @RequestParam(required = false) @DateTimeFormat(iso = ISO.DATE_TIME) LocalDateTime since, @RequestParam(required = false) String type) { QAbstractEvent $ = QAbstractEvent.abstractEvent; BooleanBuilder builder = new BooleanBuilder(); // Apply date Optional.ofNullable(since).ifPresent(it -> builder.and($.publicationDate.after(it))); // Apply type Optional.ofNullable(type) // .flatMap(events::findEventTypeByName) // .ifPresent(it -> builder.and($.instanceOf(it))); Page<AbstractEvent<?>> result = events.findAll(builder, pageable); PagedResources<Resource<AbstractEvent<?>>> resource = assembler.toResource(result, event -> toResource(event)); resource .add(links.linkTo(methodOn(EventController.class).events(assembler, pageable, since, type)).withRel("events")); return ResponseEntity.ok(resource); }
Example #2
Source File: AppRegistryController.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
/** * List app registrations. Optional type and findByTaskNameContains parameters can be passed to do * filtering. Search parameter only filters by {@code AppRegistration} name field. * * @param pageable Pagination information * @param pagedResourcesAssembler the resource assembler for app registrations * @param type the application type: source, sink, processor, task * @param search optional findByTaskNameContains parameter * @return the list of registered applications */ @RequestMapping(method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public PagedModel<? extends AppRegistrationResource> list( Pageable pageable, PagedResourcesAssembler<AppRegistration> pagedResourcesAssembler, @RequestParam(value = "type", required = false) ApplicationType type, @RequestParam(required = false) String search, @RequestParam(required = false) boolean defaultVersion) { Page<AppRegistration> pagedRegistrations = (defaultVersion) ? this.appRegistryService.findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue(type, search, pageable) : this.appRegistryService.findAllByTypeAndNameIsLike(type, search, pageable); return pagedResourcesAssembler.toModel(pagedRegistrations, this.assembler); }
Example #3
Source File: RuntimeAppsController.java From spring-cloud-dashboard with Apache License 2.0 | 6 votes |
@RequestMapping public PagedResources<AppStatusResource> list(PagedResourcesAssembler<AppStatus> assembler) { List<AppStatus> values = new ArrayList<>(); for (ApplicationDefinition applicationDefinition : this.applicationDefinitionRepository.findAll()) { String key = forApplicationDefinition(applicationDefinition); String id = this.deploymentIdRepository.findOne(key); if (id != null) { values.add(appDeployer.status(id)); } } Collections.sort(values, new Comparator<AppStatus>() { @Override public int compare(AppStatus o1, AppStatus o2) { return o1.getDeploymentId().compareTo(o2.getDeploymentId()); } }); return assembler.toResource(new PageImpl<>(values), statusAssembler); }
Example #4
Source File: AppRegistryController.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
/** * Register all applications listed in a properties file or provided as key/value pairs. * * @param pageable Pagination information * @param pagedResourcesAssembler the resource asembly for app registrations * @param uri URI for the properties file * @param apps key/value pairs representing applications, separated by newlines * @param force if {@code true}, overwrites any pre-existing registrations * @return the collection of registered applications * @throws IOException if can't store the Properties object to byte output stream */ @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public PagedModel<? extends AppRegistrationResource> registerAll( Pageable pageable, PagedResourcesAssembler<AppRegistration> pagedResourcesAssembler, @RequestParam(value = "uri", required = false) String uri, @RequestParam(value = "apps", required = false) String apps, @RequestParam(value = "force", defaultValue = "false") boolean force) throws IOException { List<AppRegistration> registrations = new ArrayList<>(); if (StringUtils.hasText(uri)) { registrations.addAll(this.appRegistryService.importAll(force, this.resourceLoader.getResource(uri))); } else if (!StringUtils.isEmpty(apps)) { ByteArrayResource bar = new ByteArrayResource(apps.getBytes()); registrations.addAll(this.appRegistryService.importAll(force, bar)); } Collections.sort(registrations); prefetchMetadata(registrations); return pagedResourcesAssembler.toModel(new PageImpl<>(registrations, pageable, registrations.size()), this.assembler); }
Example #5
Source File: JobExecutionController.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
/** * Retrieve all task job executions with the task name specified * * @param jobName name of the job. SQL server specific wildcards are enabled (eg.: myJob%, * m_Job, ...) * @param pageable page-able collection of {@code TaskJobExecution}s. * @param assembler for the {@link TaskJobExecution}s * @return list task/job executions with the specified jobName. * @throws NoSuchJobException if the job with the given name does not exist. */ @RequestMapping(value = "", method = RequestMethod.GET, produces = "application/json") @ResponseStatus(HttpStatus.OK) public PagedModel<JobExecutionResource> retrieveJobsByParameters( @RequestParam(value = "name", required = false) String jobName, @RequestParam(value = "status", required = false) BatchStatus status, Pageable pageable, PagedResourcesAssembler<TaskJobExecution> assembler) throws NoSuchJobException, NoSuchJobExecutionException { List<TaskJobExecution> jobExecutions; Page<TaskJobExecution> page; if (jobName == null && status == null) { jobExecutions = taskJobService.listJobExecutions(pageable); page = new PageImpl<>(jobExecutions, pageable, taskJobService.countJobExecutions()); } else { jobExecutions = taskJobService.listJobExecutionsForJob(pageable, jobName, status); page = new PageImpl<>(jobExecutions, pageable, taskJobService.countJobExecutionsForJob(jobName, status)); } return assembler.toModel(page, jobAssembler); }
Example #6
Source File: LockingAndVersioningRestController.java From spring-content with Apache License 2.0 | 6 votes |
public static Resources<?> toResources(Iterable<?> source, PersistentEntityResourceAssembler assembler, PagedResourcesAssembler resourcesAssembler, Class<?> domainType, Link baseLink) { if (source instanceof Page) { Page<Object> page = (Page<Object>) source; return entitiesToResources(page, assembler, resourcesAssembler, domainType, baseLink); } else if (source instanceof Iterable) { return entitiesToResources((Iterable<Object>) source, assembler, domainType); } else { return new Resources(EMPTY_RESOURCE_LIST); } }
Example #7
Source File: AuditRecordController.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
/** * Return a page-able list of {@link AuditRecordResource}s. * * @param pageable Pagination information * @param assembler assembler for {@link AuditRecord} * @param actions Optional. For which {@link AuditActionType}s do you want to retrieve * {@link AuditRecord}s * @param fromDate Optional. The fromDate must be {@link DateTimeFormatter}.ISO_DATE_TIME * formatted. eg.: 2019-02-03T00:00:30 * @param toDate Optional. The toDate must be {@link DateTimeFormatter}.ISO_DATE_TIME * formatted. eg.: 2019-02-05T23:59:30 * @param operations Optional. For which {@link AuditOperationType}s do you want to * retrieve {@link AuditRecord}s * @return list of audit records */ @RequestMapping(value = "", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public PagedModel<AuditRecordResource> list(Pageable pageable, @RequestParam(required = false) AuditActionType[] actions, @RequestParam(required = false) AuditOperationType[] operations, @RequestParam(required = false) String fromDate, @RequestParam(required = false) String toDate, PagedResourcesAssembler<AuditRecord> assembler) { final Instant fromDateAsInstant = paresStringToInstant(fromDate); final Instant toDateAsInstant = paresStringToInstant(toDate); if (fromDate != null && toDate != null && fromDate.compareTo(toDate) > 0) { throw new InvalidDateRangeException("The fromDate cannot be after the toDate."); } final Page<AuditRecord> auditRecords = this.auditRecordService .findAuditRecordByAuditOperationTypeAndAuditActionTypeAndDate(pageable, actions, operations, fromDateAsInstant, toDateAsInstant); return assembler.toModel(auditRecords, new Assembler(auditRecords)); }
Example #8
Source File: ContentSearchRestController.java From spring-content with Apache License 2.0 | 6 votes |
public static Resources<?> toResources(Iterable<?> source, PersistentEntityResourceAssembler assembler, PagedResourcesAssembler resourcesAssembler, Class<?> domainType, Link baseLink) { if (source instanceof Page) { Page<Object> page = (Page<Object>) source; return entitiesToResources(page, assembler, resourcesAssembler, domainType, baseLink); } else if (source instanceof Iterable) { return entitiesToResources((Iterable<Object>) source, assembler, domainType); } else { return new Resources(EMPTY_RESOURCE_LIST); } }
Example #9
Source File: PublicBlogRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
/** * Returns blog post approved comments with pagination. * @param id * @param pageable * @param assembler * @return * @throws ResourceNotFoundException */ @RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_BLOGS_BLOG_COMMENTS) public HttpEntity<PagedResources<PublicCommentResource>> getBlogApprovedCommentPosts( @PathVariable("blogId") String id, @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable, PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException { getPublishedBlogById(id); //security check Page<CommentPost> commentPosts = this.commentPostRepository.findByBlogPostIdAndStatusOrderByCreatedTimeAsc(id, CommentStatusType.APPROVED, pageable); return new ResponseEntity<>(assembler.toResource(commentPosts, publicCommentResourceAssembler), HttpStatus.OK); }
Example #10
Source File: FriendController.java From training with Apache License 2.0 | 5 votes |
@RequestMapping(path = "/users/{userId}/friends", method = RequestMethod.GET) public HttpEntity<?> getFriends(@PathVariable Long userId, Pageable pageable, PagedResourcesAssembler<Friend> assembler) { return Optional.of(friendRepository.findAllByUserId(userId, pageable)) .map(a -> new ResponseEntity<>(assembler.toResource(a), HttpStatus.OK)) .orElseThrow(() -> new RuntimeException("Could not retrieve friends for the supplied user id")); }
Example #11
Source File: TaskDefinitionController.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Return a page-able list of {@link TaskDefinitionResource} defined tasks. * * @param pageable page-able collection of {@code TaskDefinitionResource} * @param search optional findByTaskNameContains parameter * @param manifest optional manifest flag to indicate whether the latest task execution requires task manifest update * @param assembler assembler for the {@link TaskDefinition} * @return a list of task definitions */ @RequestMapping(value = "", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public PagedModel<TaskDefinitionResource> list(Pageable pageable, @RequestParam(required = false) String search, @RequestParam(required = false) boolean manifest, PagedResourcesAssembler<TaskExecutionAwareTaskDefinition> assembler) { final Page<TaskDefinition> taskDefinitions; if (search != null) { taskDefinitions = repository.findByTaskNameContains(search, pageable); } else { taskDefinitions = repository.findAll(pageable); } final java.util.HashMap<String, TaskDefinition> taskDefinitionMap = new java.util.HashMap<>(); for (TaskDefinition taskDefinition : taskDefinitions) { taskDefinitionMap.put(taskDefinition.getName(), taskDefinition); } final List<TaskExecution> taskExecutions; if (!taskDefinitionMap.isEmpty()) { taskExecutions = this.explorer.getLatestTaskExecutionsByTaskNames( taskDefinitionMap.keySet().toArray(new String[taskDefinitionMap.size()])); } else { taskExecutions = null; } final Page<TaskExecutionAwareTaskDefinition> taskExecutionAwareTaskDefinitions = taskDefinitions .map(new TaskDefinitionConverter(taskExecutions)); PagedModel<TaskDefinitionResource> taskDefinitionResources = assembler.toModel(taskExecutionAwareTaskDefinitions, new Assembler(manifest)); // Classify the composed task elements by iterating through the task definitions that are part of this page. updateComposedTaskElement(taskDefinitionResources.getContent()); return taskDefinitionResources; }
Example #12
Source File: StreamDefinitionController.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Return a list of related stream definition resources based on the given stream name. * Related streams include the main stream and the tap stream(s) on the main stream. * * @param pageable Pagination information * @param name the name of an existing stream definition (required) * @param nested if should recursively findByTaskNameContains for related stream definitions * @param assembler resource assembler for stream definition * @return a list of related stream definitions */ @RequestMapping(value = "/{name}/related", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public PagedModel<StreamDefinitionResource> listRelated(Pageable pageable, @PathVariable("name") String name, @RequestParam(value = "nested", required = false, defaultValue = "false") boolean nested, PagedResourcesAssembler<StreamDefinition> assembler) { List<StreamDefinition> result = this.streamService.findRelatedStreams(name, nested); Page<StreamDefinition> page = new PageImpl<>(result, pageable, result.size()); return assembler.toModel(page, new Assembler(page)); }
Example #13
Source File: JobInstanceController.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Return a page-able list of {@link JobInstanceResource} defined jobs. * * @param jobName the name of the job * @param pageable page-able collection of {@link JobInstance}s. * @param assembler for the {@link JobInstance}s * @return a list of Job Instance * @throws NoSuchJobException if the job for jobName specified does not exist. */ @RequestMapping(value = "", method = RequestMethod.GET, params = "name") @ResponseStatus(HttpStatus.OK) public PagedModel<JobInstanceResource> list(@RequestParam("name") String jobName, Pageable pageable, PagedResourcesAssembler<JobInstanceExecutions> assembler) throws NoSuchJobException { List<JobInstanceExecutions> jobInstances = taskJobService.listTaskJobInstancesForJobName(pageable, jobName); Page<JobInstanceExecutions> page = new PageImpl<>(jobInstances, pageable, taskJobService.countJobInstances(jobName)); return assembler.toModel(page, jobAssembler); }
Example #14
Source File: WebsiteRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_PROFILES_USER_COMMENTS) public HttpEntity<PagedResources<PublicCommentResource>> getUserApprovedCommentPosts( @PathVariable("userId") String userId, @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable, PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException { Page<CommentPost> commentPosts = this.commentPostRepository.findByAuthorIdAndStatusOrderByCreatedTimeDesc( userId, CommentStatusType.APPROVED, pageable); return new ResponseEntity<>(assembler.toResource(commentPosts, publicCommentResourceAssembler), HttpStatus.OK); }
Example #15
Source File: PublicBlogResourceAssembler.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@Inject public PublicBlogResourceAssembler( CommentPostRepository commentPostRepository, PagedResourcesAssembler<CommentPost> assembler) { this.commentPostRepository = commentPostRepository; this.assembler = assembler; }
Example #16
Source File: PublicBlogRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
/** * Returns public blog posts with pagination. * * @param pageable * @param assembler * @return */ @RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_SITE_BLOGS) public HttpEntity<PagedResources<PublicBlogResource>> getPublicBlogPosts( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0)Pageable pageable, PagedResourcesAssembler<BlogPost> assembler) { Page<BlogPost> blogPosts = this.blogPostRepository.findByPublishedIsTrueOrderByPublishedTimeDesc(pageable); return new ResponseEntity<>(assembler.toResource(blogPosts, publicBlogResourceAssembler), HttpStatus.OK); }
Example #17
Source File: TaskExecutionController.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
/** * Retrieve all task executions with the task name specified * * @param taskName name of the task * @param pageable page-able collection of {@code TaskExecution}s. * @param assembler for the {@link TaskExecution}s * @return the paged list of task executions */ @RequestMapping(value = "", method = RequestMethod.GET, params = "name") @ResponseStatus(HttpStatus.OK) public PagedModel<TaskExecutionResource> retrieveTasksByName(@RequestParam("name") String taskName, Pageable pageable, PagedResourcesAssembler<TaskJobExecutionRel> assembler) { this.taskDefinitionRepository.findById(taskName) .orElseThrow(() -> new NoSuchTaskDefinitionException(taskName)); Page<TaskExecution> taskExecutions = this.explorer.findTaskExecutionsByName(taskName, pageable); Page<TaskJobExecutionRel> result = getPageableRelationships(taskExecutions, pageable); return assembler.toModel(result, this.taskAssembler); }
Example #18
Source File: BlogRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_BLOGS) public HttpEntity<PagedResources<BlogResource>> getBlogPosts( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable, PagedResourcesAssembler<BlogPost> assembler) { Page<BlogPost> blogPosts = this.blogPostRepository.findAll(pageable); return new ResponseEntity<>(assembler.toResource(blogPosts, blogResourceAssembler), HttpStatus.OK); }
Example #19
Source File: BlogRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_BLOGS_BLOG_COMMENTS) public HttpEntity<PagedResources<CommentResource>> getCommentPostsByBlogPostId( @PathVariable("blogId") String blogId, @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable, PagedResourcesAssembler<CommentPost> assembler) throws ResourceNotFoundException { Page<CommentPost> commentPosts = commentPostRepository.findByBlogPostIdOrderByCreatedTimeDesc(blogId, pageable); return new ResponseEntity<>(assembler.toResource(commentPosts, commentResourceAssembler), HttpStatus.OK); }
Example #20
Source File: CommentRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_COMMENTS) public HttpEntity<PagedResources<CommentResource>> getCommentPosts( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0, sort="createdTime", direction=Direction.DESC) Pageable pageable, PagedResourcesAssembler<CommentPost> assembler) { Page<CommentPost> commentPosts = this.commentPostRepository.findAll(pageable); return new ResponseEntity<>(assembler.toResource(commentPosts, commentResourceAssembler), HttpStatus.OK); }
Example #21
Source File: UserRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_ADMIN_USERS) public HttpEntity<PagedResources<UserResource>> getUserAccounts( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0, sort="createdTime") Pageable pageable, PagedResourcesAssembler<UserAccount> assembler) { Page<UserAccount> userAccounts = this.userAccountRepository.findAll(pageable); return new ResponseEntity<>(assembler.toResource(userAccounts, userResourceAssembler), HttpStatus.OK); }
Example #22
Source File: UserCommentRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
/** * Returns current user comments with pagination. * * @param pageable * @param assembler * @return */ @RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_USER_COMMENTS) public HttpEntity<PagedResources<UserCommentResource>> getCurrentUserComments( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0) Pageable pageable, PagedResourcesAssembler<CommentPost> assembler) { UserAccount currentUser = getCurrentAuthenticatedUser(); Page<CommentPost> comments = commentPostRepository.findByAuthorIdOrderByCreatedTimeDesc(currentUser.getUserId(), pageable); return new ResponseEntity<>(assembler.toResource(comments, userCommentResourceAssembler), HttpStatus.OK); }
Example #23
Source File: UserAccountResourceAssembler.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@Inject public UserAccountResourceAssembler( UserSocialConnectionRepository userSocialConnectionRepository, PagedResourcesAssembler<CommentPost> assembler) { this.userSocialConnectionRepository = userSocialConnectionRepository; this.assembler = assembler; }
Example #24
Source File: AuthorBlogCommentRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@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 #25
Source File: AuthorBlogRestController.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
@RequestMapping(method = RequestMethod.GET, value = ApiUrls.URL_AUTHOR_BLOGS) public HttpEntity<PagedResources<AuthorBlogResource>> getBlogPosts( @PageableDefault(size = UtilConstants.DEFAULT_RETURN_RECORD_COUNT, page = 0)Pageable pageable, PagedResourcesAssembler<BlogPost> assembler) { UserAccount currentUser = getCurrentAuthenticatedAuthor(); Page<BlogPost> blogPosts = this.blogPostRepository.findByAuthorIdOrderByCreatedTimeDesc(currentUser.getUserId(), pageable); return new ResponseEntity<>(assembler.toResource(blogPosts, authorBlogResourceAssembler), HttpStatus.OK); }
Example #26
Source File: ContentSearchRestController.java From spring-content with Apache License 2.0 | 5 votes |
protected static Resources<?> entitiesToResources(Page<Object> page, PersistentEntityResourceAssembler assembler, PagedResourcesAssembler resourcesAssembler, Class<?> domainType, Link baseLink) { if (page.getContent().isEmpty()) { return resourcesAssembler.toEmptyResource(page, domainType, baseLink); } return baseLink == null ? resourcesAssembler.toResource(page, assembler) : resourcesAssembler.toResource(page, assembler, baseLink); }
Example #27
Source File: FriendController.java From training with Apache License 2.0 | 5 votes |
@RequestMapping(path = "/users/{userId}/friends", method = RequestMethod.GET) public HttpEntity<?> getFriends(@PathVariable Long userId, Pageable pageable, PagedResourcesAssembler<Friend> assembler) { return Optional.of(friendRepository.findAllByUserId(userId, pageable)) .map(a -> new ResponseEntity<>(assembler.toResource(a), HttpStatus.OK)) .orElseThrow(() -> new RuntimeException("Could not retrieve friends for the supplied user id")); }
Example #28
Source File: NotesController.java From restdocs-raml with MIT License | 5 votes |
@Autowired public NotesController(NoteRepository noteRepository, TagRepository tagRepository, NoteResourceAssembler noteResourceAssembler, TagResourceAssembler tagResourceAssembler, PagedResourcesAssembler<Note> pagedResourcesAssembler) { this.noteRepository = noteRepository; this.tagRepository = tagRepository; this.noteResourceAssembler = noteResourceAssembler; this.tagResourceAssembler = tagResourceAssembler; this.pagedResourcesAssembler = pagedResourcesAssembler; }
Example #29
Source File: TagsController.java From restdocs-raml with MIT License | 5 votes |
@Autowired public TagsController(TagRepository repository, NoteResourceAssembler noteResourceAssembler, TagResourceAssembler tagResourceAssembler, PagedResourcesAssembler<Tag> pagedResourcesAssembler) { this.repository = repository; this.noteResourceAssembler = noteResourceAssembler; this.tagResourceAssembler = tagResourceAssembler; this.pagedResourcesAssembler = pagedResourcesAssembler; }
Example #30
Source File: RuntimeAppsController.java From spring-cloud-dashboard with Apache License 2.0 | 5 votes |
@RequestMapping public PagedResources<AppInstanceStatusResource> list(@PathVariable String appId, PagedResourcesAssembler<AppInstanceStatus> assembler) { AppStatus status = appDeployer.status(appId); if (status != null) { List<AppInstanceStatus> appInstanceStatuses = new ArrayList<>(status.getInstances().values()); Collections.sort(appInstanceStatuses, INSTANCE_SORTER); return assembler.toResource(new PageImpl<>(appInstanceStatuses), new InstanceAssembler(status)); } throw new ResourceNotFoundException(); }