本文整理匯總了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"));
}