diff --git a/pom.xml b/pom.xml
index 3cb7ee70..4a21c0f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
fr.igred
simple-omero-client
- 5.13.1
+ 5.14.0
jar
Simple OMERO Client
diff --git a/src/main/java/fr/igred/omero/Client.java b/src/main/java/fr/igred/omero/Client.java
index ca8aac72..8b098402 100644
--- a/src/main/java/fr/igred/omero/Client.java
+++ b/src/main/java/fr/igred/omero/Client.java
@@ -218,6 +218,24 @@ public void delete(GenericObjectWrapper> object)
}
+ /**
+ * @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);
+ }
+
+
/**
* Deletes a table from OMERO.
*
@@ -230,12 +248,30 @@ public void delete(GenericObjectWrapper> object)
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
- public void delete(TableWrapper table)
+ public void deleteTable(TableWrapper table)
throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
deleteFile(table.getId());
}
+ /**
+ * Deletes tables from OMERO.
+ *
+ * @param tables List of tables 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.
+ */
+ public void deleteTables(Collection extends TableWrapper> tables)
+ throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
+ deleteFiles(tables.stream().map(TableWrapper::getId).toArray(Long[]::new));
+ }
+
+
/**
* Returns the user which matches the username.
*
diff --git a/src/main/java/fr/igred/omero/GatewayWrapper.java b/src/main/java/fr/igred/omero/GatewayWrapper.java
index e30c7238..0fdbeb6a 100644
--- a/src/main/java/fr/igred/omero/GatewayWrapper.java
+++ b/src/main/java/fr/igred/omero/GatewayWrapper.java
@@ -40,11 +40,13 @@
import omero.model.FileAnnotationI;
import omero.model.IObject;
+import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
/**
@@ -501,8 +503,27 @@ void delete(List objects)
*/
public void deleteFile(Long id)
throws ServiceException, AccessException, ExecutionException, OMEROServerError, InterruptedException {
- FileAnnotationI file = new FileAnnotationI(id, false);
- delete(file);
+ deleteFiles(id);
+ }
+
+
+ /**
+ * Deletes files from OMERO.
+ *
+ * @param ids List of files IDs to delete.
+ *
+ * @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 {
+ List files = Arrays.stream(ids)
+ .map(id -> new FileAnnotationI(id, false))
+ .collect(Collectors.toList());
+ delete(files);
}
diff --git a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
index babeb40b..4504f5df 100644
--- a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
+++ b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
@@ -154,7 +154,7 @@ void testCreateTableWithROIsFromIJResults1() throws Exception {
long roiId = rois.get(0).getId();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -188,7 +188,7 @@ void testCreateTableWithROIsFromIJResults2() throws Exception {
long roiId = rois.get(0).getId();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -220,7 +220,7 @@ void testCreateTableWithROIsFromIJResults3() throws Exception {
long roiId = rois.get(0).getId();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -250,7 +250,7 @@ void testCreateTableWithROIsFromIJResults4() throws Exception {
long roiId = rois.get(0).getId();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -278,7 +278,7 @@ void testCreateTableFromIJResults() throws Exception {
Object[][] data = tables.get(0).getData();
- client.delete(tables.get(0));
+ client.deleteTable(tables.get(0));
List noTables = image.getTables(client);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -308,7 +308,7 @@ void testAddRowsFromIJResults() throws Exception {
Object[][] data = tables.get(0).getData();
- client.delete(tables.get(0));
+ client.deleteTables(tables);
List noTables = image.getTables(client);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -345,7 +345,7 @@ void testAddRowsWithROIsFromIJResults() throws Exception {
long roiId = rois.get(0).getId();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(2, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -385,7 +385,7 @@ void testCreateTableWithLocalROIFromIJResults1() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(2, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -424,7 +424,7 @@ void testCreateTableWithLocalROIFromIJResults2() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(2, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -477,7 +477,7 @@ void testCreateTableWithROINamesFromIJResults1() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(2, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -535,7 +535,7 @@ void testCreateTableWithROINamesFromIJResults2() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(2, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -596,7 +596,7 @@ void testNumberFormatException() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -627,7 +627,7 @@ void testNumericName() throws Exception {
Object[][] data = table.getData();
Long fileId = table.getFileId();
- client.delete(table);
+ client.deleteTable(table);
assertEquals(1, rowCount);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
@@ -663,7 +663,7 @@ void testAddRowsFromIJResultsInverted() throws Exception {
assertEquals(1, tables.size());
assertEquals(2, tables.get(0).getRowCount());
- client.delete(tables.get(0));
+ client.deleteTables(tables);
List noTables = image.getTables(client);
assertEquals(imageId, ((DataObject) data[0][0]).getId());
diff --git a/src/test/java/fr/igred/omero/annotations/TableTest.java b/src/test/java/fr/igred/omero/annotations/TableTest.java
index 7fbcba21..224b73fc 100644
--- a/src/test/java/fr/igred/omero/annotations/TableTest.java
+++ b/src/test/java/fr/igred/omero/annotations/TableTest.java
@@ -66,7 +66,7 @@ void testCreateTable() throws Exception {
dataset.addTable(client, table);
List tables = dataset.getTables(client);
- client.delete(tables.get(0));
+ client.deleteTables(tables);
List noTables = dataset.getTables(client);
assertEquals(1, tables.size());