Here are the examples of the java api org.springframework.data.domain.Page taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2159 Examples
19
Source : Pager.java
with Apache License 2.0
from yugabyte
with Apache License 2.0
from yugabyte
public clreplaced Pager {
private final Page<ProductMetadata> products;
public Pager(Page<ProductMetadata> products) {
this.products = products;
}
public int getPageIndex() {
return products.getNumber() + 1;
}
public int getPageSize() {
return products.getSize();
}
public boolean hasNext() {
return products.hasNext();
}
public boolean hasPrevious() {
return products.hasPrevious();
}
public int getTotalPages() {
return products.getTotalPages();
}
public long getTotalElements() {
return products.getTotalElements();
}
public boolean indexOutOfBounds() {
return this.getPageIndex() < 0 || this.getPageIndex() > this.getTotalElements();
}
}
19
Source : ServiceService.java
with MIT License
from Yirendai
with MIT License
from Yirendai
public //
Page<ServiceInfo> findByAppIdAndserviceNameLike(//
final int appId, //
final String serviceName, final Pageable pageable) {
final Page<ServiceInfo> pageResult;
if (StringUtils.isEmpty(serviceName)) {
pageResult = serviceRepo.findByAppId(appId, pageable);
} else {
final String fuzzyServiceName = new StringBuilder().append("%").append(serviceName).append("%").toString();
pageResult = serviceRepo.findByAppIdAndServiceNameLike(appId, fuzzyServiceName, pageable);
}
return pageResult;
}
19
Source : CoinController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
@GetMapping("legal/page")
public MessageResult findLegalCoinPage(PageModel pageModel) {
Page all = coinService.findLegalCoinPage(pageModel);
return success(all);
}
19
Source : ActivityController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
@RequestMapping("page-query")
public MessageResult page(int pageNo, int pageSize, int step) {
MessageResult mr = new MessageResult();
Page<Activity> all = activityService.queryByStep(pageNo, pageSize, step);
mr.setCode(0);
mr.setData(all);
return mr;
}
19
Source : OrderController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
/**
* 行情机器人专用:当前委托
* @param uid
* @param sign
* @return
*/
@RequestMapping("mockcurrentydhdnskd")
public Page<ExchangeOrder> currentOrderMock(Long uid, String sign, String symbol, int pageNo, int pageSize) {
if (uid != 1 && uid != 10001) {
return null;
}
if (!sign.equals("77585211314qazwsx")) {
return null;
}
Page<ExchangeOrder> page = orderService.findCurrent(uid, symbol, pageNo, pageSize);
// page.getContent().forEach(exchangeOrder -> {
// //获取交易成交详情(机器人无需获取详情)
//
// BigDecimal tradedAmount = BigDecimal.ZERO;
// List<ExchangeOrderDetail> details = exchangeOrderDetailService.findAllByOrderId(exchangeOrder.getOrderId());
// exchangeOrder.setDetail(details);
// for (ExchangeOrderDetail trade : details) {
// tradedAmount = tradedAmount.add(trade.getAmount());
// }
// exchangeOrder.setTradedAmount(tradedAmount);
//
// });
return page;
}
19
Source : RedEnvelopeController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
/**
* 领取详情分页
* @param pageModel
* @return
*/
@RequiresPermissions("envelope:receive-detail")
@PostMapping("receive-detail")
@AccessLog(module = AdminModule.REDENVELOPE, operation = "查看红包领取详情RedEnvelopeController")
public MessageResult envelopeDetailList(@RequestParam(value = "envelopeId", defaultValue = "0") Long envelopeId, @RequestParam(value = "pageNo", defaultValue = "0") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
Page<RedEnvelopeDetail> detailList = redEnveloperDetailService.findByEnvelope(envelopeId, pageNo, pageSize);
return success(detailList);
}
19
Source : MemberController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
@RequiresPermissions("member:page-query")
@PostMapping("page-query")
@ResponseBody
@AccessLog(module = AdminModule.MEMBER, operation = "分页查找会员Member")
public MessageResult page(PageModel pageModel, MemberScreen screen) {
Predicate predicate = getPredicate(screen);
Page<Member> all = memberService.findAll(predicate, pageModel.getPageable());
return success(all);
}
19
Source : MemberController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
/**
* 查询代理商列表
* @param pageModel
* @param screen
* @return
*/
@RequiresPermissions("member:page-query-super")
@PostMapping("page-query-super")
@ResponseBody
@AccessLog(module = AdminModule.MEMBER, operation = "分页查找会员Member")
public MessageResult pageSuperPartner(PageModel pageModel, MemberScreen screen) {
// 默认选择代理商
screen.setSuperPartner("1");
Predicate predicate = getPredicate(screen);
Page<Member> all = memberService.findAll(predicate, pageModel.getPageable());
return success(all);
}
19
Source : LegalWalletRechargeController.java
with Apache License 2.0
from xunibidev
with Apache License 2.0
from xunibidev
@GetMapping("page")
public MessageResult page(PageModel pageModel, LegalWalletRechargeScreen screen) {
Predicate predicate = getPredicate(screen);
Page<LegalWalletRecharge> page = legalWalletRechargeService.findAll(predicate, pageModel);
return success(page);
}
19
Source : PaginationUtil.java
with Apache License 2.0
from xm-online
with Apache License 2.0
from xm-online
public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl) {
return generatePagination(EMPTY, page, baseUrl);
}
19
Source : UserRolesMappingServiceImplTest.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
private Page<UserRolesMapping> getUserRolesMapping() {
List<UserRolesMapping> allUserRolesMapping = getUserRolesMappingDetailsRequest();
Page<UserRolesMapping> allUserRolesMappingDetails = new PageImpl<UserRolesMapping>(allUserRolesMapping, new PageRequest(0, 1), allUserRolesMapping.size());
return allUserRolesMappingDetails;
}
19
Source : RuleServiceImplTest.java
with Apache License 2.0
from tmobile
with Apache License 2.0
from tmobile
@Test
public void getRulesTest() {
List<Rule> ruleDetails = Lists.newArrayList();
Optional<Rule> rule = getRuleDetailsResponse();
ruleDetails.add(rule.get());
Page<Rule> allPoliciesDetails = new PageImpl<Rule>(ruleDetails, new PageRequest(0, 1), ruleDetails.size());
when(ruleService.getRules(StringUtils.EMPTY, 0, 1)).thenReturn(allPoliciesDetails);
replacedertThat(ruleRepository.findAll(StringUtils.EMPTY, new PageRequest(0, 1)).getContent().size(), is(1));
}
19
Source : TPage.java
with MIT License
from temelt
with MIT License
from temelt
public void setStat(Page page, List<T> list) {
this.number = page.getNumber();
this.size = page.getSize();
this.sort = page.getSort();
this.totalPages = page.getTotalPages();
this.totalElements = page.getTotalElements();
this.content = list;
}
19
Source : ProfileController.java
with Apache License 2.0
from teambankrupt
with Apache License 2.0
from teambankrupt
@GetMapping("")
private ResponseEnreplacedy getAllProfile(@RequestParam(value = "page", defaultValue = "0") Integer page) {
Page profilePage = this.profileService.getAllProfilePaginated(page);
return ResponseEnreplacedy.ok(profilePage);
}
19
Source : InvoiceResource.java
with Apache License 2.0
from spring-cloud
with Apache License 2.0
from spring-cloud
@RequestMapping(value = "invoicesSortedWithBody", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEnreplacedy<Page<Invoice>> getInvoicesSortedWithBody(org.springframework.data.domain.Sort sort, @RequestBody String replacedlePrefix) {
Page<Invoice> page = new PageImpl<>(createInvoiceList(replacedlePrefix, 100, sort), PageRequest.of(0, 100, sort), 100);
return ResponseEnreplacedy.ok(page);
}
19
Source : InvoiceResource.java
with Apache License 2.0
from spring-cloud
with Apache License 2.0
from spring-cloud
@RequestMapping(value = "invoicesPaged", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEnreplacedy<Page<Invoice>> getInvoicesPaged(org.springframework.data.domain.Pageable pageable) {
Page<Invoice> page = new PageImpl<>(createInvoiceList(null, pageable.getPageSize(), pageable.getSort()), pageable, 100);
return ResponseEnreplacedy.ok(page);
}
19
Source : DatastoreIntegrationTests.java
with Apache License 2.0
from spring-cloud
with Apache License 2.0
from spring-cloud
@Test
public void testPageableGqlEnreplacedyProjectionsPage() {
Page<TestEnreplacedyProjection> page = this.testEnreplacedyRepository.getBySizePage(2L, PageRequest.of(0, 3));
List<TestEnreplacedyProjection> testEnreplacedyProjections = page.get().collect(Collectors.toList());
replacedertThat(testEnreplacedyProjections).hreplacedize(1);
replacedertThat(testEnreplacedyProjections.get(0)).isInstanceOf(TestEnreplacedyProjection.clreplaced);
replacedertThat(testEnreplacedyProjections.get(0)).isNotInstanceOf(TestEnreplacedy.clreplaced);
replacedertThat(testEnreplacedyProjections.get(0).getColor()).isEqualTo("blue");
}
19
Source : AppUserJpaServiceImpl.java
with MIT License
from rocketbase-io
with MIT License
from rocketbase-io
@Override
@Transactional
public Page<AppUserJpaEnreplacedy> findAll(QueryAppUser query, Pageable pageable) {
if (query == null || query.isEmpty()) {
return repository.findAll(pageable);
}
Specification<AppUserJpaEnreplacedy> specification = (Specification<AppUserJpaEnreplacedy>) (root, criteriaQuery, cb) -> {
Predicate result = cb.equal(root.get("enabled"), Nulls.notNull(query.getEnabled(), true));
List<Predicate> textSearch = new ArrayList<>();
addToListIfNotEmpty(textSearch, Nulls.notEmpty(query.getUsername(), query.getFreetext()), "username", root, cb);
addToListIfNotEmpty(textSearch, Nulls.notEmpty(query.getFirstName(), query.getFreetext()), "firstName", root, cb);
addToListIfNotEmpty(textSearch, Nulls.notEmpty(query.getLastName(), query.getFreetext()), "lastName", root, cb);
addToListIfNotEmpty(textSearch, Nulls.notEmpty(query.getEmail(), query.getFreetext()), "email", root, cb);
if (!textSearch.isEmpty()) {
if (StringUtils.isEmpty(query.getFreetext())) {
result = cb.and(result, cb.and(textSearch.toArray(new Predicate[] {})));
} else {
result = cb.and(result, cb.or(textSearch.toArray(new Predicate[] {})));
}
}
List<Predicate> furtherFilters = new ArrayList<>();
if (!StringUtils.isEmpty(query.getHasRole())) {
criteriaQuery.distinct(true);
Predicate roles = cb.upper(root.join("roles")).in(query.getHasRole().toUpperCase());
furtherFilters.add(roles);
}
if (query.getKeyValues() != null && !query.getKeyValues().isEmpty()) {
criteriaQuery.distinct(true);
MapJoin<AppUserJpaEnreplacedy, String, String> mapJoin = root.joinMap("keyValueMap");
for (Map.Entry<String, String> keyEntry : query.getKeyValues().entrySet()) {
furtherFilters.add(cb.and(cb.equal(mapJoin.key(), keyEntry.getKey()), cb.equal(mapJoin.value(), keyEntry.getValue())));
}
}
if (!furtherFilters.isEmpty()) {
result = cb.and(result, cb.and(furtherFilters.toArray(new Predicate[] {})));
}
return result;
};
Page<AppUserJpaEnreplacedy> result = repository.findAll(specification, pageable);
// in order to initialize lazy map
result.stream().forEach(v -> initLazyObjects(v));
return result;
}
19
Source : AppInviteJpaServiceImpl.java
with MIT License
from rocketbase-io
with MIT License
from rocketbase-io
@Override
@Transactional
public Page<AppInviteJpaEnreplacedy> findAll(QueryAppInvite query, Pageable pageable) {
if (query == null) {
return repository.findAll(pageable);
}
Specification<AppInviteJpaEnreplacedy> specification = (Specification<AppInviteJpaEnreplacedy>) (root, criteriaQuery, cb) -> {
Predicate result;
if (!Nulls.notNull(query.getExpired(), false)) {
result = cb.greaterThanOrEqualTo(root.get("expiration"), Instant.now());
} else {
result = cb.lessThan(root.get("expiration"), Instant.now());
}
List<Predicate> predicates = new ArrayList<>();
addToListIfNotEmpty(predicates, query.getInvitor(), "invitor", root, cb);
addToListIfNotEmpty(predicates, query.getEmail(), "email", root, cb);
if (query.getKeyValues() != null && !query.getKeyValues().isEmpty()) {
criteriaQuery.distinct(true);
MapJoin<AppUserJpaEnreplacedy, String, String> mapJoin = root.joinMap("keyValueMap");
for (Map.Entry<String, String> keyEntry : query.getKeyValues().entrySet()) {
predicates.add(cb.and(cb.equal(mapJoin.key(), keyEntry.getKey()), cb.equal(mapJoin.value(), keyEntry.getValue())));
}
}
if (!predicates.isEmpty()) {
result = cb.and(result, cb.and(predicates.toArray(new Predicate[] {})));
}
return result;
};
Page<AppInviteJpaEnreplacedy> result = repository.findAll(specification, pageable);
// in order to initialize lazy map
result.stream().forEach(v -> initLazyObjects(v));
return result;
}
19
Source : IndividualController.java
with MIT License
from Robinyo
with MIT License
from Robinyo
@GetMapping("/individuals/search/findByFamilyNameStartsWith")
@PreAuthorize("hasAuthority('SCOPE_individual:read')")
public ResponseEnreplacedy<PagedModel<IndividualModel>> findByFamilyNameStartsWith(@RequestParam("name") final String name, Pageable pageable) throws ResponseStatusException {
log.info("IndividualController GET /individuals/search/findByFamilyNameStartsWith");
try {
Page<Individual> enreplacedies = repository.findByNameFamilyNameStartsWith(name, pageable);
PagedModel<IndividualModel> models = pagedResourcesreplacedembler.toModel(enreplacedies, replacedembler);
// logInfo(enreplacedies, models);
return ResponseEnreplacedy.ok(models);
} catch (Exception e) {
log.error("{}", e.getLocalizedMessage());
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
}
}
19
Source : IndividualController.java
with MIT License
from Robinyo
with MIT License
from Robinyo
@GetMapping("/individuals")
@PreAuthorize("hasAuthority('SCOPE_individual:read')")
public ResponseEnreplacedy<PagedModel<IndividualModel>> findAll(Pageable pageable) throws ResponseStatusException {
log.info("IndividualController GET /individuals");
try {
Page<Individual> enreplacedies = repository.findAll(pageable);
PagedModel<IndividualModel> models = pagedResourcesreplacedembler.toModel(enreplacedies, replacedembler);
// logInfo(enreplacedies, models);
return ResponseEnreplacedy.ok(models);
} catch (Exception e) {
log.error("{}", e.getLocalizedMessage());
throw new ResponseStatusException(HttpStatus.BAD_REQUEST);
}
}
19
Source : Pager.java
with Apache License 2.0
from reljicd
with Apache License 2.0
from reljicd
/**
* @author Dusan Raljic
*/
public clreplaced Pager {
private final Page<Link> links;
public Pager(Page<Link> links) {
this.links = links;
}
public int getPageIndex() {
return links.getNumber() + 1;
}
public int getPageSize() {
return links.getSize();
}
public boolean hasNext() {
return links.hasNext();
}
public boolean hasPrevious() {
return links.hasPrevious();
}
public int getTotalPages() {
return links.getTotalPages();
}
public long getTotalElements() {
return links.getTotalElements();
}
public boolean indexOutOfBounds() {
return this.getPageIndex() < 0 || this.getPageIndex() > this.getTotalElements();
}
}
19
Source : Pager.java
with GNU General Public License v3.0
from reljicd
with GNU General Public License v3.0
from reljicd
/**
* @author Dusan Raljic
*/
public clreplaced Pager {
private final Page<Product> products;
public Pager(Page<Product> products) {
this.products = products;
}
public int getPageIndex() {
return products.getNumber() + 1;
}
public int getPageSize() {
return products.getSize();
}
public boolean hasNext() {
return products.hasNext();
}
public boolean hasPrevious() {
return products.hasPrevious();
}
public int getTotalPages() {
return products.getTotalPages();
}
public long getTotalElements() {
return products.getTotalElements();
}
public boolean indexOutOfBounds() {
return this.getPageIndex() < 0 || this.getPageIndex() > this.getTotalElements();
}
}
19
Source : StatisticsDocUnitController.java
with GNU Affero General Public License v3.0
from progilone
with GNU Affero General Public License v3.0
from progilone
@RequestMapping(method = RequestMethod.GET, params = { "count" }, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEnreplacedy<Page<StatisticsDocUnitCountDTO>> getDocUnitList(final HttpServletRequest request, @RequestParam(value = "libraries", required = false) final List<String> libraries, @RequestParam(value = "project", required = false) final List<String> projects, @RequestParam(value = "lot", required = false) final List<String> lots, @RequestParam(value = "page", required = false, defaultValue = "0") final Integer page, @RequestParam(value = "size", required = false, defaultValue = "10") final Integer size) {
// Droits d'accès
final List<String> filteredLibraries = libraryAccesssHelper.getLibraryFilter(request, libraries);
final Page<StatisticsDocUnitCountDTO> docUnits = uiStatService.getDocUnits(filteredLibraries, projects, lots, page, size);
return new ResponseEnreplacedy<>(docUnits, HttpStatus.OK);
}
19
Source : StatisticsDocumentService.java
with GNU Affero General Public License v3.0
from progilone
with GNU Affero General Public License v3.0
from progilone
@Transactional(readOnly = true)
public Page<StatisticsDocPublishedDTO> getDocPublishedStat(final List<String> libraries, final List<String> projects, final List<String> lots, final LocalDate fromDate, final LocalDate toDate, final List<String> types, final List<String> collections, final Integer page, final Integer size) {
final Page<StatisticsDocPublishedDTO> results = docUnitStateRepository.findDocUnitStates(new DocUnitWorkflowSearchBuilder().setLibraries(libraries).setProjects(projects).setLots(lots).setFromDate(fromDate).setToDate(toDate).setTypes(types).setCollections(collections).addState(DIFFUSION_DOreplacedENT).addState(DIFFUSION_DOreplacedENT_LOCALE).addState(DIFFUSION_DOreplacedENT_OMEKA), new PageRequest(page, size)).map(this::initDto);
// Infos IA report => ia url
results.forEach(res -> {
if (res.getWorkflowState() == DIFFUSION_DOreplacedENT) {
final InternetArchiveReport iaReport = internetArchiveReportService.findLastReportByDocUnit(res.getDocUnitIdentifier());
if (iaReport != null && iaReport.getInternetArchiveIdentifier() != null) {
res.setLinkIA(ARCHIVE_BASE_URL + iaReport.getInternetArchiveIdentifier());
}
}
});
return results;
}
19
Source : Pagination.java
with Apache License 2.0
from pravusid
with Apache License 2.0
from pravusid
public Pagination calcPage(Page page, int blockSize) {
this.currPage = page.getNumber();
this.totalPages = (page.getTotalPages() == 0) ? 0 : page.getTotalPages() - 1;
firstBlock = currPage - (currPage % blockSize);
lastBlock = (firstBlock + (blockSize - 1) > totalPages) ? totalPages : firstBlock + (blockSize - 1);
prev = (firstBlock == 0) ? 0 : firstBlock - 1;
next = (lastBlock == totalPages) ? totalPages : lastBlock + 1;
return this;
}
19
Source : ScServiceInstanceService.java
with Apache License 2.0
from PaaS-TA
with Apache License 2.0
from PaaS-TA
private Object setPageInfo(Page reqPage, Object reqObject) {
try {
Clreplaced<?> aClreplaced = reqObject.getClreplaced();
Method methodSetPage = aClreplaced.getMethod("setPage", Integer.TYPE);
Method methodSetSize = aClreplaced.getMethod("setSize", Integer.TYPE);
Method methodSetTotalPages = aClreplaced.getMethod("setTotalPages", Integer.TYPE);
Method methodSetTotalElements = aClreplaced.getMethod("setTotalElements", Long.TYPE);
Method methodSetLast = aClreplaced.getMethod("setLast", Boolean.TYPE);
methodSetPage.invoke(reqObject, reqPage.getNumber());
methodSetSize.invoke(reqObject, reqPage.getSize());
methodSetTotalPages.invoke(reqObject, reqPage.getTotalPages());
methodSetTotalElements.invoke(reqObject, reqPage.getTotalElements());
methodSetLast.invoke(reqObject, reqPage.isLast());
} catch (NoSuchMethodException e) {
this.logger.error("NoSuchMethodException :: {}", e);
} catch (IllegalAccessException e1) {
this.logger.error("IllegalAccessException :: {}", e1);
} catch (InvocationTargetException e2) {
this.logger.error("InvocationTargetException :: {}", e2);
}
return reqObject;
}
19
Source : CommonService.java
with Apache License 2.0
from PaaS-TA
with Apache License 2.0
from PaaS-TA
/**
* Sets page info.
*
* @param reqPage the req page
* @param reqObject the req object
* @return the page info
*/
public Object setPageInfo(Page reqPage, Object reqObject) {
Object resultObject = null;
try {
Clreplaced<?> aClreplaced;
if (reqObject instanceof Clreplaced) {
aClreplaced = (Clreplaced<?>) reqObject;
resultObject = ((Clreplaced) reqObject).newInstance();
} else {
aClreplaced = reqObject.getClreplaced();
resultObject = reqObject;
}
Method methodSetPage = aClreplaced.getMethod("setPage", Integer.TYPE);
Method methodSetSize = aClreplaced.getMethod("setSize", Integer.TYPE);
Method methodSetTotalPages = aClreplaced.getMethod("setTotalPages", Integer.TYPE);
Method methodSetTotalElements = aClreplaced.getMethod("setTotalElements", Long.TYPE);
Method methodSetLast = aClreplaced.getMethod("setLast", Boolean.TYPE);
methodSetPage.invoke(resultObject, reqPage.getNumber());
methodSetSize.invoke(resultObject, reqPage.getSize());
methodSetTotalPages.invoke(resultObject, reqPage.getTotalPages());
methodSetTotalElements.invoke(resultObject, reqPage.getTotalElements());
methodSetLast.invoke(resultObject, reqPage.isLast());
} catch (NoSuchMethodException e) {
LOGGER.error("NoSuchMethodException :: {}", e);
} catch (IllegalAccessException e1) {
LOGGER.error("IllegalAccessException :: {}", e1);
} catch (InvocationTargetException e2) {
LOGGER.error("InvocationTargetException :: {}", e2);
} catch (InstantiationException e3) {
LOGGER.error("InstantiationException :: {}", e3);
}
return resultObject;
}
19
Source : CategoryServiceImpl.java
with GNU Affero General Public License v3.0
from osopromadze
with GNU Affero General Public License v3.0
from osopromadze
@Override
public PagedResponse<Category> getAllCategories(int page, int size) {
AppUtils.validatePageNumberAndSize(page, size);
Pageable pageable = PageRequest.of(page, size, Sort.Direction.DESC, "createdAt");
Page<Category> categories = categoryRepository.findAll(pageable);
List<Category> content = categories.getNumberOfElements() == 0 ? Collections.emptyList() : categories.getContent();
return new PagedResponse<>(content, categories.getNumber(), categories.getSize(), categories.getTotalElements(), categories.getTotalPages(), categories.isLast());
}
19
Source : SmartMeteringManagementEndpoint.java
with Apache License 2.0
from OSGP
with Apache License 2.0
from OSGP
/**
* Retrieve the result of the
* {@link #findMessageLogsRequest(String, String, String, String, FindMessageLogsRequest)}
* method.
*
* @return FindMessageLogsResponse
* @throws OsgpException
*/
@PayloadRoot(localPart = "FindMessageLogsAsyncRequest", namespace = NAMESPACE)
@ResponsePayload
public FindMessageLogsResponse getFindMessageLogsResponse(@OrganisationIdentification final String organisationIdentification, @RequestPayload final FindMessageLogsAsyncRequest request) throws OsgpException {
LOGGER.info("FindMessageLogs response for organisation: {} and device: {}.", organisationIdentification, request.getDeviceIdentification());
FindMessageLogsResponse response = null;
try {
response = new FindMessageLogsResponse();
@SuppressWarnings("unchecked")
final Page<DeviceLogItem> page = (Page<DeviceLogItem>) this.responseDataService.dequeue(request.getCorrelationUid(), Page.clreplaced, ComponentType.WS_SMART_METERING).getMessageData();
// Map to output
final MessageLogPage logPage = new MessageLogPage();
logPage.setTotalPages(page.getTotalPages());
logPage.getMessageLogs().addAll(this.managementMapper.mapAsList(page.getContent(), MessageLog.clreplaced));
response.setMessageLogPage(logPage);
} catch (final ConstraintViolationException e) {
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.WS_SMART_METERING, new ValidationException(e.getConstraintViolations()));
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
19
Source : CustomizeRepository.java
with Apache License 2.0
from ngcly
with Apache License 2.0
from ngcly
public <T> Page<T> nativePageQueryList(String nativeSql, Pageable pageable, Object... params) {
Query q = createPageNativeQuery(nativeSql, pageable, params);
q.unwrap(NativeQueryImpl.clreplaced).setResultTransformer(Transformers.TO_LIST);
Page<T> page = new PageImpl<T>(q.getResultList(), pageable, countPageQuery("select count(*) from (" + nativeSql + ") tall", params).intValue());
return page;
}
19
Source : CustomizeRepository.java
with Apache License 2.0
from ngcly
with Apache License 2.0
from ngcly
public Page<Map<String, Object>> nativePageQueryListMap(String nativeSql, Pageable pageable, Object... params) {
;
Query q = createNativeQuery(nativeSql, params);
q.unwrap(NativeQueryImpl.clreplaced).setResultTransformer(Transformers.ALIAS_TO_ENreplacedY_MAP);
Page<Map<String, Object>> page = new PageImpl<Map<String, Object>>(q.getResultList(), pageable, countPageQuery("select count(*) from (" + nativeSql + ") tall", params).intValue());
return page;
}
19
Source : AdServiceImpl.java
with Apache License 2.0
from myxzjie
with Apache License 2.0
from myxzjie
public Page<AdPosition> findBookCriteria(Integer page, Integer size, final AdPosition adPosition) {
Pageable pageable = PageRequest.of(page, size, Sort.by("id").ascending());
// AdPositionSpecification specification = new AdPositionSpecification(new SpecSearchCriteria("positionName", ":", adPosition.getPositionName()));
Page<AdPosition> bookPage = adPositionRepository.findAll(pageable);
/*adPositionRepository.findAll(new Specification<AdPosition>() {
@Override
public Predicate toPredicate(Root<AdPosition> root, CriteriaQuery<AdPosition> query, CriteriaBuilder criteriaBuilder) {
// List<Predicate> list = new ArrayList<Predicate>();
// if (null != bookQuery.getName() && !"".equals(bookQuery.getName())) {
// list.add(criteriaBuilder.equal(root.get("name").as(String.clreplaced), bookQuery.getName()));
// }
// if (null != bookQuery.getIsbn() && !"".equals(bookQuery.getIsbn())) {
// list.add(criteriaBuilder.equal(root.get("isbn").as(String.clreplaced), bookQuery.getIsbn()));
// }
// if (null != bookQuery.getAuthor() && !"".equals(bookQuery.getAuthor())) {
// list.add(criteriaBuilder.equal(root.get("author").as(String.clreplaced), bookQuery.getAuthor()));
// }
// Predicate[] p = new Predicate[list.size()];
// return criteriaBuilder.and(list.toArray(p));
return null;
}
}, pageable);*/
return bookPage;
}
19
Source : ReplyService.java
with GNU General Public License v3.0
from microacup
with GNU General Public License v3.0
from microacup
// 按照话题找回复
public Page<Reply> findAllReplies(Post post, int page, int pageSize) {
Page<Reply> replies = replyRepository.findByPost(post, new PageRequest(page, pageSize, Sort.Direction.DESC, "topTime", "adoptTime", "perfectTime", "floor"));
return replies;
}
19
Source : PostService.java
with GNU General Public License v3.0
from microacup
with GNU General Public License v3.0
from microacup
public Page<Post> findByTags(Collection<String> tags, int page, int pageSize) {
Page<Post> posts = postRepository.findByTags(tags, new PageRequest(page, pageSize, Sort.Direction.DESC, "topTime", "lastTime"));
return posts;
}
19
Source : PostService.java
with GNU General Public License v3.0
from microacup
with GNU General Public License v3.0
from microacup
public Page<Post> findByTagsActived(Collection<String> tags, int page, int pageSize) {
Page<Post> posts = postRepository.findByTagsAndStatus(tags, PostStatus.actived, new PageRequest(page, pageSize, Sort.Direction.DESC, "topTime", "lastTime"));
return posts;
}
19
Source : PostService.java
with GNU General Public License v3.0
from microacup
with GNU General Public License v3.0
from microacup
public Page<Post> findByCategory(String category, int page, int pageSize) {
Page<Post> posts = postRepository.findByCategoryAndStatus(category, PostStatus.actived, new PageRequest(page, pageSize, Sort.Direction.DESC, "topTime", "lastTime"));
return posts;
}
19
Source : SysRoleRestSupportImpl.java
with Apache License 2.0
from melthaw
with Apache License 2.0
from melthaw
@Override
public Page<RoleSummary> getAppRoles(RoleQueryRequest request) {
Page<AppRole> appRoles = appRoleService.listAppRoles(request);
return new PageImpl<>(appRoles.getContent().stream().map(RoleSummary::from).collect(Collectors.toList()), new PageRequest(request.getStart(), request.getLimit()), appRoles.getTotalElements());
}
19
Source : SysRoleRestSupportImpl.java
with Apache License 2.0
from melthaw
with Apache License 2.0
from melthaw
@Override
public Page<UserSummary> getUsersByAppRoleId(String roleId, UserQueryParameter request) {
Page<User> users = appRoleService.listBindUsers(roleId, request);
return new PageImpl<>(users.getContent().stream().map(UserSummary::from).collect(Collectors.toList()), new PageRequest(request.getStart(), request.getLimit()), users.getTotalElements());
}
19
Source : AppRoleRestSupportImpl.java
with Apache License 2.0
from melthaw
with Apache License 2.0
from melthaw
@Override
public Page<UserSummary> getUsersBySysRoleId(String roleCode, UserQueryParameter request) {
SysRole role = null;
try {
role = SysRole.valueOf(roleCode);
} catch (RuntimeException e) {
throw new RoleException(String.format("无效的系统角色名'%s'", roleCode));
}
Page<User> users = accountService.listUsersByRole(role, request);
return new PageImpl<>(users.getContent().stream().map(UserSummary::from).collect(Collectors.toList()), new PageRequest(request.getStart(), request.getLimit()), users.getTotalElements());
}
19
Source : UserController.java
with Apache License 2.0
from melonlee
with Apache License 2.0
from melonlee
// @Autowired
// private RedisUtils redisUtils;
/**
* 分页查找
*
* @param pageable
* @return
*/
@RequestMapping("/list")
public Page<UserEnreplacedy> list(@PageableDefault(sort = { "id" }, direction = Sort.Direction.DESC) Pageable pageable) {
Page<UserEnreplacedy> users = userRepository.findAll(pageable);
return users;
}
19
Source : YarnAppController.java
with Apache License 2.0
from MeetYouDevs
with Apache License 2.0
from MeetYouDevs
@RequestMapping(value = "/page.api", method = RequestMethod.POST)
public Msg page(@RequestBody DtoYarnApp req) {
LoginUser currentUser = getCurrentUser();
if (!currentUser.isRoot()) {
req.setUserId(currentUser.getId());
}
List<String> tokens = new ArrayList<>();
if (StringUtils.isNotBlank(req.getName())) {
tokens.add("name?" + req.getName());
}
if (StringUtils.isNotBlank(req.getAppId())) {
tokens.add("appId=" + req.getAppId());
}
if (req.getClusterId() != null) {
tokens.add("clusterId=" + req.getClusterId());
}
if (req.getUserId() != null) {
tokens.add("userId=" + req.getUserId());
}
Page<DtoYarnApp> dtoYarnAppPage = yarnAppService.pageByQuery(new PageRequest(req.pageNo - 1, req.pageSize, StringUtils.join(tokens, ";"))).map(item -> {
DtoYarnApp dtoYarnApp = new DtoYarnApp();
BeanUtils.copyProperties(item, dtoYarnApp);
return dtoYarnApp;
});
return success(dtoYarnAppPage);
}
19
Source : SolrResultPage.java
with Apache License 2.0
from learningtcc
with Apache License 2.0
from learningtcc
/**
* Base implementation of page holding solr response enreplacedies.
*
* @author Christoph Strobl
* @author Francisco Spaeth
*/
public clreplaced SolrResultPage<T> extends PageImpl<T> implements FacetPage<T>, HighlightPage<T>, ScoredPage<T>, GroupPage<T>, StatsPage<T> {
private static final long serialVersionUID = -4199560685036530258L;
private Map<PageKey, Page<FacetFieldEntry>> facetResultPages = new LinkedHashMap<PageKey, Page<FacetFieldEntry>>(1);
private Map<PageKey, List<FacetPivotFieldEntry>> facetPivotResultPages = new LinkedHashMap<PageKey, List<FacetPivotFieldEntry>>();
private Map<PageKey, Page<FacetFieldEntry>> facetRangeResultPages = new LinkedHashMap<PageKey, Page<FacetFieldEntry>>(1);
private Page<FacetQueryEntry> facetQueryResult;
private List<HighlightEntry<T>> highlighted;
private Float maxScore;
private Map<Object, GroupResult<T>> groupResults = Collections.emptyMap();
private Map<String, FieldStatsResult> fieldStatsResults;
public SolrResultPage(List<T> content) {
super(content);
}
public SolrResultPage(List<T> content, Pageable pageable, long total, Float maxScore) {
super(content, pageable, total);
this.maxScore = maxScore;
}
private Page<FacetFieldEntry> getResultPage(String fieldname, Map<PageKey, Page<FacetFieldEntry>> resultPages) {
Page<FacetFieldEntry> page = resultPages.get(new StringPageKey(fieldname));
return page != null ? page : new PageImpl<FacetFieldEntry>(Collections.<FacetFieldEntry>emptyList());
}
@Override
public final Page<FacetFieldEntry> getFacetResultPage(String fieldname) {
return getResultPage(fieldname, this.facetResultPages);
}
/*
* (non-Javadoc)
*
* @see org.springframework.data.solr.core.query.result.FacetPage#
* getRangeFacetResultPage(java.lang.String)
*/
@Override
public final Page<FacetFieldEntry> getRangeFacetResultPage(String fieldname) {
return getResultPage(fieldname, this.facetRangeResultPages);
}
@Override
public final Page<FacetFieldEntry> getFacetResultPage(Field field) {
return this.getFacetResultPage(field.getName());
}
/*
* (non-Javadoc)
*
* @see org.springframework.data.solr.core.query.result.FacetPage#
* getRangeFacetResultPage(org.springframework.data.solr.core.query.Field)
*/
@Override
public final Page<FacetFieldEntry> getRangeFacetResultPage(Field field) {
return getRangeFacetResultPage(field.getName());
}
@Override
public List<FacetPivotFieldEntry> getPivot(String fieldName) {
return facetPivotResultPages.get(new StringPageKey(fieldName));
}
@Override
public List<FacetPivotFieldEntry> getPivot(PivotField field) {
return facetPivotResultPages.get(new StringPageKey(field.getName()));
}
public final void addFacetResultPage(Page<FacetFieldEntry> page, Field field) {
this.facetResultPages.put(new StringPageKey(field.getName()), page);
}
/**
* @param page
* @param field
* @since 1.5
*/
public final void addRangeFacetResultPage(Page<FacetFieldEntry> page, Field field) {
this.facetRangeResultPages.put(new StringPageKey(field.getName()), page);
}
public final void addFacetPivotResultPage(List<FacetPivotFieldEntry> result, PivotField field) {
this.facetPivotResultPages.put(new StringPageKey(field.getName()), result);
}
public void addAllFacetFieldResultPages(Map<Field, Page<FacetFieldEntry>> pageMap) {
for (Map.Entry<Field, Page<FacetFieldEntry>> entry : pageMap.entrySet()) {
addFacetResultPage(entry.getValue(), entry.getKey());
}
}
/**
* @param pageMap
* @since 1.5
*/
public void addAllRangeFacetFieldResultPages(Map<Field, Page<FacetFieldEntry>> pageMap) {
for (Map.Entry<Field, Page<FacetFieldEntry>> entry : pageMap.entrySet()) {
addRangeFacetResultPage(entry.getValue(), entry.getKey());
}
}
public void addAllFacetPivotFieldResult(Map<PivotField, List<FacetPivotFieldEntry>> resultMap) {
for (Map.Entry<PivotField, List<FacetPivotFieldEntry>> entry : resultMap.entrySet()) {
addFacetPivotResultPage(entry.getValue(), entry.getKey());
}
}
@Override
public Collection<Page<FacetFieldEntry>> getFacetResultPages() {
return Collections.unmodifiableCollection(this.facetResultPages.values());
}
public final void setFacetQueryResultPage(List<FacetQueryEntry> facetQueryResult) {
this.facetQueryResult = new PageImpl<FacetQueryEntry>(facetQueryResult);
}
@Override
public Page<FacetQueryEntry> getFacetQueryResult() {
return this.facetQueryResult != null ? this.facetQueryResult : new PageImpl<FacetQueryEntry>(Collections.<FacetQueryEntry>emptyList());
}
@Override
public Collection<Field> getFacetFields() {
if (this.facetResultPages.isEmpty()) {
return Collections.emptyList();
}
List<Field> fields = new ArrayList<Field>(this.facetResultPages.size());
for (PageKey pageKey : this.facetResultPages.keySet()) {
fields.add(new SimpleField(pageKey.getKey().toString()));
}
return fields;
}
@Override
public Collection<PivotField> getFacetPivotFields() {
if (this.facetPivotResultPages.isEmpty()) {
return Collections.emptyList();
}
List<PivotField> fields = new ArrayList<PivotField>(this.facetPivotResultPages.size());
for (PageKey pageKey : this.facetPivotResultPages.keySet()) {
fields.add(new SimplePivotField(pageKey.getKey().toString()));
}
return fields;
}
@Override
public Collection<Page<? extends FacetEntry>> getAllFacets() {
List<Page<? extends FacetEntry>> entries = new ArrayList<Page<? extends FacetEntry>>(this.facetResultPages.size() + 1);
entries.addAll(this.facetResultPages.values());
entries.add(this.facetQueryResult);
return entries;
}
@Override
public List<HighlightEntry<T>> getHighlighted() {
return this.highlighted != null ? this.highlighted : Collections.<HighlightEntry<T>>emptyList();
}
public void setHighlighted(List<HighlightEntry<T>> highlighted) {
this.highlighted = highlighted;
}
@Override
public List<HighlightEntry.Highlight> getHighlights(T enreplacedy) {
if (enreplacedy != null && this.highlighted != null) {
for (HighlightEntry<T> highlightEntry : this.highlighted) {
if (highlightEntry != null && ObjectUtils.nullSafeEquals(highlightEntry.getEnreplacedy(), enreplacedy)) {
return highlightEntry.getHighlights();
}
}
}
return Collections.emptyList();
}
/**
* @param groupResults
* @since 1.4
*/
public void setGroupResults(Map<Object, GroupResult<T>> groupResults) {
this.groupResults = groupResults;
}
/*
* (non-Javadoc)
*
* @see
* org.springframework.data.solr.core.query.result.ScoredPage#getMaxScore()
*/
@Override
public Float getMaxScore() {
return maxScore;
}
@Override
public GroupResult<T> getGroupResult(Field field) {
replacedert.notNull(field, "group result field must not be null");
return groupResults.get(field.getName());
}
@Override
public GroupResult<T> getGroupResult(Function function) {
replacedert.notNull(function, "group result function must not be null");
return groupResults.get(function);
}
@Override
public GroupResult<T> getGroupResult(Query query) {
replacedert.notNull(query, "group result query must not be null");
return groupResults.get(query);
}
@Override
public GroupResult<T> getGroupResult(String name) {
replacedert.notNull(name, "group result name must not be null");
return groupResults.get(name);
}
/**
* @param fieldStatsResult
* @since 1.4
*/
public void setFieldStatsResults(Map<String, FieldStatsResult> fieldStatsResults) {
this.fieldStatsResults = fieldStatsResults;
}
@Override
public FieldStatsResult getFieldStatsResult(Field field) {
return getFieldStatsResult(field.getName());
}
@Override
public FieldStatsResult getFieldStatsResult(String fieldName) {
return this.fieldStatsResults.get(fieldName);
}
@Override
public Map<String, FieldStatsResult> getFieldStatsResults() {
return this.fieldStatsResults;
}
}
19
Source : SolrResultPage.java
with Apache License 2.0
from learningtcc
with Apache License 2.0
from learningtcc
private Page<FacetFieldEntry> getResultPage(String fieldname, Map<PageKey, Page<FacetFieldEntry>> resultPages) {
Page<FacetFieldEntry> page = resultPages.get(new StringPageKey(fieldname));
return page != null ? page : new PageImpl<FacetFieldEntry>(Collections.<FacetFieldEntry>emptyList());
}
19
Source : SimpleGroupResult.java
with Apache License 2.0
from learningtcc
with Apache License 2.0
from learningtcc
/**
* This represents the result of a group command. This can be the result of the
* following parameter: field, function or query.
*
* @author Francisco Spaeth
* @param <T>
* @since 1.4
*/
public clreplaced SimpleGroupResult<T> implements GroupResult<T> {
private int matches;
private Integer groupsCount;
private String name;
private Page<GroupEntry<T>> groupEntries;
public SimpleGroupResult(int matches, Integer groupsCount, String name, Page<GroupEntry<T>> groupEntries) {
replacedert.isTrue(matches >= 0, "matches must be >= 0");
replacedert.hasLength(name, "group result name must be not empty");
replacedert.notNull(groupEntries, "groupEntries must be not null");
this.matches = matches;
this.groupsCount = groupsCount;
this.name = name;
this.groupEntries = groupEntries;
}
@Override
public int getMatches() {
return matches;
}
@Override
public Integer getGroupsCount() {
return groupsCount;
}
@Override
public String getName() {
return name;
}
@Override
public Page<GroupEntry<T>> getGroupEntries() {
return groupEntries;
}
@Override
public String toString() {
return //
new StringBuilder().append("SimpleGroupResult [name=").append(//
name).append(", matches=").append(//
matches).append(", groupsCount=").append(//
groupsCount).append(", groupsEntries.total=").append(//
groupEntries.getTotalElements()).append("]").toString();
}
}
19
Source : SimpleGroupEntry.java
with Apache License 2.0
from learningtcc
with Apache License 2.0
from learningtcc
/**
* Represents a group holding the group value and all beans belonging to the
* group.
*
* @author Francisco Spaeth
* @param <T>
* @since 1.4
*/
public clreplaced SimpleGroupEntry<T> implements GroupEntry<T> {
private String groupValue;
private Page<T> result;
public SimpleGroupEntry(String groupValue, Page<T> result) {
super();
this.groupValue = groupValue;
this.result = result;
}
@Override
public String getGroupValue() {
return groupValue;
}
@Override
public Page<T> getResult() {
return result;
}
@Override
public String toString() {
return "SimpleGroupEntry [groupValue=" + groupValue + ", result=" + result + "]";
}
}
19
Source : PermissionController.java
with Apache License 2.0
from JiongZhu
with Apache License 2.0
from JiongZhu
@GetMapping
public PageResult getAll(String draw, @RequestParam(required = false, defaultValue = "1") int start, @RequestParam(required = false, defaultValue = "10") int length) {
int pageNo = start / length;
Page<Permission> page = permissionService.findByPage(pageNo, length);
PageResult<List<Permission>> result = new PageResult<>(draw, page.getTotalElements(), page.getTotalElements(), page.getContent());
return result;
}
19
Source : AdminUserController.java
with Apache License 2.0
from JiongZhu
with Apache License 2.0
from JiongZhu
/**
* 翻页获取管理员
*
* @param adminUser
* @param draw:请求次数
* @param start
* @param length
* @return
*/
@GetMapping
public PageResult getAll(AdminUser adminUser, String draw, @RequestParam(required = false, defaultValue = "1") int start, @RequestParam(required = false, defaultValue = "10") int length) {
int pageNo = start / length;
Page<AdminUser> page = adminUserService.findByPage(adminUser, pageNo, length);
PageResult<List<AdminUser>> result = new PageResult<>(draw, page.getTotalElements(), page.getTotalElements(), page.getContent());
return result;
}
19
Source : OrderController.java
with Apache License 2.0
from jammy928
with Apache License 2.0
from jammy928
/**
* 行情机器人专用:当前委托
* @param member
* @param orderId
* @return
*/
@RequestMapping("mockcurrentydhdnskd")
public Page<ExchangeOrder> currentOrderMock(Long uid, String sign, String symbol, int pageNo, int pageSize) {
if (uid != 1 && uid != 10001) {
return null;
}
if (!sign.equals("987654321asdf")) {
return null;
}
Page<ExchangeOrder> page = orderService.findCurrent(uid, symbol, pageNo, pageSize);
/*
page.getContent().forEach(exchangeOrder -> {
//获取交易成交详情(机器人无需获取详情)
BigDecimal tradedAmount = BigDecimal.ZERO;
List<ExchangeOrderDetail> details = exchangeOrderDetailService.findAllByOrderId(exchangeOrder.getOrderId());
exchangeOrder.setDetail(details);
for (ExchangeOrderDetail trade : details) {
tradedAmount = tradedAmount.add(trade.getAmount());
}
exchangeOrder.setTradedAmount(tradedAmount);
});
*/
return page;
}
19
Source : PlaceServiceImplTest.java
with MIT License
from ita-social-projects
with MIT License
from ita-social-projects
@Test
void getPlacesByStatusTest() {
int pageNumber = 0;
int pageSize = 1;
Pageable pageable = PageRequest.of(pageNumber, pageSize);
Place place = new Place();
place.setName("Place");
AdminPlaceDto dto = new AdminPlaceDto();
dto.setName("Place");
Page<Place> placesPage = new PageImpl<>(Collections.singletonList(place), pageable, 1);
List<AdminPlaceDto> listDto = Collections.singletonList(dto);
PageableDto<AdminPlaceDto> pageableDto = new PageableDto<>(listDto, listDto.size(), 0, 1);
pageableDto.setPage(listDto);
when(placeRepo.findAllByStatusOrderByModifiedDateDesc(any(), any())).thenReturn(placesPage);
when(modelMapper.map(any(), any())).thenReturn(dto);
replacedertEquals(pageableDto, placeService.getPlacesByStatus(any(), any()));
verify(placeRepo, times(1)).findAllByStatusOrderByModifiedDateDesc(any(), any());
}
See More Examples