List of usage examples for org.apache.ibatis.session RowBounds RowBounds
public RowBounds(int offset, int limit)
From source file:org.sonar.db.ce.CeActivityDao.java
License:Open Source License
public void insert(DbSession dbSession, CeActivityDto dto) { dto.setCreatedAt(system2.now());/*from w ww. j a v a 2 s. com*/ dto.setUpdatedAt(system2.now()); dto.setIsLast(false); mapper(dbSession).insert(dto); List<String> uuids = mapper(dbSession).selectUuidsOfRecentlyCreatedByIsLastKey(dto.getIsLastKey(), new RowBounds(0, 1)); // should never be empty, as a row was just inserted! if (!uuids.isEmpty()) { mapper(dbSession).updateIsLastToFalseForLastKey(dto.getIsLastKey(), dto.getUpdatedAt()); mapper(dbSession).updateIsLastToTrueForUuid(uuids.get(0), dto.getUpdatedAt()); } }
From source file:org.sonar.db.ce.CeActivityDao.java
License:Open Source License
/** * Ordered by id desc -> newest to oldest *///w w w . j ava 2 s. c om public List<CeActivityDto> selectByQuery(DbSession dbSession, CeTaskQuery query, int offset, int pageSize) { if (query.isShortCircuitedByComponentUuids()) { return Collections.emptyList(); } return mapper(dbSession).selectByQuery(query, new RowBounds(offset, pageSize)); }
From source file:org.sonar.db.ce.CeActivityDaoTest.java
License:Open Source License
@Test public void test_selectByQuery() { insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS); insert("TASK_2", REPORT, "PROJECT_1", CeActivityDto.Status.FAILED); insert("TASK_3", REPORT, "PROJECT_2", CeActivityDto.Status.SUCCESS); insert("TASK_4", "views", null, CeActivityDto.Status.SUCCESS); // no filters CeActivityQuery query = new CeActivityQuery(); List<CeActivityDto> dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_4", "TASK_3", "TASK_2", "TASK_1"); // select by component uuid query = new CeActivityQuery().setComponentUuid("PROJECT_1"); dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_2", "TASK_1"); // select by status query = new CeActivityQuery().setStatus(CeActivityDto.Status.SUCCESS); dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_4", "TASK_3", "TASK_1"); // select by type query = new CeActivityQuery().setType(REPORT); dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_3", "TASK_2", "TASK_1"); query = new CeActivityQuery().setType("views"); dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_4"); // select by multiple conditions query = new CeActivityQuery().setType(REPORT).setOnlyCurrents(true).setComponentUuid("PROJECT_1"); dtos = underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10)); assertThat(dtos).extracting("uuid").containsExactly("TASK_2"); }
From source file:org.sonar.db.ce.CeActivityDaoTest.java
License:Open Source License
@Test public void selectByQuery_no_results_if_shortcircuited_by_component_uuids() { insert("TASK_1", REPORT, "PROJECT_1", CeActivityDto.Status.SUCCESS); CeActivityQuery query = new CeActivityQuery(); query.setComponentUuids(Collections.<String>emptyList()); assertThat(underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10))).isEmpty(); }
From source file:org.sonar.db.ce.CeActivityDaoTest.java
License:Open Source License
@Test public void select_and_count_by_date() { insertWithDates("UUID1", 1_450_000_000_000L, 1_470_000_000_000L); insertWithDates("UUID2", 1_460_000_000_000L, 1_480_000_000_000L); // search by min submitted date CeActivityQuery query = new CeActivityQuery().setMinSubmittedAt(1_455_000_000_000L); assertThat(underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10))).extracting("uuid") .containsOnly("UUID2"); assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(1); // search by max executed date query = new CeActivityQuery().setMaxExecutedAt(1_475_000_000_000L); assertThat(underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10))).extracting("uuid") .containsOnly("UUID1"); assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(1); // search by both dates query = new CeActivityQuery().setMinSubmittedAt(1_400_000_000_000L).setMaxExecutedAt(1_475_000_000_000L); assertThat(underTest.selectByQuery(db.getSession(), query, new RowBounds(0, 10))).extracting("uuid") .containsOnly("UUID1"); assertThat(underTest.countByQuery(db.getSession(), query)).isEqualTo(1); }
From source file:org.sonar.db.ce.CeQueueDao.java
License:Open Source License
public List<CeQueueDto> selectByQueryInDescOrder(DbSession dbSession, CeTaskQuery query, Paging paging) { if (query.isShortCircuitedByComponentUuids() || query.isOnlyCurrents() || query.getMaxExecutedAt() != null) { return emptyList(); }// w ww. ja va 2s . c o m return mapper(dbSession).selectByQueryInDescOrder(query, new RowBounds(paging.offset(), paging.pageSize())); }
From source file:org.sonar.db.component.ComponentDao.java
License:Open Source License
public List<ComponentDto> selectByQuery(DbSession session, ComponentQuery query, int offset, int limit) { return mapper(session).selectByQuery(query, new RowBounds(offset, limit)); }
From source file:org.sonar.db.component.ComponentDao.java
License:Open Source License
public List<ComponentDtoWithSnapshotId> selectDirectChildren(DbSession dbSession, ComponentTreeQuery componentQuery) { RowBounds rowBounds = new RowBounds(offset(componentQuery.getPage(), componentQuery.getPageSize()), componentQuery.getPageSize()); return mapper(dbSession).selectDirectChildren(componentQuery, rowBounds); }
From source file:org.sonar.db.component.ComponentDao.java
License:Open Source License
public List<ComponentDtoWithSnapshotId> selectAllChildren(DbSession dbSession, ComponentTreeQuery componentQuery) { RowBounds rowBounds = new RowBounds(offset(componentQuery.getPage(), componentQuery.getPageSize()), componentQuery.getPageSize()); return mapper(dbSession).selectAllChildren(componentQuery, rowBounds); }
From source file:org.sonar.db.component.ComponentDao.java
License:Open Source License
public List<ComponentDto> selectProvisionedProjects(DbSession session, int offset, int limit, @Nullable String query) { Map<String, Object> parameters = newHashMapWithExpectedSize(2); addProjectQualifier(parameters);// w ww. j a va2s.c om addPartialQueryParameterIfNotNull(parameters, query); return mapper(session).selectProvisionedProjects(parameters, new RowBounds(offset, limit)); }