Skip to content

Commit adb96cc

Browse files
authored
Merge pull request #85 from GReD-Clermont/small-fixes
Small fixes
2 parents 892500a + 97806f9 commit adb96cc

7 files changed

Lines changed: 19 additions & 30 deletions

File tree

src/main/java/fr/igred/omero/AnnotatableWrapper.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,19 +552,21 @@ public void addMapAnnotation(Client client, MapAnnotationWrapper mapAnnotation)
552552
*/
553553
public void addTable(Client client, TableWrapper table)
554554
throws ServiceException, AccessException, ExecutionException {
555+
String error = "Cannot add table to " + this;
556+
555557
TablesFacility tablesFacility = client.getTablesFacility();
556558
TableData tableData = ExceptionHandler.of(tablesFacility,
557559
tf -> tf.addTable(client.getCtx(),
558560
data,
559561
table.getName(),
560562
table.createTable()))
561-
.handleOMEROException("Cannot add table to " + this)
563+
.handleOMEROException(error)
562564
.get();
563565

564566
Collection<FileAnnotationData> tables = ExceptionHandler.of(tablesFacility,
565567
tf -> tf.getAvailableTables(client.getCtx(),
566568
data))
567-
.handleOMEROException("Cannot add table to " + this)
569+
.handleOMEROException(error)
568570
.get();
569571
long fileId = tableData.getOriginalFileId();
570572

@@ -590,17 +592,18 @@ public void addTable(Client client, TableWrapper table)
590592
*/
591593
public void addAndReplaceTable(Client client, TableWrapper table, ReplacePolicy policy)
592594
throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
595+
String error = "Cannot add table to " + this;
596+
593597
Collection<FileAnnotationWrapper> tables = wrap(ExceptionHandler.of(client.getTablesFacility(),
594598
t -> t.getAvailableTables(
595599
client.getCtx(), data))
596-
.handleOMEROException("Cannot get tables from "
597-
+ this)
600+
.handleOMEROException(error)
598601
.get(),
599602
FileAnnotationWrapper::new);
600603
addTable(client, table);
601604
tables.removeIf(t -> !t.getDescription().equals(table.getName()));
605+
this.unlink(client, tables);
602606
for (FileAnnotationWrapper fileAnnotation : tables) {
603-
this.unlink(client, fileAnnotation);
604607
if (policy == ReplacePolicy.DELETE ||
605608
policy == ReplacePolicy.DELETE_ORPHANED && fileAnnotation.countAnnotationLinks(client) == 0) {
606609
client.deleteFile(fileAnnotation.getId());

src/main/java/fr/igred/omero/Browser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ public List<ImageWrapper> getImages(String name)
434434
/**
435435
* Gets all orphaned images owned by the specified user.
436436
*
437+
* @param experimenter The user.
438+
*
437439
* @return See above.
438440
*
439441
* @throws ServiceException Cannot connect to OMERO.

src/main/java/fr/igred/omero/GenericObjectWrapper.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import fr.igred.omero.exception.AccessException;
2222
import fr.igred.omero.exception.ExceptionHandler;
23-
import fr.igred.omero.exception.OMEROServerError;
2423
import fr.igred.omero.exception.ServiceException;
2524
import fr.igred.omero.meta.ExperimenterWrapper;
2625
import omero.gateway.model.DataObject;
@@ -93,24 +92,6 @@ protected GenericObjectWrapper(T o) {
9392
}
9493

9594

96-
/**
97-
* Deletes an object from OMERO.
98-
*
99-
* @param client The client handling the connection.
100-
* @param object The OMERO object.
101-
*
102-
* @throws ServiceException Cannot connect to OMERO.
103-
* @throws AccessException Cannot access data.
104-
* @throws ExecutionException A Facility can't be retrieved or instantiated.
105-
* @throws OMEROServerError Server error.
106-
* @throws InterruptedException If block(long) does not return.
107-
*/
108-
protected static void delete(Client client, IObject object)
109-
throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
110-
client.delete(object);
111-
}
112-
113-
11495
/**
11596
* Only keeps objects with different IDs in a collection.
11697
*

src/main/java/fr/igred/omero/repository/ImageWrapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public class ImageWrapper extends GenericRepositoryObjectWrapper<ImageData> {
8585
/** Annotation link name for this type of object */
8686
public static final String ANNOTATION_LINK = "ImageAnnotationLink";
8787

88+
/** Default IJ property to store image ID. */
89+
public static final String IJ_ID_PROPERTY = "IMAGE_ID";
90+
8891

8992
/**
9093
* Constructor of the class ImageWrapper
@@ -771,7 +774,7 @@ public ImagePlus toImagePlus(Client client,
771774
}
772775
imp.setPosition(1);
773776
if (IJ.getVersion().compareTo("1.53a") >= 0) {
774-
imp.setProp("IMAGE_ID", getId());
777+
imp.setProp(IJ_ID_PROPERTY, getId());
775778
}
776779
return imp;
777780
}

src/main/java/fr/igred/omero/roi/GenericShapeWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public abstract class GenericShapeWrapper<T extends ShapeData> extends Annotatab
6464
public static final String ANNOTATION_LINK = "ShapeAnnotationLink";
6565

6666
/** Default IJ property to store shape ID. */
67-
public static final String IJ_IDPROPERTY = "SHAPE_ID";
67+
public static final String IJ_ID_PROPERTY = "SHAPE_ID";
6868

6969
/** Transparent color */
7070
private static final Color TRANSPARENT = new Color(0, 0, 0, 0);
@@ -272,7 +272,7 @@ protected void copyToIJRoi(ij.gui.Roi ijRoi) {
272272
if (ijRoi instanceof TextRoi) {
273273
copyToIJTextRoi((TextRoi) ijRoi);
274274
}
275-
ijRoi.setProperty(IJ_IDPROPERTY, String.valueOf(data.getId()));
275+
ijRoi.setProperty(IJ_ID_PROPERTY, String.valueOf(data.getId()));
276276
}
277277

278278

src/main/java/fr/igred/omero/roi/ROIWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public static List<ij.gui.Roi> toImageJ(Collection<? extends ROIWrapper> rois, S
286286
* @return See above.
287287
*/
288288
private static ij.gui.Roi xor(Collection<? extends ij.gui.Roi> rois) {
289-
String idProperty = GenericShapeWrapper.IJ_IDPROPERTY;
289+
String idProperty = GenericShapeWrapper.IJ_ID_PROPERTY;
290290
String shapeIDs = rois.stream()
291291
.map(r -> r.getProperty(idProperty))
292292
.collect(Collectors.joining(","));
@@ -317,7 +317,7 @@ private static ij.gui.Roi xor(Collection<? extends ij.gui.Roi> rois) {
317317
* @return See above.
318318
*/
319319
private static PointRoi combine(Collection<? extends PointRoi> points) {
320-
String idProperty = GenericShapeWrapper.IJ_IDPROPERTY;
320+
String idProperty = GenericShapeWrapper.IJ_ID_PROPERTY;
321321
String shapeIDs = points.stream()
322322
.map(p -> p.getProperty(idProperty))
323323
.collect(Collectors.joining(","));

src/test/java/fr/igred/omero/repository/ImageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void testToImagePlus() throws Exception {
376376
ImageStatistics stats = difference.getStatistics();
377377

378378
assertEquals(0, (int) stats.max);
379-
assertEquals(String.valueOf(IMAGE2.id), imp.getProp("IMAGE_ID"));
379+
assertEquals(String.valueOf(IMAGE2.id), imp.getProp(ImageWrapper.IJ_ID_PROPERTY));
380380
}
381381

382382

0 commit comments

Comments
 (0)