List of usage examples for org.apache.ibatis.session RowBounds RowBounds
public RowBounds(int offset, int limit)
From source file:org.nebula.service.admin.GetInstancesProcessor.java
License:Apache License
private List<WorkflowInstance> getInstancesByRegistrationId(CommonEventMapper cem, GetInstancesRequest request) {//from w w w .ja v a 2 s .c o m List<WorkflowInstance> instances = new ArrayList<WorkflowInstance>(); RowBounds rowBounds = new RowBounds((request.getPageNo() - 1) * request.getPageSize(), request.getPageSize()); List<Event> workflowScheduledEvents = cem.findInstancesByRegistrationIdByPage(rowBounds, request.getRegistrationId()); for (Event scheduledEvent : workflowScheduledEvents) { String registrationId = request.getRegistrationId(); if (registrationId == null) { registrationId = scheduledEvent.getRegistrationId(); } Registration registration = registrationMapper.findById(registrationId); if (registration == null) { String error = String.format("No workflow registration found for registrationId - %s", request.getRegistrationId()); logger.warn(error); return instances; } Event completedEvent = cem.findWorkflowCompletedEvent(scheduledEvent.getInstanceId()); instances.add(createWorkflowInstance(registration, scheduledEvent, completedEvent)); } return instances; }
From source file:org.nebula.service.admin.GetInstancesProcessor.java
License:Apache License
private int countInstancesByUsername(CommonEventMapper cem, String username) { RowBounds rowBounds = new RowBounds(0, maxWorkflowsPerUser); List<Registration> registrations = registrationMapper.findRegistrations(rowBounds, username, null, RegisterRequest.NodeType.WORKFLOW.name(), null, null); logger.info("registrations.size=" + registrations.size()); int totalInstances = 0; for (Registration registration : registrations) { logger.info("registrations.getId=" + registration.getId()); totalInstances += countInstancesByRegistrationId(cem, registration.getId()); }/*from w w w .j ava 2 s. co m*/ return totalInstances; }
From source file:org.nebula.service.admin.GetRegistrationsProcessor.java
License:Apache License
public GetRegistrationsResponse processInternal(GetRegistrationsRequest request) { RowBounds rowBounds = new RowBounds((request.getPageNo() - 1) * request.getPageSize(), request.getPageSize());/* w ww.j a va2s . co m*/ List<Registration> registrations = registrationMapper.findRegistrations(rowBounds, request.getUsername(), request.getWorkflowName(), request.getNodeType() == null ? null : request.getNodeType().name(), request.getCreatedBefore(), request.getCreatedAfter()); int total = registrationMapper.countRegistrations(request.getUsername(), request.getWorkflowName(), request.getNodeType() == null ? null : request.getNodeType().name(), request.getCreatedBefore(), request.getCreatedAfter()); GetRegistrationsResponse response = new GetRegistrationsResponse(); response.setRegistrationSummaries(extractSummaries(registrations)); response.setPageNo(request.getPageNo()); response.setPageSize(request.getPageSize()); response.setTotal(total); return response; }
From source file:org.nebula.service.archive.EventArchiver.java
License:Apache License
private void backupToHistory(String instanceId) { int pageNo = 1; int pageSize = PAGE_SIZE; int total = eventMapper.countByInstanceId(instanceId); int processed = 0; boolean hasNext = true; while (hasNext) { RowBounds rowBounds = new RowBounds((pageNo - 1) * pageSize, pageSize); List<Event> events = eventMapper.findByInstanceIdByPage(rowBounds, instanceId); if (events.size() == 0) { break; }/*from w w w . jav a 2 s .c om*/ insertIntoHistoryEvents(events); processed += events.size(); hasNext = hasNext(total, processed); pageNo++; } }
From source file:org.nebula.service.processor.GetEventsProcessor.java
License:Apache License
protected GetEventsResponse buildResponse(GetEventsRequest request, Event aEvent) { String instanceId = request.getInstanceId(); RowBounds rowBounds = new RowBounds((request.getPageNo() - 1) * request.getPageSize(), request.getPageSize());/*from w ww . j av a2s . c o m*/ List<Event> pevents = eventMapper.findByInstanceIdByPage(rowBounds, instanceId); List<org.nebula.framework.event.Event> events = new ArrayList<org.nebula.framework.event.Event>(); for (Event event : pevents) { org.nebula.framework.event.Event eve = (org.nebula.framework.event.Event) toObject(event.getData(), "org.nebula.framework.event." + event.getEventType()); eve.setEventId(event.getId()); eve.setPrecedingId(event.getPrecedingId()); events.add(eve); } GetEventsResponse response = new GetEventsResponse(); response.setEvents(events); response.setPageNo(request.getPageNo()); response.setSize(events.size()); response.setTotal(eventMapper.countByInstanceId(instanceId)); return response; }
From source file:org.openlmis.lookupapi.controller.LookupController.java
License:Open Source License
@ApiOperation(value = "Products", notes = "Returns a list of products.", response = Product.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful request", response = Product.class), @ApiResponse(code = 500, message = "Internal server error") }) @RequestMapping(value = "/rest-api/lookup/products", method = RequestMethod.GET, headers = ACCEPT_JSON) public ResponseEntity getProducts(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "paging", defaultValue = "true") Boolean paging) { RowBounds rowBounds = paging ? new RowBounds(page, pageSize) : new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT); return RestResponse.response(PRODUCTS, lookupService.getFullProductList(rowBounds)); }
From source file:org.openlmis.lookupapi.controller.LookupController.java
License:Open Source License
@ApiOperation(value = "Facilities", notes = "Returns a list of facilities.", response = Facility.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful request", response = Facility.class), @ApiResponse(code = 500, message = "Internal server error") }) @RequestMapping(value = "/rest-api/lookup/facilities", method = RequestMethod.GET, headers = ACCEPT_JSON) public ResponseEntity getFacilities(@RequestParam(value = "page", defaultValue = "1") Integer page, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, @RequestParam(value = "paging", defaultValue = "true") Boolean paging) { RowBounds rowBounds = paging ? new RowBounds(page, pageSize) : new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT); return RestResponse.response(FACILITIES, lookupService.getAllFacilities(rowBounds)); }
From source file:org.openlmis.report.controller.ReportLookupController.java
License:Open Source License
@RequestMapping(value = "/allFacilities", method = GET, headers = BaseController.ACCEPT_JSON) public ResponseEntity<OpenLmisResponse> getAllFacilities() { return OpenLmisResponse.response(ALL_FACILITIES, reportLookupService .getAllFacilities(new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT))); }
From source file:org.openlmis.report.service.AdjustmentSummaryReportDataProvider.java
License:Open Source License
@Override public List<? extends ReportData> getReportBody(Map<String, String[]> filterCriteria, Map<String, String[]> sortCriteria, int page, int pageSize) { RowBounds rowBounds = new RowBounds((page - 1) * pageSize, pageSize); return reportMapper.getFilteredSortedPagedAdjustmentSummaryReport(getReportFilterData(filterCriteria), sortCriteria, rowBounds, this.getUserId()); }
From source file:org.openlmis.report.service.AggregateConsumptionReportDataProvider.java
License:Open Source License
@Override public List<? extends ReportData> getReportBody(Map<String, String[]> filterCriteria, Map<String, String[]> sortCriteria, int page, int pageSize) { RowBounds rowBounds = new RowBounds((page - 1) * pageSize, pageSize); return reportMapper.getAggregateConsumptionReport(getReportFilterData(filterCriteria), sortCriteria, rowBounds, this.getUserId()); }