当前位置: 首页>>代码示例>>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;未经允许,请勿转载。