當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource.add方法代碼示例

本文整理匯總了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;
}
 
開發者ID:HumanCellAtlas,項目名稱:ingest-core,代碼行數:21,代碼來源:SubmissionEnvelopeResourceProcessor.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:9,代碼來源:PackageMetadataResourceProcessor.java

示例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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:10,代碼來源:PackageSummaryResourceProcessor.java

示例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;
        }
    };
}
 
開發者ID:pawankumar8608,項目名稱:spring-cloud-microservices-docker,代碼行數:12,代碼來源:Application.java

示例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;
}
 
開發者ID:in28minutes,項目名稱:spring-web-services,代碼行數:22,代碼來源:UserResource.java

示例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);
}
 
開發者ID:ePages-de,項目名稱:restdocs-raml,代碼行數:10,代碼來源:RamlResourceSnippetIntegrationTest.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Spring-5.0,代碼行數:13,代碼來源:TodoController.java

示例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"));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:6,代碼來源:ManifestResourceAssembler.java

示例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"));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:6,代碼來源:InfoResourceAssembler.java

示例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"));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:6,代碼來源:ReleaseResourceAssembler.java

示例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;
}
 
開發者ID:in28minutes,項目名稱:spring-web-services,代碼行數:20,代碼來源:UserJPAResource.java

示例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;
}
 
開發者ID:HumanCellAtlas,項目名稱:ingest-core,代碼行數:6,代碼來源:AssayResourceProcessor.java

示例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;
}
 
開發者ID:HumanCellAtlas,項目名稱:ingest-core,代碼行數:6,代碼來源:AnalysisResourceProcessor.java

示例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"));

}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:8,代碼來源:PackageMetadataResourceAssembler.java


注:本文中的org.springframework.hateoas.Resource.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。