From 701b12d7331e9b18402b2edfc2caf8381c14b27b Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 23 Feb 2024 23:36:46 +0100 Subject: [PATCH 1/5] Remove unused method --- .../fr/igred/omero/GenericObjectWrapper.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/main/java/fr/igred/omero/GenericObjectWrapper.java b/src/main/java/fr/igred/omero/GenericObjectWrapper.java index 30c098c4..145657ab 100644 --- a/src/main/java/fr/igred/omero/GenericObjectWrapper.java +++ b/src/main/java/fr/igred/omero/GenericObjectWrapper.java @@ -93,24 +93,6 @@ protected GenericObjectWrapper(T o) { } - /** - * Deletes an object from OMERO. - * - * @param client The client handling the connection. - * @param object The OMERO 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. - */ - protected static void delete(Client client, IObject object) - throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException { - client.delete(object); - } - - /** * Only keeps objects with different IDs in a collection. * From 64dd346bc75b314fe093061f6267ee06604bc960 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 23 Feb 2024 23:37:46 +0100 Subject: [PATCH 2/5] Rename static variables for ID properties --- src/main/java/fr/igred/omero/repository/ImageWrapper.java | 5 ++++- src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java | 4 ++-- src/main/java/fr/igred/omero/roi/ROIWrapper.java | 4 ++-- src/test/java/fr/igred/omero/repository/ImageTest.java | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/fr/igred/omero/repository/ImageWrapper.java b/src/main/java/fr/igred/omero/repository/ImageWrapper.java index 39a1f9ec..826d9c40 100644 --- a/src/main/java/fr/igred/omero/repository/ImageWrapper.java +++ b/src/main/java/fr/igred/omero/repository/ImageWrapper.java @@ -85,6 +85,9 @@ public class ImageWrapper extends GenericRepositoryObjectWrapper { /** Annotation link name for this type of object */ public static final String ANNOTATION_LINK = "ImageAnnotationLink"; + /** Default IJ property to store image ID. */ + public static final String IJ_ID_PROPERTY = "IMAGE_ID"; + /** * Constructor of the class ImageWrapper @@ -771,7 +774,7 @@ public ImagePlus toImagePlus(Client client, } imp.setPosition(1); if (IJ.getVersion().compareTo("1.53a") >= 0) { - imp.setProp("IMAGE_ID", getId()); + imp.setProp(IJ_ID_PROPERTY, getId()); } return imp; } diff --git a/src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java b/src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java index 5daa4d58..932d09ac 100644 --- a/src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java +++ b/src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java @@ -64,7 +64,7 @@ public abstract class GenericShapeWrapper extends Annotatab public static final String ANNOTATION_LINK = "ShapeAnnotationLink"; /** Default IJ property to store shape ID. */ - public static final String IJ_IDPROPERTY = "SHAPE_ID"; + public static final String IJ_ID_PROPERTY = "SHAPE_ID"; /** Transparent color */ private static final Color TRANSPARENT = new Color(0, 0, 0, 0); @@ -272,7 +272,7 @@ protected void copyToIJRoi(ij.gui.Roi ijRoi) { if (ijRoi instanceof TextRoi) { copyToIJTextRoi((TextRoi) ijRoi); } - ijRoi.setProperty(IJ_IDPROPERTY, String.valueOf(data.getId())); + ijRoi.setProperty(IJ_ID_PROPERTY, String.valueOf(data.getId())); } diff --git a/src/main/java/fr/igred/omero/roi/ROIWrapper.java b/src/main/java/fr/igred/omero/roi/ROIWrapper.java index ac9d77a5..dab8c05b 100644 --- a/src/main/java/fr/igred/omero/roi/ROIWrapper.java +++ b/src/main/java/fr/igred/omero/roi/ROIWrapper.java @@ -286,7 +286,7 @@ public static List toImageJ(Collection rois, S * @return See above. */ private static ij.gui.Roi xor(Collection rois) { - String idProperty = GenericShapeWrapper.IJ_IDPROPERTY; + String idProperty = GenericShapeWrapper.IJ_ID_PROPERTY; String shapeIDs = rois.stream() .map(r -> r.getProperty(idProperty)) .collect(Collectors.joining(",")); @@ -317,7 +317,7 @@ private static ij.gui.Roi xor(Collection rois) { * @return See above. */ private static PointRoi combine(Collection points) { - String idProperty = GenericShapeWrapper.IJ_IDPROPERTY; + String idProperty = GenericShapeWrapper.IJ_ID_PROPERTY; String shapeIDs = points.stream() .map(p -> p.getProperty(idProperty)) .collect(Collectors.joining(",")); diff --git a/src/test/java/fr/igred/omero/repository/ImageTest.java b/src/test/java/fr/igred/omero/repository/ImageTest.java index b5a43f26..3dc62f16 100644 --- a/src/test/java/fr/igred/omero/repository/ImageTest.java +++ b/src/test/java/fr/igred/omero/repository/ImageTest.java @@ -376,7 +376,7 @@ void testToImagePlus() throws Exception { ImageStatistics stats = difference.getStatistics(); assertEquals(0, (int) stats.max); - assertEquals(String.valueOf(IMAGE2.id), imp.getProp("IMAGE_ID")); + assertEquals(String.valueOf(IMAGE2.id), imp.getProp(ImageWrapper.IJ_ID_PROPERTY)); } From 67f52d00f706a764a90636f426a496a4c39dcc57 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 23 Feb 2024 23:38:12 +0100 Subject: [PATCH 3/5] Refactor code --- .../java/fr/igred/omero/AnnotatableWrapper.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/igred/omero/AnnotatableWrapper.java b/src/main/java/fr/igred/omero/AnnotatableWrapper.java index aeb26016..39f565fd 100644 --- a/src/main/java/fr/igred/omero/AnnotatableWrapper.java +++ b/src/main/java/fr/igred/omero/AnnotatableWrapper.java @@ -552,19 +552,21 @@ public void addMapAnnotation(Client client, MapAnnotationWrapper mapAnnotation) */ public void addTable(Client client, TableWrapper table) throws ServiceException, AccessException, ExecutionException { + String error = "Cannot add table to " + this; + TablesFacility tablesFacility = client.getTablesFacility(); TableData tableData = ExceptionHandler.of(tablesFacility, tf -> tf.addTable(client.getCtx(), data, table.getName(), table.createTable())) - .handleOMEROException("Cannot add table to " + this) + .handleOMEROException(error) .get(); Collection tables = ExceptionHandler.of(tablesFacility, tf -> tf.getAvailableTables(client.getCtx(), data)) - .handleOMEROException("Cannot add table to " + this) + .handleOMEROException(error) .get(); long fileId = tableData.getOriginalFileId(); @@ -590,17 +592,18 @@ public void addTable(Client client, TableWrapper table) */ public void addAndReplaceTable(Client client, TableWrapper table, ReplacePolicy policy) throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException { + String error = "Cannot add table to " + this; + Collection tables = wrap(ExceptionHandler.of(client.getTablesFacility(), t -> t.getAvailableTables( client.getCtx(), data)) - .handleOMEROException("Cannot get tables from " - + this) + .handleOMEROException(error) .get(), FileAnnotationWrapper::new); addTable(client, table); tables.removeIf(t -> !t.getDescription().equals(table.getName())); + this.unlink(client, tables); for (FileAnnotationWrapper fileAnnotation : tables) { - this.unlink(client, fileAnnotation); if (policy == ReplacePolicy.DELETE || policy == ReplacePolicy.DELETE_ORPHANED && fileAnnotation.countAnnotationLinks(client) == 0) { client.deleteFile(fileAnnotation.getId()); From 2ffcee3ad5217304289c67a8285df6fef2887497 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 23 Feb 2024 23:42:16 +0100 Subject: [PATCH 4/5] [skip] Add missing Javadoc parameter --- src/main/java/fr/igred/omero/Browser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/fr/igred/omero/Browser.java b/src/main/java/fr/igred/omero/Browser.java index 71c5e116..5a5e6634 100644 --- a/src/main/java/fr/igred/omero/Browser.java +++ b/src/main/java/fr/igred/omero/Browser.java @@ -434,6 +434,8 @@ public List getImages(String name) /** * Gets all orphaned images owned by the specified user. * + * @param experimenter The user. + * * @return See above. * * @throws ServiceException Cannot connect to OMERO. From 97806f9cef448f069ec299d9f035f371caafd188 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Sat, 24 Feb 2024 00:41:13 +0100 Subject: [PATCH 5/5] Remove useless import --- src/main/java/fr/igred/omero/GenericObjectWrapper.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/fr/igred/omero/GenericObjectWrapper.java b/src/main/java/fr/igred/omero/GenericObjectWrapper.java index 145657ab..a67b829b 100644 --- a/src/main/java/fr/igred/omero/GenericObjectWrapper.java +++ b/src/main/java/fr/igred/omero/GenericObjectWrapper.java @@ -20,7 +20,6 @@ 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 omero.gateway.model.DataObject;