getLinks(Client client, String linkType)
- throws ServiceException, OMEROServerError {
+ throws ServiceException, AccessException {
return client.findByQuery("select link.parent from " + linkType +
" link where link.child = " + getId());
}
diff --git a/src/main/java/fr/igred/omero/annotations/FileAnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/FileAnnotationWrapper.java
index 5acdd61b..3ca46bd6 100644
--- a/src/main/java/fr/igred/omero/annotations/FileAnnotationWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/FileAnnotationWrapper.java
@@ -18,9 +18,9 @@
package fr.igred.omero.annotations;
-import fr.igred.omero.Client;
+import fr.igred.omero.client.Client;
+import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ExceptionHandler;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
import omero.ServerError;
import omero.api.RawFileStorePrx;
@@ -37,10 +37,10 @@
* Class containing a FileAnnotationData object.
* Wraps function calls to the FileAnnotationData contained.
*/
-public class FileAnnotationWrapper extends GenericAnnotationWrapper {
+public class FileAnnotationWrapper extends AnnotationWrapper {
/**
- * Constructor of the GenericAnnotationWrapper class.
+ * Constructor of the AnnotationWrapper class.
*
* @param annotation FileAnnotationData to wrap.
*/
@@ -178,27 +178,26 @@ public long getFileID() {
* @return See above.
*
* @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
* @throws IOException Cannot write to the file.
- * @throws OMEROServerError Server error.
*/
public File getFile(Client client, String path)
- throws IOException, ServiceException, OMEROServerError {
+ throws ServiceException, AccessException, IOException {
File file = new File(path);
RawFileStorePrx store;
try (FileOutputStream stream = new FileOutputStream(file)) {
String error = "Could not create RawFileService";
store = ExceptionHandler.of(client, c -> writeFile(c, stream))
- .handleServiceOrServer(error)
+ .handleOMEROException(error)
.rethrow(IOException.class)
.get();
}
if (store != null) {
+ String error = "Could not close RawFileService";
ExceptionHandler.ofConsumer(store, RawFileStorePrx::close)
- .rethrow(ServerError.class,
- OMEROServerError::new,
- "Could not close RawFileService")
+ .handleServerAndService(error)
.rethrow();
}
@@ -227,15 +226,4 @@ public boolean isMovieFile() {
return data.isMovieFile();
}
-
- /**
- * @return the {@link FileAnnotationData} contained. Use {@link #asDataObject()} instead.
- *
- * @deprecated Gets the FileAnnotationData contained.
- */
- @Deprecated
- public FileAnnotationData asFileAnnotationData() {
- return data;
- }
-
}
diff --git a/src/main/java/fr/igred/omero/annotations/MapAnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/MapAnnotationWrapper.java
index 52b5ccf2..91884f0b 100644
--- a/src/main/java/fr/igred/omero/annotations/MapAnnotationWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/MapAnnotationWrapper.java
@@ -37,7 +37,7 @@
* Class containing a MapAnnotationData, a MapAnnotationData contains a list of NamedValue(Key-Value pair).
* Wraps function calls to the MapAnnotationData contained.
*/
-public class MapAnnotationWrapper extends GenericAnnotationWrapper {
+public class MapAnnotationWrapper extends AnnotationWrapper {
/**
* The name space used to identify MapAnnotations created be the user
@@ -55,21 +55,6 @@ public MapAnnotationWrapper(MapAnnotationData data) {
}
- /**
- * Constructor of the MapAnnotationWrapper class. Sets the content of the MapAnnotationData
- *
- * @param result List of NamedValue(Key-Value pair).
- *
- * @deprecated This constructor will be removed in a future version.
- * Use {@link #MapAnnotationWrapper(Collection)} instead.
- */
- @Deprecated
- public MapAnnotationWrapper(List result) {
- super(new MapAnnotationData());
- data.setContent(result);
- }
-
-
/**
* Constructor of the MapAnnotationWrapper class. Sets the content of the map annotation.
*
@@ -130,26 +115,15 @@ private static NamedValue toNamedValue(Entry entry) {
/**
- * Gets the List of NamedValue contained in the map annotation.
+ * Gets the List of Key-Value pairs contained in the map annotation.
*
* @return MapAnnotationData content.
*/
@SuppressWarnings("unchecked")
- public List getContent() {
- return (List) data.getContent();
- }
-
-
- /**
- * Sets the content of the map annotation.
- *
- * @param result List of NamedValue(Key-Value pair).
- *
- * @deprecated This method will be replaced by {@link #setContent(Collection)} in a future version.
- */
- @Deprecated
- public void setContent(List result) {
- data.setContent(result);
+ public List> getContent() {
+ return ((Collection) data.getContent()).stream()
+ .map(MapAnnotationWrapper::toMapEntry)
+ .collect(toList());
}
@@ -166,33 +140,15 @@ public void setContent(Collection extends Entry> pairs) {
}
- /**
- * Gets the List of Key-Value pairs contained in the map annotation.
- *
- * @return MapAnnotationData content.
- *
- * @deprecated This method will be renamed to {@link #getContent()} in a future version.
- */
- @Deprecated
- @SuppressWarnings("unchecked")
- public List> getContentAsEntryList() {
- return ((Collection) data.getContent()).stream()
- .map(MapAnnotationWrapper::toMapEntry)
- .collect(toList());
- }
-
-
/**
* Gets the List of Key-Value pairs contained in the map annotation as a map.
- * As keys may not be unique, the map contains values as a list.
*
* @return See above.
*/
public Map> getContentAsMap() {
- return this.getContentAsEntryList()
+ return this.getContent()
.stream()
- .collect(groupingBy(Entry::getKey,
- mapping(Entry::getValue, toList())));
+ .collect(groupingBy(Entry::getKey, mapping(Entry::getValue, toList())));
}
@@ -205,15 +161,4 @@ public String getContentAsString() {
return data.getContentAsString();
}
-
- /**
- * @return the {@link MapAnnotationData} contained.
- *
- * @deprecated Gets the MapAnnotationData contained. Use {@link #asDataObject()} instead.
- */
- @Deprecated
- public MapAnnotationData asMapAnnotationData() {
- return data;
- }
-
}
\ No newline at end of file
diff --git a/src/main/java/fr/igred/omero/annotations/RatingAnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/RatingAnnotationWrapper.java
index 7518724d..17102630 100644
--- a/src/main/java/fr/igred/omero/annotations/RatingAnnotationWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/RatingAnnotationWrapper.java
@@ -25,7 +25,7 @@
* Class containing a RatingAnnotationData object.
* Wraps function calls to the RatingAnnotationData contained.
*/
-public class RatingAnnotationWrapper extends GenericAnnotationWrapper {
+public class RatingAnnotationWrapper extends AnnotationWrapper {
/** Indicates the object is not rated. */
public static final int LEVEL_ZERO = RatingAnnotationData.LEVEL_ZERO;
diff --git a/src/main/java/fr/igred/omero/annotations/TableWrapper.java b/src/main/java/fr/igred/omero/annotations/TableWrapper.java
index abf75031..7190ae39 100644
--- a/src/main/java/fr/igred/omero/annotations/TableWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/TableWrapper.java
@@ -18,11 +18,11 @@
package fr.igred.omero.annotations;
-import fr.igred.omero.Client;
-import fr.igred.omero.GenericObjectWrapper;
+import fr.igred.omero.ObjectWrapper;
+import fr.igred.omero.client.Client;
+import fr.igred.omero.core.ImageWrapper;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
-import fr.igred.omero.repository.ImageWrapper;
import fr.igred.omero.roi.ROIWrapper;
import ij.gui.Roi;
import ij.macro.Variable;
@@ -137,7 +137,7 @@ public TableWrapper(TableData table) {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public TableWrapper(Client client, ResultsTable results, Long imageId, List extends Roi> ijRois)
+ public TableWrapper(Client client, ResultsTable results, Long imageId, Collection extends Roi> ijRois)
throws ServiceException, AccessException, ExecutionException {
this(client, results, imageId, ijRois, ROIWrapper.IJ_PROPERTY);
}
@@ -157,7 +157,7 @@ public TableWrapper(Client client, ResultsTable results, Long imageId, List ex
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public TableWrapper(Client client, ResultsTable results, Long imageId, List extends Roi> ijRois,
+ public TableWrapper(Client client, ResultsTable results, Long imageId, Collection extends Roi> ijRois,
String roiProperty)
throws ServiceException, AccessException, ExecutionException {
roiProperty = ROIWrapper.checkProperty(roiProperty);
@@ -409,11 +409,11 @@ private static ROIData[] createROIColumn(ResultsTable results,
Map id2roi = rois.stream()
.collect(toMap(ROIWrapper::getId,
- GenericObjectWrapper::asDataObject));
+ ObjectWrapper::asDataObject));
Map name2roi = rois.stream()
.filter(r -> !r.getName().isEmpty())
.collect(toMap(ROIWrapper::getName,
- GenericObjectWrapper::asDataObject,
+ ObjectWrapper::asDataObject,
(x1, x2) -> x1));
Map label2roi = ijRois.stream()
@@ -579,7 +579,7 @@ public String toString() {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public void addRows(Client client, ResultsTable results, Long imageId, List extends Roi> ijRois)
+ public void addRows(Client client, ResultsTable results, Long imageId, Collection extends Roi> ijRois)
throws ServiceException, AccessException, ExecutionException {
this.addRows(client, results, imageId, ijRois, ROIWrapper.IJ_PROPERTY);
}
@@ -599,7 +599,7 @@ public void addRows(Client client, ResultsTable results, Long imageId, List ex
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public void addRows(Client client, ResultsTable results, Long imageId, List extends Roi> ijRois,
+ public void addRows(Client client, ResultsTable results, Long imageId, Collection extends Roi> ijRois,
String roiProperty)
throws ServiceException, AccessException, ExecutionException {
roiProperty = ROIWrapper.checkProperty(roiProperty);
diff --git a/src/main/java/fr/igred/omero/annotations/TagAnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/TagAnnotationWrapper.java
index bf3413f4..491f4465 100644
--- a/src/main/java/fr/igred/omero/annotations/TagAnnotationWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/TagAnnotationWrapper.java
@@ -18,7 +18,7 @@
package fr.igred.omero.annotations;
-import fr.igred.omero.Client;
+import fr.igred.omero.client.Client;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import omero.gateway.model.TagAnnotationData;
@@ -30,7 +30,7 @@
* Class containing a TagAnnotationData object.
* Wraps function calls to the TagAnnotationData contained.
*/
-public class TagAnnotationWrapper extends GenericAnnotationWrapper {
+public class TagAnnotationWrapper extends AnnotationWrapper {
/**
* The name space used to indicate that the tag is used a tag set.
@@ -108,15 +108,4 @@ public TagSetWrapper toTagSet() {
return new TagSetWrapper(data);
}
-
- /**
- * @return the {@link TagAnnotationData} contained.
- *
- * @deprecated Gets the TagAnnotationData contained. Use {@link #asDataObject()} instead.
- */
- @Deprecated
- public TagAnnotationData asTagAnnotationData() {
- return data;
- }
-
}
\ No newline at end of file
diff --git a/src/main/java/fr/igred/omero/annotations/TagSetWrapper.java b/src/main/java/fr/igred/omero/annotations/TagSetWrapper.java
index 2ec224c1..5820012f 100644
--- a/src/main/java/fr/igred/omero/annotations/TagSetWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/TagSetWrapper.java
@@ -18,10 +18,9 @@
package fr.igred.omero.annotations;
-import fr.igred.omero.Browser;
-import fr.igred.omero.Client;
+import fr.igred.omero.client.Browser;
+import fr.igred.omero.client.Client;
import fr.igred.omero.exception.AccessException;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
import omero.gateway.model.TagAnnotationData;
import omero.model.AnnotationAnnotationLink;
@@ -85,13 +84,11 @@ public List getTags() {
*
* @return See above.
*
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
+ * @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
*/
public List getTags(Browser browser)
- throws ExecutionException, AccessException, ServiceException, OMEROServerError {
+ throws AccessException, ServiceException {
reload(browser);
return getTags();
}
@@ -139,13 +136,11 @@ public void link(Client dm, TagAnnotationWrapper... tags)
*
* @param browser The data browser.
*
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
+ * @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
*/
public void reload(Browser browser)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError {
+ throws ServiceException, AccessException {
String query = "select t from TagAnnotation as t" +
" left outer join fetch t.annotationLinks as l" +
" left outer join fetch l.child as a" +
diff --git a/src/main/java/fr/igred/omero/annotations/TextualAnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/TextualAnnotationWrapper.java
index 6bf7258b..e74d0333 100644
--- a/src/main/java/fr/igred/omero/annotations/TextualAnnotationWrapper.java
+++ b/src/main/java/fr/igred/omero/annotations/TextualAnnotationWrapper.java
@@ -25,7 +25,7 @@
* Class containing a TextualAnnotationData object.
* Wraps function calls to the TextualAnnotationData contained.
*/
-public class TextualAnnotationWrapper extends GenericAnnotationWrapper {
+public class TextualAnnotationWrapper extends AnnotationWrapper {
/**
* Constructor of the TextualAnnotationWrapper class.
diff --git a/src/main/java/fr/igred/omero/Browser.java b/src/main/java/fr/igred/omero/client/Browser.java
similarity index 85%
rename from src/main/java/fr/igred/omero/Browser.java
rename to src/main/java/fr/igred/omero/client/Browser.java
index fb3ab445..2698b706 100644
--- a/src/main/java/fr/igred/omero/Browser.java
+++ b/src/main/java/fr/igred/omero/client/Browser.java
@@ -15,24 +15,23 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero;
+package fr.igred.omero.client;
-import fr.igred.omero.annotations.GenericAnnotationWrapper;
+import fr.igred.omero.ObjectWrapper;
+import fr.igred.omero.annotations.AnnotationWrapper;
import fr.igred.omero.annotations.MapAnnotationWrapper;
import fr.igred.omero.annotations.TagAnnotationWrapper;
import fr.igred.omero.exception.AccessException;
-import fr.igred.omero.exception.ExceptionHandler;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.meta.ExperimenterWrapper;
-import fr.igred.omero.repository.DatasetWrapper;
-import fr.igred.omero.repository.FolderWrapper;
-import fr.igred.omero.repository.ImageWrapper;
-import fr.igred.omero.repository.PlateWrapper;
-import fr.igred.omero.repository.ProjectWrapper;
-import fr.igred.omero.repository.ScreenWrapper;
-import fr.igred.omero.repository.WellWrapper;
+import fr.igred.omero.containers.DatasetWrapper;
+import fr.igred.omero.containers.FolderWrapper;
+import fr.igred.omero.core.ImageWrapper;
+import fr.igred.omero.screen.PlateWrapper;
+import fr.igred.omero.containers.ProjectWrapper;
+import fr.igred.omero.screen.ScreenWrapper;
+import fr.igred.omero.screen.WellWrapper;
import omero.RLong;
import omero.gateway.Gateway;
import omero.gateway.SecurityContext;
@@ -57,8 +56,8 @@
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
-import static fr.igred.omero.GenericObjectWrapper.flatten;
-import static fr.igred.omero.GenericObjectWrapper.wrap;
+import static fr.igred.omero.ObjectWrapper.flatten;
+import static fr.igred.omero.ObjectWrapper.wrap;
import static fr.igred.omero.exception.ExceptionHandler.call;
import static java.lang.String.format;
import static java.util.Arrays.asList;
@@ -243,11 +242,10 @@ public List getDatasets(Long... ids)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getDatasets()
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
+ throws ServiceException, AccessException, ExecutionException {
Long[] ids = this.findByQuery("select d from Dataset d")
.stream()
.map(IObject::getId)
@@ -266,11 +264,10 @@ public List getDatasets()
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getDatasets(ExperimenterWrapper experimenter)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
+ throws ServiceException, AccessException, ExecutionException {
String template = "select d from Dataset d where d.details.owner.id=%d";
String query = format(template, experimenter.getId());
Long[] ids = this.findByQuery(query)
@@ -313,11 +310,10 @@ public List getDatasets(String name)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getOrphanedDatasets(ExperimenterWrapper experimenter)
- throws ServiceException, ExecutionException, OMEROServerError, AccessException {
+ throws ServiceException, ExecutionException, AccessException {
String template = "select dataset from Dataset as dataset" +
" join fetch dataset.details.owner as o" +
" where o.id = %d" +
@@ -341,11 +337,10 @@ public List getOrphanedDatasets(ExperimenterWrapper experimenter
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getOrphanedDatasets()
- throws ServiceException, ExecutionException, OMEROServerError, AccessException {
+ throws ServiceException, ExecutionException, AccessException {
return getOrphanedDatasets(getUser());
}
@@ -501,11 +496,10 @@ public abstract List getImages(String projectName, String datasetN
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public abstract List getImages(GenericAnnotationWrapper> annotation)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException;
+ public abstract List getImages(AnnotationWrapper> annotation)
+ throws ServiceException, AccessException, ExecutionException;
/**
@@ -528,57 +522,6 @@ public List getImagesLike(String motif)
}
- /**
- * @param tag The tag annotation.
- *
- * @return See above.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets all images tagged with a specified tag from OMERO.
- */
- @Deprecated
- public List getImagesTagged(TagAnnotationWrapper tag)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
- return getImages(tag);
- }
-
-
- /**
- * @param tagId Id of the tag researched.
- *
- * @return See above.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets all images tagged with a specified tag from OMERO.
- */
- @Deprecated
- public List getImagesTagged(Long tagId)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
- return getImagesTagged(getTag(tagId));
- }
-
-
- /**
- * @param key Name of the key 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.
- * @deprecated Gets all images with a certain key
- */
- @Deprecated
- public abstract List getImagesKey(String key)
- throws ServiceException, AccessException, ExecutionException;
-
-
/**
* Gets all images with a certain key.
*
@@ -588,11 +531,10 @@ public abstract List getImagesKey(String key)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getImagesWithKey(String key)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError {
+ throws ServiceException, AccessException, ExecutionException {
List maps = getMapAnnotations(key);
Collection> selected = new ArrayList<>(maps.size());
@@ -604,22 +546,6 @@ public List getImagesWithKey(String key)
}
- /**
- * @param key Name of the key researched.
- * @param value Value associated with the key.
- *
- * @return See above.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets all images with a certain key value pair from OMERO
- */
- @Deprecated
- public abstract List getImagesPairKeyValue(String key, String value)
- throws ServiceException, AccessException, ExecutionException;
-
-
/**
* Gets all images with a certain key value pair from OMERO
*
@@ -630,11 +556,10 @@ public abstract List getImagesPairKeyValue(String key, String valu
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getImagesWithKeyValuePair(String key, String value)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError {
+ throws ServiceException, AccessException, ExecutionException {
List maps = getMapAnnotations(key, value);
Collection> selected = new ArrayList<>(maps.size());
@@ -826,11 +751,10 @@ public List getPlates(ExperimenterWrapper experimenter)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getOrphanedPlates(ExperimenterWrapper experimenter)
- throws ServiceException, ExecutionException, OMEROServerError, AccessException {
+ throws ServiceException, ExecutionException, AccessException {
String template = "select plate from Plate as plate" +
" join fetch plate.details.owner as o" +
" where o.id = %d" +
@@ -854,11 +778,10 @@ public List getOrphanedPlates(ExperimenterWrapper experimenter)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getOrphanedPlates()
- throws ServiceException, ExecutionException, OMEROServerError, AccessException {
+ throws ServiceException, ExecutionException, AccessException {
return getOrphanedPlates(getUser());
}
@@ -916,10 +839,9 @@ public List getWells(Long... ids)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
*/
public List getWells()
- throws ServiceException, AccessException, ExecutionException, OMEROServerError {
+ throws ServiceException, AccessException, ExecutionException {
Long[] ids = this.findByQuery("select w from Well w")
.stream()
.map(IObject::getId)
@@ -939,10 +861,9 @@ public List getWells()
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
*/
public List getWells(ExperimenterWrapper experimenter)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError {
+ throws ServiceException, AccessException, ExecutionException {
String template = "select w from Well w where w.details.owner.id=%d";
String query = format(template, experimenter.getId());
Long[] ids = this.findByQuery(query)
@@ -1044,22 +965,21 @@ public List loadFolders(Long... ids)
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
*/
public List getTags()
- throws OMEROServerError, ServiceException {
+ throws AccessException, ServiceException {
String klass = TagAnnotation.class.getSimpleName();
- List os = ExceptionHandler.of(getGateway(),
- g -> g.getQueryService(getCtx())
- .findAll(klass, null))
- .handleServiceOrServer("Cannot get tags")
- .get();
+ List os = call(getGateway(),
+ g -> g.getQueryService(getCtx())
+ .findAll(klass, null),
+ "Cannot get tags");
return os.stream()
.map(TagAnnotation.class::cast)
.map(TagAnnotationData::new)
.map(TagAnnotationWrapper::new)
- .sorted(Comparator.comparing(GenericObjectWrapper::getId))
+ .sorted(Comparator.comparing(ObjectWrapper::getId))
.collect(Collectors.toList());
}
@@ -1071,14 +991,14 @@ public List getTags()
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
*/
public List getTags(String name)
- throws OMEROServerError, ServiceException {
+ throws AccessException, ServiceException {
List tags = getTags();
tags.removeIf(tag -> !tag.getName().equals(name));
- tags.sort(Comparator.comparing(GenericObjectWrapper::getId));
+ tags.sort(Comparator.comparing(ObjectWrapper::getId));
return tags;
}
@@ -1090,18 +1010,16 @@ public List getTags(String name)
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
* @throws NoSuchElementException No element with this ID.
*/
public TagAnnotationWrapper getTag(Long id)
- throws OMEROServerError, ServiceException {
- String klass = TagAnnotation.class.getSimpleName();
- IObject o = ExceptionHandler.of(getGateway(),
- g -> g.getQueryService(getCtx())
- .find(klass, id))
- .handleServiceOrServer("Cannot get tag ID: " + id)
- .get();
+ throws AccessException, ServiceException {
+ IObject o = call(getGateway(),
+ g -> g.getQueryService(getCtx())
+ .find(TagAnnotation.class.getSimpleName(), id),
+ "Cannot get tag ID: " + id);
TagAnnotationData tag;
if (o == null) {
String msg = format("Tag %d doesn't exist in this context", id);
@@ -1118,23 +1036,22 @@ public TagAnnotationWrapper getTag(Long id)
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
*/
public List getMapAnnotations()
- throws OMEROServerError, ServiceException {
+ throws AccessException, ServiceException {
String klass = omero.model.MapAnnotation.class.getSimpleName();
- return ExceptionHandler.of(getGateway(),
- g -> g.getQueryService(getCtx())
- .findAll(klass, null))
- .handleServiceOrServer("Cannot get map annotations")
- .get()
- .stream()
- .map(omero.model.MapAnnotation.class::cast)
- .map(MapAnnotationData::new)
- .map(MapAnnotationWrapper::new)
- .sorted(Comparator.comparing(GenericObjectWrapper::getId))
- .collect(Collectors.toList());
+ List os = call(getGateway(),
+ g -> g.getQueryService(getCtx())
+ .findAll(klass, null),
+ "Cannot get map annotations");
+ return os.stream()
+ .map(omero.model.MapAnnotation.class::cast)
+ .map(MapAnnotationData::new)
+ .map(MapAnnotationWrapper::new)
+ .sorted(Comparator.comparing(ObjectWrapper::getId))
+ .collect(Collectors.toList());
}
@@ -1145,11 +1062,11 @@ public List getMapAnnotations()
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
*/
public List getMapAnnotations(String key)
- throws OMEROServerError, ServiceException {
+ throws AccessException, ServiceException {
String template = "select m from MapAnnotation as m" +
" join m.mapValue as mv" +
" where mv.name = '%s'";
@@ -1158,7 +1075,7 @@ public List getMapAnnotations(String key)
.map(omero.model.MapAnnotation.class::cast)
.map(MapAnnotationData::new)
.map(MapAnnotationWrapper::new)
- .sorted(Comparator.comparing(GenericObjectWrapper::getId))
+ .sorted(Comparator.comparing(ObjectWrapper::getId))
.collect(Collectors.toList());
}
@@ -1171,11 +1088,11 @@ public List getMapAnnotations(String key)
*
* @return See above.
*
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws ServiceException Cannot connect to OMERO.
*/
public List getMapAnnotations(String key, String value)
- throws OMEROServerError, ServiceException {
+ throws AccessException, ServiceException {
String template = "select m from MapAnnotation as m" +
" join m.mapValue as mv" +
" where mv.name = '%s' and mv.value = '%s'";
@@ -1184,7 +1101,7 @@ public List getMapAnnotations(String key, String value)
.map(omero.model.MapAnnotation.class::cast)
.map(MapAnnotationData::new)
.map(MapAnnotationWrapper::new)
- .sorted(Comparator.comparing(GenericObjectWrapper::getId))
+ .sorted(Comparator.comparing(ObjectWrapper::getId))
.collect(Collectors.toList());
}
@@ -1202,12 +1119,11 @@ public List getMapAnnotations(String key, String value)
*/
public MapAnnotationWrapper getMapAnnotation(Long id)
throws ServiceException, ExecutionException, AccessException {
- MapAnnotationData kv = ExceptionHandler.of(getBrowseFacility(),
- b -> b.findObject(getCtx(),
- MapAnnotationData.class,
- id))
- .handleServiceOrAccess("Cannot get map annotation with ID: " + id)
- .get();
+ MapAnnotationData kv = call(getBrowseFacility(),
+ b -> b.findObject(getCtx(),
+ MapAnnotationData.class,
+ id),
+ "Cannot get map annotation with ID: " + id);
return new MapAnnotationWrapper(kv);
}
diff --git a/src/main/java/fr/igred/omero/Client.java b/src/main/java/fr/igred/omero/client/Client.java
similarity index 74%
rename from src/main/java/fr/igred/omero/Client.java
rename to src/main/java/fr/igred/omero/client/Client.java
index a02ca384..4a22485a 100644
--- a/src/main/java/fr/igred/omero/Client.java
+++ b/src/main/java/fr/igred/omero/client/Client.java
@@ -15,20 +15,20 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero;
+package fr.igred.omero.client;
-import fr.igred.omero.annotations.GenericAnnotationWrapper;
+import fr.igred.omero.ObjectWrapper;
+import fr.igred.omero.annotations.AnnotationWrapper;
import fr.igred.omero.annotations.TableWrapper;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ExceptionHandler;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.meta.ExperimenterWrapper;
import fr.igred.omero.meta.GroupWrapper;
-import fr.igred.omero.repository.FolderWrapper;
-import fr.igred.omero.repository.ImageWrapper;
-import fr.igred.omero.repository.ProjectWrapper;
+import fr.igred.omero.containers.FolderWrapper;
+import fr.igred.omero.core.ImageWrapper;
+import fr.igred.omero.containers.ProjectWrapper;
import omero.ApiUsageException;
import omero.gateway.Gateway;
import omero.gateway.SecurityContext;
@@ -40,13 +40,12 @@
import java.util.ArrayList;
import java.util.Collection;
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;
-import static fr.igred.omero.GenericObjectWrapper.flatten;
+import static fr.igred.omero.ObjectWrapper.flatten;
import static fr.igred.omero.exception.ExceptionHandler.call;
@@ -114,67 +113,12 @@ public List getImages(String projectName, String datasetName, Stri
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
- public List getImages(GenericAnnotationWrapper> annotation)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
- return annotation.getImages(this);
- }
-
-
- /**
- * @param key Name of the key 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.
- * @deprecated Gets all images with a certain key
- */
- @Deprecated
- @Override
- public List getImagesKey(String key)
- throws ServiceException, AccessException, ExecutionException {
- List images = getImages();
- List selected = new ArrayList<>(images.size());
- for (ImageWrapper image : images) {
- Map pairsKeyValue = image.getKeyValuePairs(this);
- if (pairsKeyValue.get(key) != null) {
- selected.add(image);
- }
- }
-
- return selected;
- }
-
-
- /**
- * @param key Name of the key researched.
- * @param value Value associated with the key.
- *
- * @return See above.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets all images with a certain key value pair from OMERO
- */
- @Deprecated
- @Override
- public List getImagesPairKeyValue(String key, String value)
+ public List getImages(AnnotationWrapper> annotation)
throws ServiceException, AccessException, ExecutionException {
- List images = getImages();
- List selected = new ArrayList<>(images.size());
- for (ImageWrapper image : images) {
- Map pairsKeyValue = image.getKeyValuePairs(this);
- if (pairsKeyValue.get(key) != null && pairsKeyValue.get(key).equals(value)) {
- selected.add(image);
- }
- }
- return selected;
+ return annotation.getImages(this);
}
@@ -186,19 +130,18 @@ public List getImagesPairKeyValue(String key, String value)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
- public void delete(Collection extends GenericObjectWrapper>> objects)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
- for (GenericObjectWrapper> object : objects) {
+ public void delete(Collection extends ObjectWrapper>> objects)
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
+ for (ObjectWrapper> object : objects) {
if (object instanceof FolderWrapper) {
((FolderWrapper) object).unlinkAllROIs(this);
}
}
if (!objects.isEmpty()) {
delete(objects.stream()
- .map(GenericObjectWrapper::asIObject)
+ .map(o -> o.asDataObject().asIObject())
.collect(Collectors.toList()));
}
}
@@ -213,33 +156,14 @@ public void delete(Collection extends GenericObjectWrapper>> objects)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
- public void delete(GenericObjectWrapper> object)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ public void delete(ObjectWrapper> object)
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
if (object instanceof FolderWrapper) {
((FolderWrapper) object).unlinkAllROIs(this);
}
- delete(object.asIObject());
- }
-
-
- /**
- * @param table Table to delete.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws IllegalArgumentException ID not defined.
- * @throws OMEROServerError Server error.
- * @throws InterruptedException If block(long) does not return.
- * @deprecated Deletes a table from OMERO.
- */
- @Deprecated
- public void delete(TableWrapper table)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
- deleteTable(table);
+ delete(object.asDataObject().asIObject());
}
@@ -252,11 +176,10 @@ public void delete(TableWrapper table)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws IllegalArgumentException ID not defined.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void deleteTable(TableWrapper table)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
deleteFile(table.getId());
}
@@ -270,11 +193,10 @@ public void deleteTable(TableWrapper table)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws IllegalArgumentException ID not defined.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void deleteTables(Collection extends TableWrapper> tables)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
deleteFiles(tables.stream()
.map(TableWrapper::getId)
.toArray(Long[]::new));
@@ -316,18 +238,18 @@ public ExperimenterWrapper getUser(String username)
* @return The user matching the user ID, or null if it does not exist.
*
* @throws ServiceException Cannot connect to OMERO.
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws NoSuchElementException The requested user cannot be found.
*/
public ExperimenterWrapper getUser(long userId)
- throws ServiceException, OMEROServerError {
+ throws ServiceException, AccessException {
Experimenter user = ExceptionHandler.of(getGateway(),
g -> g.getAdminService(getCtx())
.getExperimenter(userId))
.rethrow(ApiUsageException.class,
(m, e) -> new NoSuchElementException(m),
"User not found: " + userId)
- .handleServiceOrServer("Cannot retrieve user: " + userId)
+ .handleOMEROException("Cannot retrieve user: " + userId)
.get();
return new ExperimenterWrapper(new ExperimenterData(user));
}
@@ -367,18 +289,18 @@ public GroupWrapper getGroup(String groupName)
* @return The group with the appropriate group ID, if it exists.
*
* @throws ServiceException Cannot connect to OMERO.
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
* @throws NoSuchElementException The requested group cannot be found.
*/
public GroupWrapper getGroup(long groupId)
- throws ServiceException, OMEROServerError {
+ throws ServiceException, AccessException {
ExperimenterGroup group = ExceptionHandler.of(getGateway(),
g -> g.getAdminService(getCtx())
.getGroup(groupId))
.rethrow(ApiUsageException.class,
(m, e) -> new NoSuchElementException(m),
"Group not found: " + groupId)
- .handleServiceOrServer("Cannot retrieve group: " + groupId)
+ .handleOMEROException("Cannot retrieve group: " + groupId)
.get();
return new GroupWrapper(new GroupData(group));
}
@@ -420,7 +342,7 @@ public List getGroups()
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws NoSuchElementException The requested user does not exist.
*/
- public Client sudoGetUser(String username)
+ public Client sudo(String username)
throws ServiceException, AccessException, ExecutionException {
ExperimenterWrapper sudoUser = getUser(username);
long groupId = sudoUser.getDefaultGroup().getId();
diff --git a/src/main/java/fr/igred/omero/GatewayWrapper.java b/src/main/java/fr/igred/omero/client/GatewayWrapper.java
similarity index 94%
rename from src/main/java/fr/igred/omero/GatewayWrapper.java
rename to src/main/java/fr/igred/omero/client/GatewayWrapper.java
index 2ae1befc..ca052f60 100644
--- a/src/main/java/fr/igred/omero/GatewayWrapper.java
+++ b/src/main/java/fr/igred/omero/client/GatewayWrapper.java
@@ -15,12 +15,11 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero;
+package fr.igred.omero.client;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ExceptionHandler;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.meta.ExperimenterWrapper;
import ome.formats.OMEROMetadataStoreClient;
@@ -436,15 +435,14 @@ public void closeImport() {
* @return A list of OMERO objects.
*
* @throws ServiceException Cannot connect to OMERO.
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
*/
public List findByQuery(String query)
- throws ServiceException, OMEROServerError {
- return ExceptionHandler.of(gateway,
- g -> g.getQueryService(ctx)
- .findAllByQuery(query, null))
- .handleServiceOrServer("Query failed: " + query)
- .get();
+ throws ServiceException, AccessException {
+ return call(gateway,
+ g -> g.getQueryService(ctx)
+ .findAllByQuery(query, null),
+ "Query failed: " + query);
}
@@ -475,16 +473,15 @@ public IObject save(IObject object)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
- void delete(IObject object)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ public void delete(IObject object)
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
final long wait = 500L;
ExceptionHandler.ofConsumer(getDm(),
d -> d.delete(ctx, object).loop(10, wait))
.rethrow(InterruptedException.class)
- .handleException("Cannot delete object")
+ .handleOMEROException("Cannot delete object")
.rethrow();
}
@@ -497,16 +494,15 @@ void delete(IObject object)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
- void delete(List objects)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ public void delete(List objects)
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
final long wait = 500L;
ExceptionHandler.ofConsumer(getDm(),
d -> d.delete(ctx, objects).loop(10, wait))
.rethrow(InterruptedException.class)
- .handleException("Cannot delete objects")
+ .handleOMEROException("Cannot delete objects")
.rethrow();
}
@@ -519,11 +515,10 @@ void delete(List objects)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void deleteFile(Long id)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
deleteFiles(id);
}
@@ -536,11 +531,10 @@ public void deleteFile(Long id)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void deleteFiles(Long... ids)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
List files = Arrays.stream(ids)
.map(id -> new FileAnnotationI(id, false))
.collect(Collectors.toList());
diff --git a/src/main/java/fr/igred/omero/client/package-info.java b/src/main/java/fr/igred/omero/client/package-info.java
new file mode 100644
index 00000000..3005b5dd
--- /dev/null
+++ b/src/main/java/fr/igred/omero/client/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2020-2023 GReD
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
+ * Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+/**
+ * This package contains the client classes used to interact with an OMERO server.
+ */
+package fr.igred.omero.client;
diff --git a/src/main/java/fr/igred/omero/repository/DatasetWrapper.java b/src/main/java/fr/igred/omero/containers/DatasetWrapper.java
similarity index 82%
rename from src/main/java/fr/igred/omero/repository/DatasetWrapper.java
rename to src/main/java/fr/igred/omero/containers/DatasetWrapper.java
index e139eee3..ace2e5e8 100644
--- a/src/main/java/fr/igred/omero/repository/DatasetWrapper.java
+++ b/src/main/java/fr/igred/omero/containers/DatasetWrapper.java
@@ -15,16 +15,17 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero.repository;
+package fr.igred.omero.containers;
-import fr.igred.omero.Browser;
-import fr.igred.omero.Client;
-import fr.igred.omero.GenericObjectWrapper;
+import fr.igred.omero.client.Browser;
+import fr.igred.omero.client.Client;
+import fr.igred.omero.ObjectWrapper;
import fr.igred.omero.annotations.TagAnnotationWrapper;
import fr.igred.omero.exception.AccessException;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
+import fr.igred.omero.core.ImageWrapper;
+import fr.igred.omero.RepositoryObjectWrapper;
import fr.igred.omero.roi.ROIWrapper;
import omero.RLong;
import omero.gateway.model.DatasetData;
@@ -41,17 +42,19 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
import static fr.igred.omero.exception.ExceptionHandler.call;
import static java.util.Collections.singletonList;
+import static java.util.stream.Collectors.groupingBy;
+import static java.util.stream.Collectors.mapping;
+import static java.util.stream.Collectors.toList;
/**
* Class containing a DatasetData object.
* Wraps function calls to the DatasetData contained.
*/
-public class DatasetWrapper extends GenericRepositoryObjectWrapper {
+public class DatasetWrapper extends RepositoryObjectWrapper {
/** Annotation link name for this type of object */
public static final String ANNOTATION_LINK = "DatasetAnnotationLink";
@@ -105,17 +108,6 @@ public void setName(String name) {
}
- /**
- * @return See above.
- *
- * @deprecated Returns the DatasetData contained. Use {@link #asDataObject()} instead.
- */
- @Deprecated
- public DatasetData asDatasetData() {
- return data;
- }
-
-
/**
* Gets the DatasetData description
*
@@ -155,13 +147,12 @@ protected String annotationLinkType() {
*
* @return See above.
*
- * @throws OMEROServerError Server error.
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getProjects(Client client)
- throws OMEROServerError, ServiceException, AccessException, ExecutionException {
+ throws ServiceException, AccessException, ExecutionException {
String query = "select link.parent from ProjectDatasetLink as link" +
" where link.child=" + getId();
List os = client.findByQuery(query);
@@ -256,11 +247,10 @@ public List getImagesLike(Client client, String motif)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getImagesTagged(Client client, TagAnnotationWrapper tag)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
+ throws ServiceException, AccessException, ExecutionException {
return getImagesTagged(client, tag.getId());
}
@@ -275,11 +265,10 @@ public List getImagesTagged(Client client, TagAnnotationWrapper ta
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List getImagesTagged(Client client, Long tagId)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
+ throws ServiceException, AccessException, ExecutionException {
Long[] ids = client.findByQuery("select link.parent" +
" from ImageAnnotationLink link" +
" where link.child = " +
@@ -297,24 +286,6 @@ public List getImagesTagged(Client client, Long tagId)
}
- /**
- * @param client The client handling the connection.
- * @param key Name of the key 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.
- * @deprecated Gets all images in the dataset with a certain key
- */
- @Deprecated
- public List getImagesKey(Client client, String key)
- throws ServiceException, AccessException, ExecutionException {
- return getImagesWithKey(client, key);
- }
-
-
/**
* Gets all images in the dataset with a certain key
*
@@ -339,36 +310,20 @@ public List getImagesWithKey(Client client, String key)
for (ImageData image : images) {
ImageWrapper imageWrapper = new ImageWrapper(image);
- Map pairsKeyValue = imageWrapper.getKeyValuePairs(client);
- if (pairsKeyValue.get(key) != null) {
+ Map> pairs = imageWrapper.getKeyValuePairs(client)
+ .stream()
+ .collect(groupingBy(Map.Entry::getKey,
+ mapping(Map.Entry::getValue, toList())));
+ if (pairs.get(key) != null) {
selected.add(imageWrapper);
}
}
- selected.sort(Comparator.comparing(GenericObjectWrapper::getId));
+ selected.sort(Comparator.comparing(ObjectWrapper::getId));
return selected;
}
- /**
- * @param client The client handling the connection.
- * @param key Name of the key researched.
- * @param value Value associated with the key.
- *
- * @return See above.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets all images in the dataset with a certain key value pair from OMERO
- */
- @Deprecated
- public List getImagesPairKeyValue(Client client, String key, String value)
- throws ServiceException, AccessException, ExecutionException {
- return getImagesWithKeyValuePair(client, key, value);
- }
-
-
/**
* Gets all images in the dataset with a certain key value pair from OMERO
*
@@ -393,12 +348,15 @@ public List getImagesWithKeyValuePair(Client client, String key, S
for (ImageData image : images) {
ImageWrapper imageWrapper = new ImageWrapper(image);
- Map pairs = imageWrapper.getKeyValuePairs(client);
- if (pairs.get(key) != null && pairs.get(key).equals(value)) {
+ Map> pairs = imageWrapper.getKeyValuePairs(client)
+ .stream()
+ .collect(groupingBy(Map.Entry::getKey,
+ mapping(Map.Entry::getValue, toList())));
+ if (pairs.get(key) != null && pairs.get(key).contains(value)) {
selected.add(imageWrapper);
}
}
- selected.sort(Comparator.comparing(GenericObjectWrapper::getId));
+ selected.sort(Comparator.comparing(ObjectWrapper::getId));
return selected;
}
@@ -414,7 +372,7 @@ public List getImagesWithKeyValuePair(Client client, String key, S
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
- public void addImages(Client client, List extends ImageWrapper> images)
+ public void addImages(Client client, Iterable extends ImageWrapper> images)
throws ServiceException, AccessException, ExecutionException {
for (ImageWrapper image : images) {
addImage(client, image);
@@ -450,11 +408,10 @@ public void addImage(Client client, ImageWrapper image)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void removeImage(Client client, ImageWrapper image)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
removeLink(client, "DatasetImageLink", image.getId());
}
@@ -467,14 +424,12 @@ public void removeImage(Client client, ImageWrapper image)
*
* @return If the import did not exit because of an error.
*
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
- * @throws IOException Cannot read file.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
+ * @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
+ * @throws IOException Cannot read file.
*/
public boolean importImages(Client client, String... paths)
- throws ServiceException, OMEROServerError, AccessException, IOException, ExecutionException {
+ throws ServiceException, AccessException, IOException {
return importImages(client, 1, paths);
}
@@ -488,14 +443,12 @@ public boolean importImages(Client client, String... paths)
*
* @return If the import did not exit because of an error.
*
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
- * @throws IOException Cannot read file.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
+ * @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
+ * @throws IOException Cannot read file.
*/
public boolean importImages(Client client, int threads, String... paths)
- throws ServiceException, OMEROServerError, AccessException, IOException, ExecutionException {
+ throws ServiceException, AccessException, IOException {
return importImages(client, data, threads, paths);
}
@@ -508,13 +461,12 @@ public boolean importImages(Client client, int threads, String... paths)
*
* @return The list of IDs of the newly imported images.
*
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
+ * @throws ServiceException Cannot connect to OMERO.
+ * @throws AccessException Cannot access data.
+ * @throws IOException Cannot read file.
*/
public List importImage(Client client, String path)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException {
+ throws ServiceException, AccessException, IOException {
return importImage(client, data, path);
}
@@ -531,14 +483,13 @@ public List importImage(Client client, String path)
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws InterruptedException If block(long) does not return.
*/
public List replaceImages(Client client,
Collection extends ImageWrapper> oldImages,
ImageWrapper newImage)
- throws AccessException, ServiceException, ExecutionException, OMEROServerError, InterruptedException {
+ throws AccessException, ServiceException, ExecutionException, InterruptedException {
Collection descriptions = new ArrayList<>(oldImages.size() + 1);
List orphaned = new ArrayList<>(oldImages.size());
descriptions.add(newImage.getDescription());
@@ -576,12 +527,12 @@ public List replaceImages(Client client,
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
+ * @throws IOException Cannot read file.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws InterruptedException If block(long) does not return.
*/
public List importAndReplaceImages(Client client, String path, ReplacePolicy policy)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException, InterruptedException {
+ throws ServiceException, AccessException, IOException, ExecutionException, InterruptedException {
List ids = importImage(client, path);
Long[] newIds = ids.toArray(LONGS);
@@ -599,8 +550,8 @@ public List importAndReplaceImages(Client client, String path, ReplacePoli
}
if (policy == ReplacePolicy.DELETE_ORPHANED) {
List idsToDelete = toDelete.stream()
- .map(GenericObjectWrapper::getId)
- .collect(Collectors.toList());
+ .map(ObjectWrapper::getId)
+ .collect(toList());
Iterable orphans = new ArrayList<>(toDelete);
for (ImageWrapper orphan : orphans) {
@@ -627,12 +578,12 @@ public List importAndReplaceImages(Client client, String path, ReplacePoli
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
- * @throws OMEROServerError Server error.
+ * @throws IOException Cannot read file.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws InterruptedException If block(long) does not return.
*/
public List importAndReplaceImages(Client client, String path)
- throws ServiceException, AccessException, OMEROServerError, ExecutionException, InterruptedException {
+ throws ServiceException, AccessException, IOException, ExecutionException, InterruptedException {
return importAndReplaceImages(client, path, ReplacePolicy.UNLINK);
}
diff --git a/src/main/java/fr/igred/omero/repository/FolderWrapper.java b/src/main/java/fr/igred/omero/containers/FolderWrapper.java
similarity index 79%
rename from src/main/java/fr/igred/omero/repository/FolderWrapper.java
rename to src/main/java/fr/igred/omero/containers/FolderWrapper.java
index 670f0830..40788ad6 100644
--- a/src/main/java/fr/igred/omero/repository/FolderWrapper.java
+++ b/src/main/java/fr/igred/omero/containers/FolderWrapper.java
@@ -15,16 +15,17 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero.repository;
+package fr.igred.omero.containers;
-import fr.igred.omero.Browser;
-import fr.igred.omero.Client;
-import fr.igred.omero.GenericObjectWrapper;
+import fr.igred.omero.client.Browser;
+import fr.igred.omero.client.Client;
+import fr.igred.omero.ObjectWrapper;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ExceptionHandler;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
+import fr.igred.omero.core.ImageWrapper;
+import fr.igred.omero.RepositoryObjectWrapper;
import fr.igred.omero.roi.ROIWrapper;
import omero.gateway.facility.ROIFacility;
import omero.gateway.model.AnnotationData;
@@ -55,7 +56,7 @@
* Class containing a FolderData object.
* Wraps function calls to the FolderData contained.
*/
-public class FolderWrapper extends GenericRepositoryObjectWrapper {
+public class FolderWrapper extends RepositoryObjectWrapper {
/** Annotation link name for this type of object */
public static final String ANNOTATION_LINK = "FolderAnnotationLink";
@@ -63,9 +64,6 @@ public class FolderWrapper extends GenericRepositoryObjectWrapper {
/** Empty ROI array for fast list conversion */
private static final ROIWrapper[] EMPTY_ROI_ARRAY = new ROIWrapper[0];
- /** ID of the associated image */
- private long imageID = -1L;
-
/**
* Constructor of the FolderWrapper class.
@@ -94,16 +92,16 @@ public FolderWrapper(Folder folder) {
* @param name Name of the folder.
*
* @throws ServiceException Cannot connect to OMERO.
- * @throws OMEROServerError Server error.
+ * @throws AccessException Cannot access data.
*/
public FolderWrapper(Client client, String name)
- throws ServiceException, OMEROServerError {
+ throws ServiceException, AccessException {
super(new FolderData());
data.setName(name);
Folder f = (Folder) ExceptionHandler.of(client.getGateway(),
g -> g.getUpdateService(client.getCtx())
.saveAndReturnObject(data.asIObject()))
- .handleServiceOrServer("Could not create Folder with name: " + name)
+ .handleServerAndService("Could not create Folder with name: " + name)
.get();
data.setFolder(f);
}
@@ -164,17 +162,6 @@ public void setName(String name) {
}
- /**
- * @return the FolderData.
- *
- * @deprecated Gets the folder contained in the FolderWrapper. Use {@link #asDataObject()} instead.
- */
- @Deprecated
- public FolderData asFolderData() {
- return data;
- }
-
-
/**
* Gets the folder description
*
@@ -196,21 +183,6 @@ public void setDescription(String description) {
}
- /**
- * @param client The client handling the connection.
- *
- * @throws AccessException Cannot access data.
- * @throws ServiceException Cannot connect to OMERO.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Reloads the folder from OMERO, to update all links.
- */
- @Deprecated
- public void reload(Client client)
- throws AccessException, ServiceException, ExecutionException {
- reload((Browser) client);
- }
-
-
/**
* Retrieves the parent folders for this folder.
*
@@ -249,7 +221,7 @@ public void addChild(FolderWrapper folder) {
public void addChildren(Collection extends FolderWrapper> folders) {
data.asFolder()
.addAllChildFoldersSet(folders.stream()
- .map(GenericObjectWrapper::asDataObject)
+ .map(ObjectWrapper::asDataObject)
.map(DataObject::asFolder)
.collect(toList()));
}
@@ -279,7 +251,7 @@ public void addImages(Client client, ImageWrapper... images)
throws ServiceException, AccessException, ExecutionException {
List links = new ArrayList<>(images.length);
List linkedIds = getImages().stream()
- .map(GenericObjectWrapper::getId)
+ .map(ObjectWrapper::getId)
.collect(toList());
for (ImageWrapper image : images) {
if (!linkedIds.contains(image.getId())) {
@@ -324,44 +296,6 @@ public List getImages(Client client)
}
- /**
- * @param id ID of the image to associate.
- *
- * @deprecated Sets the image associated to the folder
- */
- @Deprecated
- public void setImage(long id) {
- imageID = id;
- }
-
-
- /**
- * @param image Image to associate.
- *
- * @deprecated Sets the image associated to the folder
- */
- @Deprecated
- public void setImage(ImageWrapper image) {
- imageID = image.getId();
- }
-
-
- /**
- * @param client The client handling the connection.
- * @param roi ROI to add.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException If the ROIFacility can't be retrieved or instantiated.
- * @deprecated Adds an ROI to the folder and associate it to the image id set(an image need to be associated)
- */
- @Deprecated
- public void addROI(Client client, ROIWrapper roi)
- throws ServiceException, AccessException, ExecutionException {
- addROIs(client, imageID, roi);
- }
-
-
/**
* Adds ROIs to the folder and associate them to the provided image ID.
*
@@ -376,7 +310,7 @@ public void addROI(Client client, ROIWrapper roi)
public void addROIs(Client client, long imageId, ROIWrapper... rois)
throws ServiceException, AccessException, ExecutionException {
List roiData = Arrays.stream(rois)
- .map(GenericObjectWrapper::asDataObject)
+ .map(ObjectWrapper::asDataObject)
.collect(toList());
ROIFacility roiFac = client.getRoiFacility();
ExceptionHandler.of(roiFac,
@@ -406,24 +340,6 @@ public void addROIs(Client client, ImageWrapper image, ROIWrapper... rois)
}
- /**
- * @param client The client handling the connection.
- *
- * @return List of ROIWrapper containing the ROI.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Gets the ROI contained in the folder associated with the image id set (an image need to be
- * associated)
- */
- @Deprecated
- public List getROIs(Client client)
- throws ServiceException, AccessException, ExecutionException {
- return getROIs(client, imageID);
- }
-
-
/**
* Gets the ROIs contained in the folder associated with the provided image ID.
*
@@ -448,7 +364,7 @@ public List getROIs(Client client, long imageId)
.map(ROIResult::getROIs)
.flatMap(Collection::stream)
.map(ROIWrapper::new)
- .sorted(Comparator.comparing(GenericObjectWrapper::getId))
+ .sorted(Comparator.comparing(ObjectWrapper::getId))
.collect(toList());
return distinct(roiWrappers);
@@ -473,21 +389,6 @@ public List getROIs(Client client, ImageWrapper image)
}
- /**
- * @param client The client handling the connection.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Unlink all ROI, associated to the image set, in the folder. ROIs are now linked to the image directly
- */
- @Deprecated
- public void unlinkAllROI(Client client)
- throws ServiceException, AccessException, ExecutionException {
- unlinkAllROIs(client);
- }
-
-
/**
* Unlink all ROIs associated to the provided image ID from the folder.
* ROIs are now linked to the image directly.
@@ -540,23 +441,6 @@ public void unlinkAllROIs(Client client)
}
- /**
- * @param client The client handling the connection.
- * @param roi ROI to unlink.
- *
- * @throws ServiceException Cannot connect to OMERO.
- * @throws AccessException Cannot access data.
- * @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @deprecated Unlink an ROI, associated to the image set, in the folder. The ROI is now linked to the image
- * directly.
- */
- @Deprecated
- public void unlinkROI(Client client, ROIWrapper roi)
- throws ServiceException, AccessException, ExecutionException {
- unlinkROIs(client, roi);
- }
-
-
/**
* Unlink ROIs from the folder.
*
The ROIs are now linked to the image directly.
diff --git a/src/main/java/fr/igred/omero/repository/ProjectWrapper.java b/src/main/java/fr/igred/omero/containers/ProjectWrapper.java
similarity index 87%
rename from src/main/java/fr/igred/omero/repository/ProjectWrapper.java
rename to src/main/java/fr/igred/omero/containers/ProjectWrapper.java
index cfd19d0d..f1c2556c 100644
--- a/src/main/java/fr/igred/omero/repository/ProjectWrapper.java
+++ b/src/main/java/fr/igred/omero/containers/ProjectWrapper.java
@@ -15,16 +15,17 @@
* Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package fr.igred.omero.repository;
+package fr.igred.omero.containers;
-import fr.igred.omero.Browser;
-import fr.igred.omero.Client;
-import fr.igred.omero.GenericObjectWrapper;
+import fr.igred.omero.client.Browser;
+import fr.igred.omero.client.Client;
+import fr.igred.omero.ObjectWrapper;
import fr.igred.omero.annotations.TagAnnotationWrapper;
import fr.igred.omero.exception.AccessException;
-import fr.igred.omero.exception.OMEROServerError;
import fr.igred.omero.exception.ServiceException;
+import fr.igred.omero.core.ImageWrapper;
+import fr.igred.omero.RepositoryObjectWrapper;
import omero.gateway.model.ImageData;
import omero.gateway.model.ProjectData;
import omero.model.ProjectDatasetLink;
@@ -45,7 +46,7 @@
* Class containing a ProjectData object.
*
Wraps function calls to the Project contained
*/
-public class ProjectWrapper extends GenericRepositoryObjectWrapper {
+public class ProjectWrapper extends RepositoryObjectWrapper {
/** Annotation link name for this type of object */
public static final String ANNOTATION_LINK = "ProjectAnnotationLink";
@@ -104,17 +105,6 @@ public void setName(String name) {
}
- /**
- * @return See above.
- *
- * @deprecated Returns the ProjectData contained. Use {@link #asDataObject()} instead.
- */
- @Deprecated
- public ProjectData asProjectData() {
- return data;
- }
-
-
/**
* Gets the project description
*
@@ -226,11 +216,10 @@ public DatasetWrapper addDataset(Client client, DatasetWrapper dataset)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
- * @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void removeDataset(Client client, DatasetWrapper dataset)
- throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ throws ServiceException, AccessException, ExecutionException, InterruptedException {
removeLink(client, "ProjectDatasetLink", dataset.getId());
reload(client);
}
@@ -305,7 +294,7 @@ public List getImages(Client client, String datasetName, String im
}
List images = lists.stream()
.flatMap(Collection::stream)
- .sorted(comparing(GenericObjectWrapper::getId))
+ .sorted(comparing(ObjectWrapper::getId))
.collect(Collectors.toList());
return distinct(images);
@@ -346,11 +335,10 @@ public List