本文整理汇总了Java中org.springframework.hateoas.Resource.add方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.add方法的具体用法?Java Resource.add怎么用?Java Resource.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.hateoas.Resource
的用法示例。
在下文中一共展示了Resource.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
public Resource<SubmissionEnvelope> process(Resource<SubmissionEnvelope> resource) {
SubmissionEnvelope submissionEnvelope = resource.getContent();
// add subresource links for each type of metadata document in a submission envelope
resource.add(getAnalysesLink(submissionEnvelope));
resource.add(getAssaysLink(submissionEnvelope));
resource.add(getFilesLink(submissionEnvelope));
resource.add(getProjectsLink(submissionEnvelope));
resource.add(getProtocolsLink(submissionEnvelope));
resource.add(getSamplesLink(submissionEnvelope));
// add subresource links for events that occur in response to state transitions
submissionEnvelope.allowedStateTransitions().stream()
.map(submissionState -> getStateTransitionLink(submissionEnvelope, submissionState))
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(resource::add);
return resource;
}
示例2: process
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
public Resource<PackageMetadata> process(Resource<PackageMetadata> packageMetadataResource) {
Link installLink = linkTo(
methodOn(PackageController.class).install(packageMetadataResource.getContent().getId(), null))
.withRel("install");
packageMetadataResource.add(installLink);
return packageMetadataResource;
}
示例3: process
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
public Resource<PackageSummary> process(Resource<PackageSummary> packageSummaryResource) {
Link link = linkTo(
methodOn(PackageController.class).install(Long.valueOf(packageSummaryResource.getContent().getId()),
null))
.withRel("install");
packageSummaryResource.add(link);
return packageSummaryResource;
}
示例4: movieProcessor
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Bean
public ResourceProcessor<Resource<User>> movieProcessor() {
return new ResourceProcessor<Resource<User>>() {
@Override
public Resource<User> process(Resource<User> resource) {
resource.add(new Link("/movie/movies", "movies"));
return resource;
}
};
}
示例5: retrieveUser
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@GetMapping("/users/{id}")
public Resource<User> retrieveUser(@PathVariable int id) {
User user = service.findOne(id);
if(user==null)
throw new UserNotFoundException("id-"+ id);
//"all-users", SERVER_PATH + "/users"
//retrieveAllUsers
Resource<User> resource = new Resource<User>(user);
ControllerLinkBuilder linkTo =
linkTo(methodOn(this.getClass()).retrieveAllUsers());
resource.add(linkTo.withRel("all-users"));
//HATEOAS
return resource;
}
示例6: addLinks
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
/**
* Define links to add to every individual {@link Resource}.
*
* @param resource
*/
@Override
protected void addLinks(Resource<EmployeeWithManager> resource) {
resource.add(linkTo(methodOn(EmployeeController.class).findDetailedEmployee(resource.getContent().getId())).withSelfRel());
resource.add(linkTo(methodOn(EmployeeController.class).findOne(resource.getContent().getId())).withRel("summary"));
resource.add(linkTo(methodOn(EmployeeController.class).findAllDetailedEmployees()).withRel("detailedEmployees"));
}
开发者ID:spring-projects,项目名称:spring-hateoas-examples,代码行数:13,代码来源:EmployeeWithManagerResourceAssembler.java
示例7: doSomething
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@PostMapping(path = "/some/{someId}/other/{otherId}")
public ResponseEntity<Resource<TestDateHolder>> doSomething(@PathVariable String someId,
@PathVariable Integer otherId,
@RequestBody TestDateHolder testDateHolder) {
testDateHolder.setId(UUID.randomUUID().toString());
Resource<TestDateHolder> resource = new Resource<>(testDateHolder);
resource.add(linkTo(methodOn(TestController.class).doSomething(someId, otherId, null)).withSelfRel());
return ResponseEntity.ok(resource);
}
示例8: retrieveTodo
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@GetMapping(path = "/users/{name}/todos/{id}")
public Resource<Todo> retrieveTodo(@PathVariable String name, @PathVariable int id) {
Todo todo = todoService.retrieveTodo(id);
if (todo == null) {
throw new TodoNotFoundException("Todo Not Found");
}
Resource<com.mastering.spring.springboot.bean.Todo> todoResource = new Resource<com.mastering.spring.springboot.bean.Todo>(todo);
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveTodos(name));
todoResource.add(linkTo.withRel("parent"));
return todoResource;
}
示例9: addLinks
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
protected void addLinks(Resource<Manifest> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).status(null)).withRel("status"));
}
示例10: addLinks
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
protected void addLinks(Resource<Info> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).manifest(null)).withRel("manifest"));
}
示例11: addLinks
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
protected void addLinks(Resource<Release> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(ReleaseController.class).status(null)).withRel("status"));
}
示例12: retrieveUser
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@GetMapping("/jpa/users/{id}")
public Resource<User> retrieveUser(@PathVariable int id) {
Optional<User> user = userRepository.findById(id);
if (!user.isPresent())
throw new UserNotFoundException("id-" + id);
// "all-users", SERVER_PATH + "/users"
// retrieveAllUsers
Resource<User> resource = new Resource<User>(user.get());
ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllUsers());
resource.add(linkTo.withRel("all-users"));
// HATEOAS
return resource;
}
示例13: process
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
public Resource<Assay> process(Resource<Assay> assayResource) {
Assay assay = assayResource.getContent();
assayResource.add(getFileReferenceLink(assay));
return assayResource;
}
示例14: process
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
public Resource<Analysis> process(Resource<Analysis> analysisResource) {
Analysis analysis = analysisResource.getContent();
analysisResource.add(getBundleReferencesLink(analysis), getFileReferenceLink(analysis));
return analysisResource;
}
示例15: addLinks
import org.springframework.hateoas.Resource; //导入方法依赖的package包/类
@Override
protected void addLinks(Resource<PackageMetadata> resource) {
super.addLinks(resource);
resource.add(linkTo(methodOn(PackageController.class).install(null)).withRel("install"));
}