Skip to content

Commit

Permalink
Fixed administrative user group retrieval.
Browse files Browse the repository at this point in the history
Now returns groups with empty members.

Change-Id: I4702ab23c7c48d35ecc3c4d8fa47414861e29f10
  • Loading branch information
margaretha committed Oct 25, 2024
1 parent e533626 commit 083b0ea
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Added role names to user-group list
- Added not-timeExceeded to the totalResult constraints.
- Replace EDIT_VC occurrences with CREATE_VC, and removed it.
- Fixed administrative user group retrieval to return groups with empty members.


# version 0.74.1-SNAPSHOT
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/de/ids_mannheim/korap/dao/UserGroupDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ public List<UserGroup> retrieveGroupByUserId (String userId)
}
}

/** If fetchMembers=true, this method doesn't return groups with empty
* members.
*
* @param groupName
* @param fetchMembers
* @return
* @throws KustvaktException
*/
public UserGroup retrieveGroupByName (String groupName,
boolean fetchMembers) throws KustvaktException {
ParameterChecker.checkStringValue(groupName, "groupName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,12 @@ else if (memberId.equals(deletedBy)

public UserGroupDto searchByName (String groupName)
throws KustvaktException {
UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, true);
UserGroup userGroup = userGroupDao.retrieveGroupByName(groupName, false);
List<UserGroupMember> members = groupMemberDao
.retrieveMemberByGroupId(userGroup.getId());

UserGroupDto groupDto = converter.createUserGroupDto(userGroup,
userGroup.getMembers());
members);
return groupDto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.service.UserGroupService;
import de.ids_mannheim.korap.utils.JsonUtils;
import de.ids_mannheim.korap.web.controller.vc.VirtualCorpusTestBase;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MediaType;
Expand All @@ -23,7 +24,7 @@
/**
* @author margaretha
*/
public class UserGroupControllerAdminTest extends UserGroupTestBase {
public class UserGroupControllerAdminTest extends VirtualCorpusTestBase {

private String testUser = "group-admin";

Expand Down Expand Up @@ -178,6 +179,23 @@ public void testListHiddenGroups ()
assertEquals(1, node.size());
}

@Test
public void testRetrieveHiddenGroupEmptyMember() throws KustvaktException {
createDoryGroup();
createPublishedVC("dory", "dory-published");

JsonNode node = listHiddenGroup();
assertEquals(2, node.size());

String name = node.at("/1/name").asText();
JsonNode groupNode = retrieveGroup(name);

assertEquals(name, groupNode.at("/name").asText());

deleteVC("dory-published", "dory", "dory");
deleteGroupByName(doryGroupName, "dory");
}

@Test
public void testUserGroupAdmin ()
throws KustvaktException {
Expand Down

0 comments on commit 083b0ea

Please sign in to comment.