本文整理了Java中org.sonar.db.qualityprofile.QProfileEditGroupsDao
类的一些代码示例,展示了QProfileEditGroupsDao
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QProfileEditGroupsDao
类的具体详情如下:
包路径:org.sonar.db.qualityprofile.QProfileEditGroupsDao
类名称:QProfileEditGroupsDao
暂无
代码示例来源:origin: SonarSource/sonarqube
public boolean exists(DbSession dbSession, QProfileDto profile, GroupDto group) {
return exists(dbSession, profile, Collections.singletonList(group));
}
代码示例来源: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
private void removeGroup(DbSession dbSession, QProfileDto profile, GroupDto group) {
if (!dbClient.qProfileEditGroupsDao().exists(dbSession, profile, group)) {
return;
}
dbClient.qProfileEditGroupsDao().deleteByQProfileAndGroup(dbSession, profile, group);
dbSession.commit();
}
}
代码示例来源:origin: SonarSource/sonarqube
private void addGroup(DbSession dbSession, QProfileDto profile, GroupDto group) {
if (dbClient.qProfileEditGroupsDao().exists(dbSession, profile, group)) {
return;
}
dbClient.qProfileEditGroupsDao().insert(dbSession,
new QProfileEditGroupsDto()
.setUuid(uuidFactory.create())
.setGroupId(group.getId())
.setQProfileUuid(profile.getKee()));
dbSession.commit();
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteByQProfiles() {
OrganizationDto organization = db.organizations().insert();
OrganizationDto anotherOrganization = db.organizations().insert();
QProfileDto profile1 = db.qualityProfiles().insert(organization);
QProfileDto profile2 = db.qualityProfiles().insert(organization);
QProfileDto profile3 = db.qualityProfiles().insert(organization);
QProfileDto anotherProfile = db.qualityProfiles().insert(anotherOrganization);
GroupDto group1 = db.users().insertGroup(organization);
GroupDto group2 = db.users().insertGroup(organization);
db.qualityProfiles().addGroupPermission(profile1, group1);
db.qualityProfiles().addGroupPermission(profile2, group2);
db.qualityProfiles().addGroupPermission(profile3, group1);
db.qualityProfiles().addGroupPermission(anotherProfile, group1);
underTest.deleteByQProfiles(db.getSession(), asList(profile1, profile2));
assertThat(underTest.exists(db.getSession(), profile1, group1)).isFalse();
assertThat(underTest.exists(db.getSession(), profile2, group2)).isFalse();
assertThat(underTest.exists(db.getSession(), profile3, group1)).isTrue();
assertThat(underTest.exists(db.getSession(), anotherProfile, group1)).isTrue();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteByGroup() {
OrganizationDto organization = db.organizations().insert();
OrganizationDto anotherOrganization = db.organizations().insert();
QProfileDto profile1 = db.qualityProfiles().insert(organization);
QProfileDto profile2 = db.qualityProfiles().insert(organization);
QProfileDto profile3 = db.qualityProfiles().insert(organization);
QProfileDto anotherProfile = db.qualityProfiles().insert(anotherOrganization);
GroupDto group1 = db.users().insertGroup(organization);
GroupDto group2 = db.users().insertGroup(organization);
db.qualityProfiles().addGroupPermission(profile1, group1);
db.qualityProfiles().addGroupPermission(profile2, group2);
db.qualityProfiles().addGroupPermission(profile3, group1);
db.qualityProfiles().addGroupPermission(anotherProfile, group1);
underTest.deleteByGroup(db.getSession(), group1);
assertThat(underTest.exists(db.getSession(), profile1, group1)).isFalse();
assertThat(underTest.exists(db.getSession(), profile2, group2)).isTrue();
assertThat(underTest.exists(db.getSession(), profile3, group1)).isFalse();
assertThat(underTest.exists(db.getSession(), anotherProfile, group1)).isFalse();
}
代码示例来源:origin: SonarSource/sonarqube
private List<String> searchEditableProfiles(DbSession dbSession, OrganizationDto organization) {
if (!userSession.isLoggedIn()) {
return emptyList();
}
String login = userSession.getLogin();
UserDto user = dbClient.userDao().selectActiveUserByLogin(dbSession, login);
checkState(user != null, "User with login '%s' is not found'", login);
return Stream.concat(
dbClient.qProfileEditUsersDao().selectQProfileUuidsByOrganizationAndUser(dbSession, organization, user).stream(),
dbClient.qProfileEditGroupsDao().selectQProfileUuidsByOrganizationAndGroups(dbSession, organization, userSession.getGroups()).stream())
.collect(toList());
}
代码示例来源: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
public void addGroupPermission(QProfileDto profile, GroupDto group){
checkArgument(!profile.isBuiltIn(), "Built-In profile cannot be used");
dbClient.qProfileEditGroupsDao().insert(dbSession, new QProfileEditGroupsDto()
.setUuid(Uuids.createFast())
.setGroupId(group.getId())
.setQProfileUuid(profile.getKee())
);
dbSession.commit();
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
GroupDto group = support.findGroupDto(dbSession, request);
userSession.checkPermission(OrganizationPermission.ADMINISTER, group.getOrganizationUuid());
support.checkGroupIsNotDefault(dbSession, group);
checkNotTryingToDeleteLastAdminGroup(dbSession, group);
removeGroupPermissions(dbSession, group);
removeFromPermissionTemplates(dbSession, group);
removeGroupMembers(dbSession, group);
dbClient.qProfileEditGroupsDao().deleteByGroup(dbSession, group);
dbClient.groupDao().deleteById(dbSession, group.getId());
dbSession.commit();
response.noContent();
}
}
代码示例来源:origin: SonarSource/sonarqube
db.qProfileEditGroupsDao().deleteByQProfiles(dbSession, customProfiles);
代码示例来源:origin: SonarSource/sonarqube
@Test
public void countByQuery() {
OrganizationDto organization = db.organizations().insert();
QProfileDto profile = db.qualityProfiles().insert(organization);
GroupDto group1 = db.users().insertGroup(organization);
GroupDto group2 = db.users().insertGroup(organization);
GroupDto group3 = db.users().insertGroup(organization);
db.qualityProfiles().addGroupPermission(profile, group1);
db.qualityProfiles().addGroupPermission(profile, group2);
assertThat(underTest.countByQuery(db.getSession(), builder()
.setOrganization(organization)
.setProfile(profile)
.setMembership(ANY).build()))
.isEqualTo(3);
assertThat(underTest.countByQuery(db.getSession(), builder()
.setOrganization(organization)
.setProfile(profile)
.setMembership(IN).build()))
.isEqualTo(2);
assertThat(underTest.countByQuery(db.getSession(), builder()
.setOrganization(organization)
.setProfile(profile)
.setMembership(OUT).build()))
.isEqualTo(1);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
private void addGroup(DbSession dbSession, QProfileDto profile, GroupDto group) {
if (dbClient.qProfileEditGroupsDao().exists(dbSession, profile, group)) {
return;
}
dbClient.qProfileEditGroupsDao().insert(dbSession,
new QProfileEditGroupsDto()
.setUuid(uuidFactory.create())
.setGroupId(group.getId())
.setQProfileUuid(profile.getKee()));
dbSession.commit();
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectQProfileUuidsByOrganizationAndGroups() {
OrganizationDto organization = db.organizations().insert();
OrganizationDto anotherOrganization = db.organizations().insert();
QProfileDto profile1 = db.qualityProfiles().insert(organization);
QProfileDto profile2 = db.qualityProfiles().insert(organization);
QProfileDto anotherProfile = db.qualityProfiles().insert(anotherOrganization);
GroupDto group1 = db.users().insertGroup(organization, "group1");
GroupDto group2 = db.users().insertGroup(organization, "group2");
GroupDto group3 = db.users().insertGroup(organization, "group3");
db.qualityProfiles().addGroupPermission(profile1, group1);
db.qualityProfiles().addGroupPermission(profile1, group2);
db.qualityProfiles().addGroupPermission(profile2, group2);
db.qualityProfiles().addGroupPermission(anotherProfile, group1);
db.qualityProfiles().addGroupPermission(anotherProfile, group3);
assertThat(underTest.selectQProfileUuidsByOrganizationAndGroups(db.getSession(), organization, asList(group1, group2)))
.containsExactlyInAnyOrder(profile1.getKee(), profile2.getKee())
.doesNotContain(anotherProfile.getKee());
assertThat(underTest.selectQProfileUuidsByOrganizationAndGroups(db.getSession(), organization, asList(group1, group2, group3)))
.containsExactlyInAnyOrder(profile1.getKee(), profile2.getKee());
assertThat(underTest.selectQProfileUuidsByOrganizationAndGroups(db.getSession(), organization, emptyList())).isEmpty();
}
代码示例来源: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
@Test
public void insert() {
underTest.insert(db.getSession(), new QProfileEditGroupsDto()
.setUuid("ABCD")
.setGroupId(100)
.setQProfileUuid("QPROFILE")
);
assertThat(db.selectFirst(db.getSession(), "select uuid as \"uuid\", group_id as \"groupId\", qprofile_uuid as \"qProfileUuid\", created_at as \"createdAt\" from qprofile_edit_groups")).contains(
entry("uuid", "ABCD"),
entry("groupId", 100L),
entry("qProfileUuid", "QPROFILE"),
entry("createdAt", NOW));
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
GroupDto group = support.findGroupDto(dbSession, request);
userSession.checkPermission(OrganizationPermission.ADMINISTER, group.getOrganizationUuid());
support.checkGroupIsNotDefault(dbSession, group);
checkNotTryingToDeleteLastAdminGroup(dbSession, group);
removeGroupPermissions(dbSession, group);
removeFromPermissionTemplates(dbSession, group);
removeGroupMembers(dbSession, group);
dbClient.qProfileEditGroupsDao().deleteByGroup(dbSession, group);
dbClient.groupDao().deleteById(dbSession, group.getId());
dbSession.commit();
response.noContent();
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
db.qProfileEditGroupsDao().deleteByQProfiles(dbSession, customProfiles);
代码示例来源:origin: SonarSource/sonarqube
@Test
public void exists() {
OrganizationDto organization = db.organizations().insert();
QProfileDto profile = db.qualityProfiles().insert(organization);
QProfileDto anotherProfile = db.qualityProfiles().insert(organization);
GroupDto group = db.users().insertGroup(organization);
GroupDto anotherGroup = db.users().insertGroup(organization);
db.qualityProfiles().addGroupPermission(profile, group);
assertThat(underTest.exists(db.getSession(), profile, group)).isTrue();
assertThat(underTest.exists(db.getSession(), profile, anotherGroup)).isFalse();
assertThat(underTest.exists(db.getSession(), anotherProfile, group)).isFalse();
assertThat(underTest.exists(db.getSession(), anotherProfile, anotherGroup)).isFalse();
assertThat(underTest.exists(db.getSession(), profile, asList(group, anotherGroup))).isTrue();
assertThat(underTest.exists(db.getSession(), profile, singletonList(anotherGroup))).isFalse();
assertThat(underTest.exists(db.getSession(), profile, emptyList())).isFalse();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteByQProfileAndGroup() {
OrganizationDto organization = db.organizations().insert();
QProfileDto profile = db.qualityProfiles().insert(organization);
GroupDto group = db.users().insertGroup(organization);
db.qualityProfiles().addGroupPermission(profile, group);
assertThat(underTest.exists(db.getSession(), profile, group)).isTrue();
underTest.deleteByQProfileAndGroup(db.getSession(), profile, group);
assertThat(underTest.exists(db.getSession(), profile, group)).isFalse();
}
内容来源于网络,如有侵权,请联系作者删除!