Skip to content

Commit

Permalink
Move getImages methods from Client to Browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed Nov 27, 2024
1 parent 01bbd56 commit 4bc91a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 54 deletions.
19 changes: 15 additions & 4 deletions src/main/java/fr/igred/omero/client/Browser.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,17 @@ default List<ImageWrapper> getOrphanedImages()
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<ImageWrapper> getImages(String projectName, String datasetName, String imageName)
throws ServiceException, AccessException, ExecutionException;
default List<ImageWrapper> getImages(String projectName, String datasetName, String imageName)
throws ServiceException, AccessException, ExecutionException {
List<ProjectWrapper> projects = getProjects(projectName);

Collection<List<ImageWrapper>> lists = new ArrayList<>(projects.size());
for (ProjectWrapper project : projects) {
lists.add(project.getImages(this, datasetName, imageName));
}

return flatten(lists);
}


/**
Expand All @@ -549,8 +558,10 @@ List<ImageWrapper> getImages(String projectName, String datasetName, String imag
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<ImageWrapper> getImages(AnnotationWrapper<?> annotation)
throws ServiceException, AccessException, ExecutionException;
default List<ImageWrapper> getImages(AnnotationWrapper<?> annotation)
throws ServiceException, AccessException, ExecutionException {
return annotation.getImages(this);
}


/**
Expand Down
50 changes: 0 additions & 50 deletions src/main/java/fr/igred/omero/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@


import fr.igred.omero.ObjectWrapper;
import fr.igred.omero.annotations.AnnotationWrapper;
import fr.igred.omero.annotations.TableWrapper;
import fr.igred.omero.containers.FolderWrapper;
import fr.igred.omero.containers.ProjectWrapper;
import fr.igred.omero.core.ImageWrapper;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ExceptionHandler;
import fr.igred.omero.exception.ServiceException;
Expand All @@ -37,15 +34,13 @@
import omero.model.Experimenter;
import omero.model.ExperimenterGroup;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

import static fr.igred.omero.ObjectWrapper.flatten;
import static fr.igred.omero.exception.ExceptionHandler.call;


Expand Down Expand Up @@ -77,51 +72,6 @@ public Client(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user) {
}


/**
* Gets all images with the name specified inside projects and datasets with the given names.
*
* @param projectName Expected project name.
* @param datasetName Expected dataset name.
* @param imageName Expected image name.
*
* @return See above.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<ImageWrapper> getImages(String projectName, String datasetName, String imageName)
throws ServiceException, AccessException, ExecutionException {
List<ProjectWrapper> projects = getProjects(projectName);

Collection<List<ImageWrapper>> lists = new ArrayList<>(projects.size());
for (ProjectWrapper project : projects) {
lists.add(project.getImages(this, datasetName, imageName));
}

return flatten(lists);
}


/**
* Gets all images with the specified annotation from OMERO.
*
* @param annotation TagAnnotation containing the tag researched.
*
* @return See above.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<ImageWrapper> getImages(AnnotationWrapper<?> annotation)
throws ServiceException, AccessException, ExecutionException {
return annotation.getImages(this);
}


/**
* Deletes multiple objects from OMERO.
*
Expand Down

0 comments on commit 4bc91a7

Please sign in to comment.