Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List all groups on the OMERO database #78

Merged
merged 7 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/main/java/fr/igred/omero/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -365,13 +366,36 @@ public GroupWrapper getGroup(long groupId)
ExperimenterGroup group = ExceptionHandler.of(getGateway(), g -> g.getAdminService(getCtx()).getGroup(groupId))
.rethrow(ApiUsageException.class,
(m, e) -> new NoSuchElementException(m),
"User not found: " + groupId)
"Group not found: " + groupId)
.handleServiceOrServer("Cannot retrieve group: " + groupId)
.get();
return new GroupWrapper(new GroupData(group));
}


/**
* Returns all the groups on OMERO.
*
* @return See above.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
*/
public List<GroupWrapper> getGroups()
throws ServiceException, AccessException {
String error = "Cannot retrieve the groups on OMERO";
return ExceptionHandler.of(getGateway(),
g -> g.getAdminService(getCtx()).lookupGroups())
.handleOMEROException(error)
.get()
.stream()
.filter(Objects::nonNull)
.map(GroupData::new)
.map(GroupWrapper::new)
.collect(Collectors.toList());
}


/**
* Gets the client associated with the username in the parameters. The user calling this function needs to have
* administrator rights. All action realized with the client returned will be considered as his.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fr/igred/omero/repository/ScreenWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public class ScreenWrapper extends GenericRepositoryObjectWrapper<ScreenData> {


/**
* Constructor of the ProjectWrapper class. Creates a new project and saves it to OMERO.
* Constructor of the ScreenWrapper class. Creates a new screen and saves it to OMERO.
*
* @param client The client handling the connection.
* @param name Project name.
* @param description Project description.
* @param name Screen name.
* @param description Screen description.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/fr/igred/omero/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import fr.igred.omero.meta.ExperimenterWrapper;
import fr.igred.omero.meta.GroupWrapper;
import fr.igred.omero.repository.DatasetWrapper;
import fr.igred.omero.repository.ImageWrapper;
import fr.igred.omero.repository.PlateWrapper;
Expand Down Expand Up @@ -372,4 +373,11 @@ void testGetAllWellsForUser2() throws Exception {
assertEquals(0, wells.size());
}


@Test
void testGetAllGroups() throws Exception {
List<GroupWrapper> groups = client.getGroups();
assertEquals(7, groups.size());
}

}
Loading