List of usage examples for org.apache.ibatis.session RowBounds RowBounds
public RowBounds(int offset, int limit)
From source file:org.sonar.server.component.db.ComponentDao.java
License:Open Source License
public List<ComponentDto> selectGhostProjects(DbSession session, @Nullable String query, SearchOptions options) {/*from w w w. ja v a2 s . c o m*/ Map<String, String> parameters = newHashMapWithExpectedSize(2); addProjectQualifier(parameters); addPartialQueryParameterIfNotNull(parameters, query); return mapper(session).selectGhostProjects(parameters, new RowBounds(options.getOffset(), options.getLimit())); }
From source file:org.sonar.server.computation.ws.ActivityAction.java
License:Open Source License
private static RowBounds readMyBatisRowBounds(Request wsRequest) { int pageIndex = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE); int pageSize = wsRequest.mandatoryParamAsInt(WebService.Param.PAGE_SIZE); return new RowBounds((pageIndex - 1) * pageSize, pageSize); }
From source file:org.sonar.server.computation.ws.ComponentAction.java
License:Open Source License
@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { String componentUuid = wsRequest.mandatoryParam(PARAM_COMPONENT_UUID); userSession.checkComponentUuidPermission(UserRole.USER, componentUuid); DbSession dbSession = dbClient.openSession(false); try {//w ww . j a v a 2 s. c om List<CeQueueDto> queueDtos = dbClient.ceQueueDao().selectByComponentUuid(dbSession, componentUuid); CeActivityQuery activityQuery = new CeActivityQuery().setComponentUuid(componentUuid) .setOnlyCurrents(true); List<CeActivityDto> activityDtos = dbClient.ceActivityDao().selectByQuery(dbSession, activityQuery, new RowBounds(0, 1)); ProjectResponse.Builder wsResponseBuilder = ProjectResponse.newBuilder(); wsResponseBuilder.addAllQueue(formatter.formatQueue(dbSession, queueDtos)); if (activityDtos.size() == 1) { wsResponseBuilder.setCurrent(formatter.formatActivity(dbSession, activityDtos.get(0))); } WsUtils.writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse); } finally { dbClient.closeSession(dbSession); } }
From source file:org.sonar.server.computation.ws.ProjectWsAction.java
License:Open Source License
@Override public void handle(Request wsRequest, Response wsResponse) throws Exception { String componentUuid = wsRequest.mandatoryParam(PARAM_COMPONENT_UUID); userSession.checkProjectUuidPermission(UserRole.USER, componentUuid); DbSession dbSession = dbClient.openSession(false); try {/*from w ww. j a va 2 s .c o m*/ List<CeQueueDto> queueDtos = dbClient.ceQueueDao().selectByComponentUuid(dbSession, componentUuid); CeActivityQuery activityQuery = new CeActivityQuery().setComponentUuid(componentUuid) .setOnlyCurrents(true); List<CeActivityDto> activityDtos = dbClient.ceActivityDao().selectByQuery(dbSession, activityQuery, new RowBounds(0, 1)); ProjectResponse.Builder wsResponseBuilder = ProjectResponse.newBuilder(); wsResponseBuilder.addAllQueue(formatter.formatQueue(dbSession, queueDtos)); if (activityDtos.size() == 1) { wsResponseBuilder.setCurrent(formatter.formatActivity(dbSession, activityDtos.get(0))); } WsUtils.writeProtobuf(wsResponseBuilder.build(), wsRequest, wsResponse); } finally { dbClient.closeSession(dbSession); } }
From source file:org.sonar.server.measure.custom.persistence.CustomMeasureDao.java
License:Open Source License
public List<CustomMeasureDto> selectByComponentUuid(DbSession session, String componentUuid, SearchOptions searchOptions) {// ww w.j a va 2 s. c o m return mapper(session).selectByComponentUuid(componentUuid, new RowBounds(searchOptions.getOffset(), searchOptions.getLimit())); }
From source file:org.sonar.server.metric.persistence.MetricDao.java
License:Open Source License
public List<MetricDto> selectEnabled(DbSession session, @Nullable Boolean isCustom, SearchOptions searchOptions) {/* www. j av a2 s . c om*/ Map<String, Object> properties = Maps.newHashMapWithExpectedSize(1); if (isCustom != null) { properties.put("isCustom", isCustom); } return mapper(session).selectAllEnabled(properties, new RowBounds(searchOptions.getOffset(), searchOptions.getLimit())); }
From source file:org.sonar.server.project.ws.ProvisionedAction.java
License:Open Source License
@Override public void handle(Request request, Response response) throws Exception { userSession.checkLoggedIn();// w ww.j a v a2 s.c om SearchOptions options = new SearchOptions().setPage(request.mandatoryParamAsInt(Param.PAGE), request.mandatoryParamAsInt(Param.PAGE_SIZE)); Set<String> desiredFields = desiredFields(request); String query = request.param(Param.TEXT_QUERY); try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = support.getOrganization(dbSession, request.getParam(PARAM_ORGANIZATION).or(defaultOrganizationProvider.get()::getKey)); userSession.checkPermission(PROVISION_PROJECTS, organization); RowBounds rowBounds = new RowBounds(options.getOffset(), options.getLimit()); List<ComponentDto> projects = dbClient.componentDao().selectProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER, rowBounds); int nbOfProjects = dbClient.componentDao().countProvisioned(dbSession, organization.getUuid(), query, QUALIFIERS_FILTER); JsonWriter json = response.newJsonWriter().beginObject(); writeProjects(projects, json, desiredFields); options.writeJson(json, nbOfProjects); json.endObject().close(); } }
From source file:org.wso2.carbon.bpmn.core.mgt.dao.ActivitiDAO.java
License:Open Source License
/** * Return the list of substitute info based on query parameters. * @param model model with only required query parameter values. Leave others as null. By default enabled=false. * @return List<SubstitutesDataModel> Result set of substitute info *//*from w w w . j a va 2 s.com*/ public List<PaginatedSubstitutesDataModel> querySubstituteInfo(final PaginatedSubstitutesDataModel model) { final RowBounds rw = new RowBounds(model.getStart(), model.getSize()); CustomSqlExecution<SubstitutesMapper, List<PaginatedSubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<PaginatedSubstitutesDataModel>>( SubstitutesMapper.class) { public List<PaginatedSubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) { return substitutesMapper.querySubstitutes(rw, model); } }; return managementService.executeCustomSql(customSqlExecution); }
From source file:org.wso2.carbon.bpmn.core.mgt.dao.ActivitiDAO.java
License:Open Source License
/** * Return the list of substitute info based on query parameters except enabled property. * @param model data model with only required query parameter values. Leave others as null. * @return List<PaginatedSubstitutesDataModel> Result set of substitute info *//*w w w. j ava 2 s.c om*/ public List<PaginatedSubstitutesDataModel> querySubstituteInfoWithoutEnabled( final PaginatedSubstitutesDataModel model) { final RowBounds rw = new RowBounds(model.getStart(), model.getSize()); CustomSqlExecution<SubstitutesMapper, List<PaginatedSubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<PaginatedSubstitutesDataModel>>( SubstitutesMapper.class) { public List<PaginatedSubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) { return substitutesMapper.querySubstitutesWithoutEnabled(rw, model); } }; return managementService.executeCustomSql(customSqlExecution); }
From source file:plum.mybatis.PaginationInterceptor.java
License:Apache License
/** * Set the paging information,to RowBuounds. * * @param rowBounds rowBounds./*from w w w . j av a 2 s. co m*/ * @return rowBounds. */ private static RowBounds offset_paging(RowBounds rowBounds) { // rowBuounds has offset. if (rowBounds.getOffset() == RowBounds.NO_ROW_OFFSET) { final PageQuery paginationCriteria = PAGINATION_CRITERIA_THREAD_LOCAL.get(); if (paginationCriteria != null) { return new RowBounds(paginationCriteria.getPage(), paginationCriteria.getPageSize()); } } return rowBounds; }