org.sonar.db.qualityprofile.QProfileEditGroupsDao.selectByQuery()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(64)

本文整理了Java中org.sonar.db.qualityprofile.QProfileEditGroupsDao.selectByQuery方法的一些代码示例,展示了QProfileEditGroupsDao.selectByQuery的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QProfileEditGroupsDao.selectByQuery方法的具体详情如下:
包路径:org.sonar.db.qualityprofile.QProfileEditGroupsDao
类名称:QProfileEditGroupsDao
方法名:selectByQuery

QProfileEditGroupsDao.selectByQuery介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
public void handle(Request request, Response response) throws Exception {
 SearchUsersRequest wsRequest = buildRequest(request);
 try (DbSession dbSession = dbClient.openSession(false)) {
  OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, wsRequest.getOrganization());
  QProfileDto profile = wsSupport.getProfile(dbSession, organization, wsRequest.getQualityProfile(), wsRequest.getLanguage());
  wsSupport.checkCanEdit(dbSession, organization, profile);
  SearchGroupsQuery query = builder()
   .setOrganization(organization)
   .setProfile(profile)
   .setQuery(wsRequest.getQuery())
   .setMembership(MEMBERSHIP.get(fromParam(wsRequest.getSelected())))
   .build();
  int total = dbClient.qProfileEditGroupsDao().countByQuery(dbSession, query);
  List<GroupMembershipDto> groupMemberships = dbClient.qProfileEditGroupsDao().selectByQuery(dbSession, query,
   forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize()));
  Map<Integer, GroupDto> groupsById = dbClient.groupDao().selectByIds(dbSession,
   groupMemberships.stream().map(GroupMembershipDto::getGroupId).collect(MoreCollectors.toList()))
   .stream()
   .collect(MoreCollectors.uniqueIndex(GroupDto::getId));
  writeProtobuf(
   Qualityprofiles.SearchGroupsResponse.newBuilder()
    .addAllGroups(groupMemberships.stream()
     .map(groupsMembership -> toGroup(groupsById.get(groupsMembership.getGroupId()), groupsMembership.isSelected()))
     .collect(toList()))
    .setPaging(buildPaging(wsRequest, total)).build(),
   request, response);
 }
}

代码示例来源:origin: SonarSource/sonarqube

db.qualityProfiles().addGroupPermission(profile, group2);
assertThat(underTest.selectByQuery(db.getSession(), builder()
  .setOrganization(organization)
  .setProfile(profile)
 .containsExactly(group1.getId());
assertThat(underTest.selectByQuery(db.getSession(), builder()
  .setOrganization(organization)
  .setProfile(profile)
 .containsExactly(group3.getId());
assertThat(underTest.selectByQuery(db.getSession(), builder()
  .setOrganization(organization)
  .setProfile(profile)

代码示例来源:origin: SonarSource/sonarqube

@Test
public void selectByQuery_search_by_name() {
 OrganizationDto organization = db.organizations().insert();
 QProfileDto profile = db.qualityProfiles().insert(organization);
 GroupDto group1 = db.users().insertGroup(organization, "sonar-users-project");
 GroupDto group2 = db.users().insertGroup(organization, "sonar-users-qprofile");
 GroupDto group3 = db.users().insertGroup(organization, "sonar-admin");
 db.qualityProfiles().addGroupPermission(profile, group1);
 db.qualityProfiles().addGroupPermission(profile, group2);
 db.qualityProfiles().addGroupPermission(profile, group3);
 assertThat(underTest.selectByQuery(db.getSession(), builder()
   .setOrganization(organization)
   .setProfile(profile)
   .setMembership(IN)
   .setQuery("project").build(),
  Pagination.all()))
  .extracting(GroupMembershipDto::getGroupId)
  .containsExactlyInAnyOrder(group1.getId());
 assertThat(underTest.selectByQuery(db.getSession(), builder()
   .setOrganization(organization)
   .setProfile(profile)
   .setMembership(IN)
   .setQuery("UserS").build(),
  Pagination.all()))
  .extracting(GroupMembershipDto::getGroupId)
  .containsExactlyInAnyOrder(group1.getId(), group2.getId());
}

代码示例来源:origin: SonarSource/sonarqube

db.qualityProfiles().addGroupPermission(profile, group2);
assertThat(underTest.selectByQuery(db.getSession(), builder()
 .setOrganization(organization)
 .setProfile(profile)
  tuple(group3.getId(), false));
assertThat(underTest.selectByQuery(db.getSession(), builder()
  .setOrganization(organization)
  .setProfile(profile)
 .containsExactlyInAnyOrder(tuple(group1.getId(), true), tuple(group2.getId(), true));
assertThat(underTest.selectByQuery(db.getSession(), builder()
  .setOrganization(organization)
  .setProfile(profile)

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public void handle(Request request, Response response) throws Exception {
 SearchUsersRequest wsRequest = buildRequest(request);
 try (DbSession dbSession = dbClient.openSession(false)) {
  OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, wsRequest.getOrganization());
  QProfileDto profile = wsSupport.getProfile(dbSession, organization, wsRequest.getQualityProfile(), wsRequest.getLanguage());
  wsSupport.checkCanEdit(dbSession, organization, profile);
  SearchGroupsQuery query = builder()
   .setOrganization(organization)
   .setProfile(profile)
   .setQuery(wsRequest.getQuery())
   .setMembership(MEMBERSHIP.get(fromParam(wsRequest.getSelected())))
   .build();
  int total = dbClient.qProfileEditGroupsDao().countByQuery(dbSession, query);
  List<GroupMembershipDto> groupMemberships = dbClient.qProfileEditGroupsDao().selectByQuery(dbSession, query,
   forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize()));
  Map<Integer, GroupDto> groupsById = dbClient.groupDao().selectByIds(dbSession,
   groupMemberships.stream().map(GroupMembershipDto::getGroupId).collect(MoreCollectors.toList()))
   .stream()
   .collect(MoreCollectors.uniqueIndex(GroupDto::getId));
  writeProtobuf(
   Qualityprofiles.SearchGroupsResponse.newBuilder()
    .addAllGroups(groupMemberships.stream()
     .map(groupsMembership -> toGroup(groupsById.get(groupsMembership.getGroupId()), groupsMembership.isSelected()))
     .collect(toList()))
    .setPaging(buildPaging(wsRequest, total)).build(),
   request, response);
 }
}

相关文章