本文整理匯總了Java中org.springframework.hateoas.PagedResources.add方法的典型用法代碼示例。如果您正苦於以下問題:Java PagedResources.add方法的具體用法?Java PagedResources.add怎麽用?Java PagedResources.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.hateoas.PagedResources
的用法示例。
在下文中一共展示了PagedResources.add方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: events
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@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);
}
示例2: lightsideExports
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(value = "/database/{databaseName}/lightsideExports", method=RequestMethod.GET)
@ResponseBody
PagedResources<Resource<BrowsingLightsideStubsResource>> lightsideExports(
@PathVariable("databaseName") String databaseName,
HttpServletRequest hsr, HttpSession session) {
registerDb(hsr,session, databaseName);
String lightsideDataDirectory = lsDataDirectory();
List<BrowsingLightsideStubsResource> exported = BrowsingLightsideStubsResource.findPreviouslyExportedLightside(lightsideDataDirectory);
Page<BrowsingLightsideStubsResource> p = new PageImpl<BrowsingLightsideStubsResource>(exported, new PageRequest(0,100), exported.size());
for (BrowsingLightsideStubsResource ltstub: p) {
ltstub.add(makeLink1Arg("/browsing/action/database/" + databaseName + "/deleteLightside", "Delete this export", "exportFilename", ltstub.getName()));
ltstub.add(makeLightsideDownloadLink("/browsing/action/database/" + databaseName + "/downloadLightside", ltstub.isAnnotated(), "Download", "exportFilename", ltstub.getName()));
}
PagedResources<Resource<BrowsingLightsideStubsResource>> ret = praLSAssembler.toResource(p);
ret.add(makeLink("/browsing/action/database/" + databaseName + "/uploadLightside{?file_annotatedFileForUpload}", "Upload"));
return ret;
}
示例3: getSubnets
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<PagedResources<SubnetResource>> getSubnets(@RequestParam(required = false) String ip,
@RequestParam(required = false) Long size, @PathVariable @NotNull Integer infraId, Pageable pageable,
PagedResourcesAssembler<Subnet> pagedAssembler) {
Page<Subnet> subnets;
if (! Strings.isNullOrEmpty(ip)) {
long ip4 = IpAddress.toLong(ip);
if (size == null) {
subnets = this.repository.findAllByInfraIdAndIp(infraId, ip4, pageable);
} else {
subnets = this.repository.findAllByInfraIdAndIpAndSize(infraId, ip4, size, pageable);
}
} else {
subnets = this.repository.findAllByInfraId(infraId, pageable);
}
PagedResources<SubnetResource> page = pagedAssembler.toResource(subnets, assembler);
page.add(InfrastructureResourceAssembler.link(infraId));
return new ResponseEntity<>(page, HttpStatus.OK);
}
示例4: dpContributions
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(value = "/database/{databaseName}/dpContributions/{childOf}", method = RequestMethod.GET)
@ResponseBody
PagedResources<Resource<BrowsingContributionResource>> dpContributions(@RequestParam(value= "page", defaultValue = "0") int page,
@RequestParam(value= "size", defaultValue="20") int size,
@PathVariable("databaseName") String databaseName,
@PathVariable("childOf") Long dpId
, HttpServletRequest hsr, HttpSession session) {
registerDb(hsr,session, databaseName);
PageRequest p = new PageRequest(page,size, new Sort("startTime"));
Optional<DiscoursePart> parent = discoursePartRepository.findOne(dpId);
if (parent.isPresent()) {
Page<BrowsingContributionResource> lbcr =
discoursePartContributionRepository.findByDiscoursePartSorted(parent.get(), p)
.map(dpc -> dpc.getContribution())
.map( c -> new BrowsingContributionResource(c,annoService));
lbcr.forEach(bcr -> {if (bcr.getDiscourseParts().size() > 1) { bcr._getDiscourseParts().forEach(
(dpId2, dpName2) -> {
if (dpId2 != dpId) { bcr.add(
makeLink("/browsing/database/" + databaseName + "/dpContributions/" + dpId2 , "Also in:" + dpName2)); }} ); }} );
PagedResources<Resource<BrowsingContributionResource>> response = praContributionAssembler.toResource(lbcr);
//response.add(makeLink("/browsing/subDiscourseParts{?page,size,repoType,annoType}", "search"));
response.add(makeLink("/browsing/database/" + databaseName + "/usersInDiscoursePart/" + dpId, "show users"));
return response;
} else {
return null;
}
}
示例5: getRanges
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(method=RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public PagedResources<RangeResource> getRanges(@PathVariable Integer infraId, @PathVariable Long zoneId, Pageable pageable, PagedResourcesAssembler<Range> pagedAssembler) {
Page<Range> ranges = this.repository.findByInfraIdAndZoneId(infraId, zoneId, pageable);
PagedResources<RangeResource> page = pagedAssembler.toResource(ranges, assembler);
page.add(ZoneResourceAssembler.link(infraId, zoneId));
return page;
}
示例6: getZones
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(method=RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public PagedResources<ZoneResource> getZones(@PathVariable @NotNull Integer infraId, Pageable pageable, PagedResourcesAssembler<Zone> pagedAssembler) {
Page<Zone> zones = this.repository.findByInfraId(infraId, pageable);
PagedResources<ZoneResource> page = pagedAssembler.toResource(zones, assembler);
page.add(InfrastructureResourceAssembler.link(infraId));
return page;
}
示例7: getAddresses
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(method=RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE})
public PagedResources<AddressResource> getAddresses(@RequestParam(required = false) RequestMode mode, @PathVariable Integer infraId, @PathVariable Long subnetId, Pageable pageable, PagedResourcesAssembler<Address> pagedAssembler) {
Page<Address> addresses;
if (RequestMode.FREE.equals(mode)) {
addresses = this.service.findFreeBySubnetId(subnetId, pageable);
} else {
addresses = this.repository.findBySubnetId(subnetId, pageable);
}
for (Address address : addresses) {
address.setInfraId(infraId);
}
PagedResources<AddressResource> page = pagedAssembler.toResource(addresses, assembler);
page.add(SubnetResourceAssembler.link(infraId, subnetId));
return page;
}
示例8: getAddressPlans
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<PagedResources<AddressPlanResource>> getAddressPlans(@PathVariable @NotNull Integer infraId, Pageable pageable,
PagedResourcesAssembler<AddressPlan> pagedAssembler) {
Page<AddressPlan> subnets = this.repository.findAllByInfraId(infraId, pageable);
PagedResources<AddressPlanResource> page = pagedAssembler.toResource(subnets, assembler);
page.add(InfrastructureResourceAssembler.link(infraId));
return new ResponseEntity<>(page, HttpStatus.OK);
}
示例9: subDiscourseParts
import org.springframework.hateoas.PagedResources; //導入方法依賴的package包/類
@RequestMapping(value = "/database/{databaseName}/subDiscourseParts/{childOf}", method = RequestMethod.GET)
@ResponseBody
PagedResources<Resource<BrowsingDiscoursePartResource>> subDiscourseParts(@RequestParam(value= "page", defaultValue = "0") int page,
@RequestParam(value= "size", defaultValue="20") int size,
@PathVariable("databaseName") String databaseName,
@PathVariable("childOf") Long dpId,
HttpServletRequest hsr, HttpSession session) {
registerDb(hsr,session, databaseName);
PageRequest p = new PageRequest(page,size, new Sort("startTime"));
Optional<DiscoursePart> parent = discoursePartRepository.findOne(dpId);
if (parent.isPresent()) {
Page<BrowsingDiscoursePartResource> repoResources =
discoursePartRelationRepository.findAllTargetsBySource(parent.get(), p)
/*.map(dpr -> dpr.getTarget())*/.map(dp -> new BrowsingDiscoursePartResource(dp, annoService));
repoResources.forEach(bdp -> bdp.fillInUserInteractions(discoursePartInteractionRepository, annoService));
repoResources.forEach(
bcr -> {
if (bcr.getContainingDiscourseParts().size() > 1) {
bcr._getContainingDiscourseParts().forEach(
(childDpId,childDpName) -> {
bcr.add(
makeLink("/browsing/database/" + databaseName + "/subDiscourseParts/" + childDpId , "Contained in: " + childDpName));
}
);
}
//if (bcr.getContributionCount() > 0) {
Link check3 = makeBratExportNameLink("/browsing/action/database/" + databaseName + "/exportBratItem","chk:Export to BRAT", parent.get().getName(), Long.toString(bcr._getDpId()));
bcr.add(check3);
//}
//Link check = makeLink1Arg("/browsing/action/exportLightside","chk:Export to Lightside: no annotations", "parentDpId", Long.toString(bcr._getDpId()));
//Link check2 = makeLink2Arg("/browsing/action/exportLightside","chk:Export to Lightside: with annotations", "withAnnotations", "true", "parentDpId", Long.toString(bcr._getDpId()));
Link check = makeLightsideExportNameLink("/browsing/action/database/" + databaseName + "/exportLightside", false, "chk:Export to Lightside, no annotations", bcr.getName(), Long.toString(bcr._getDpId()));
Link check2 = makeLightsideExportNameLink("/browsing/action/database/" + databaseName + "/exportLightside", true, "chk:Export to Lightside, with annotations", bcr.getName(), Long.toString(bcr._getDpId()));
bcr.add(check);
bcr.add(check2);
}
);
PagedResources<Resource<BrowsingDiscoursePartResource>> response = praDiscoursePartAssembler.toResource(repoResources);
/*
* Disabling exportBrat link overall -- instead add for each thread item as a checkbox
*
long threadcount = 0L;
for (BrowsingDiscoursePartResource bdpr: repoResources) {
threadcount += bdpr.getContributionCount();
}
if (threadcount > 0) {
response.add(makeLink1Arg("/browsing/action/exportBrat", "Export these all to BRAT", "parentDpId", dpId.toString()));
}
*/
response.add(makeLink("/browsing/database/" + databaseName + "/usersInDiscoursePart/" + dpId, "show users"));
return response;
} else {
logger.info("subdiscourseParts(" + dpId + ") : isPresent==false");
return null;
}
}