Skip to content

Commit

Permalink
Update Javadoc and variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed Nov 29, 2024
1 parent 51cb0f1 commit 588fe57
Show file tree
Hide file tree
Showing 16 changed files with 231 additions and 230 deletions.
104 changes: 52 additions & 52 deletions src/main/java/fr/igred/omero/AnnotatableWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,38 @@ public <A extends AnnotationWrapper<?>> boolean isLinked(Browser browser, A anno
/**
* Attach an {@link AnnotationData} to this object.
*
* @param client The client handling the connection.
* @param dm The data manager.
* @param annotation The {@link AnnotationData}.
* @param <A> The type of the annotation.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
protected <A extends AnnotationData> void link(DataManager client, A annotation)
protected <A extends AnnotationData> void link(DataManager dm, A annotation)
throws ServiceException, AccessException, ExecutionException {
String error = String.format("Cannot add %s to %s", annotation, this);
call(client.getDMFacility(),
d -> d.attachAnnotation(client.getCtx(), annotation, data),
call(dm.getDMFacility(),
d -> d.attachAnnotation(dm.getCtx(), annotation, data),
error);
}


/**
* Adds an annotation to the object in OMERO, if possible (and if it's not a TagSet).
*
* @param client The client handling the connection.
* @param dm The data manager.
* @param annotation Annotation to be added.
* @param <A> The type of the annotation.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public <A extends AnnotationWrapper<?>> void link(DataManager client, A annotation)
public <A extends AnnotationWrapper<?>> void link(DataManager dm, A annotation)
throws ServiceException, AccessException, ExecutionException {
if (!(annotation instanceof TagAnnotationWrapper) || !((TagAnnotationWrapper) annotation).isTagSet()) {
link(client, annotation.asDataObject());
link(dm, annotation.asDataObject());
} else {
String msg = "Tag sets should only be linked to tags";
throw new IllegalArgumentException(msg);
Expand All @@ -149,17 +149,17 @@ public <A extends AnnotationWrapper<?>> void link(DataManager client, A annotati
/**
* Adds multiple annotations to the object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param dm The data manager.
* @param annotations Annotations to add.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void link(DataManager client, AnnotationWrapper<?>... annotations)
public void link(DataManager dm, AnnotationWrapper<?>... annotations)
throws ServiceException, AccessException, ExecutionException {
for (AnnotationWrapper<?> annotation : annotations) {
link(client, annotation);
link(dm, annotation);
}
}

Expand Down Expand Up @@ -188,54 +188,54 @@ public void linkIfNotLinked(Client client, AnnotationWrapper<?>... annotations)
/**
* Adds a newly created tag to the object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param dm The data manager.
* @param name Tag Name.
* @param description Tag description.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void addTag(DataManager client, String name, String description)
public void addTag(DataManager dm, String name, String description)
throws ServiceException, AccessException, ExecutionException {
TagAnnotationWrapper tag = new TagAnnotationWrapper(new TagAnnotationData(name));
tag.setDescription(description);
link(client, tag);
link(dm, tag);
}


/**
* Adds a tag to the object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param id ID of the tag to add to the object.
* @param dm The data manager.
* @param id ID of the tag to add to the object.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void addTag(DataManager client, Long id)
public void addTag(DataManager dm, Long id)
throws ServiceException, AccessException, ExecutionException {
TagAnnotationI tag = new TagAnnotationI(id, false);
TagAnnotationData tagData = new TagAnnotationData(tag);
link(client, tagData);
link(dm, tagData);
}


/**
* Adds multiple tags by ID to the object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param ids Array of tag id in OMERO to add.
* @param dm The data manager.
* @param ids Array of tag id in OMERO to add.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void addTags(DataManager client, Long... ids)
public void addTags(DataManager dm, Long... ids)
throws ServiceException, AccessException, ExecutionException {
for (Long id : ids) {
addTag(client, id);
addTag(dm, id);
}
}

Expand Down Expand Up @@ -305,18 +305,18 @@ public List<MapAnnotationWrapper> getMapAnnotations(Browser browser)
/**
* Adds a single Key-Value pair to the object.
*
* @param client The client handling the connection.
* @param key Name of the key.
* @param value Value associated to the key.
* @param dm The data manager.
* @param key Name of the key.
* @param value Value associated to the key.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void addKeyValuePair(DataManager client, String key, String value)
public void addKeyValuePair(DataManager dm, String key, String value)
throws ServiceException, AccessException, ExecutionException {
MapAnnotationWrapper pkv = new MapAnnotationWrapper(key, value);
link(client, pkv);
link(dm, pkv);
}


Expand Down Expand Up @@ -474,27 +474,27 @@ public int getMyRating(Browser browser)
/**
* Adds a table to the object in OMERO.
*
* @param client The client handling the connection.
* @param table Table to add to the object.
* @param dm The data manager.
* @param table Table to add to the object.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public void addTable(DataManager client, TableWrapper table)
public void addTable(DataManager dm, TableWrapper table)
throws ServiceException, AccessException, ExecutionException {
String error = "Cannot add table to " + this;

TablesFacility tablesFacility = client.getTablesFacility();
TablesFacility tablesFacility = dm.getTablesFacility();
TableData tableData = call(tablesFacility,
tf -> tf.addTable(client.getCtx(),
tf -> tf.addTable(dm.getCtx(),
data,
table.getName(),
table.createTable()),
error);

Collection<FileAnnotationData> tables = call(tablesFacility,
tf -> tf.getAvailableTables(client.getCtx(),
tf -> tf.getAvailableTables(dm.getCtx(),
data),
error);
long fileId = tableData.getOriginalFileId();
Expand Down Expand Up @@ -563,7 +563,7 @@ public void addAndReplaceTable(Client client, TableWrapper table)
/**
* Gets a certain table linked to the object in OMERO.
*
* @param client The client handling the connection.
* @param dm The data manager.
* @param fileId FileId of the table researched.
*
* @return See above.
Expand All @@ -572,18 +572,18 @@ public void addAndReplaceTable(Client client, TableWrapper table)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public TableWrapper getTable(DataManager client, Long fileId)
public TableWrapper getTable(DataManager dm, Long fileId)
throws ServiceException, AccessException, ExecutionException {
TableData info = call(client.getTablesFacility(),
tf -> tf.getTableInfo(client.getCtx(), fileId),
TableData info = call(dm.getTablesFacility(),
tf -> tf.getTableInfo(dm.getCtx(), fileId),
"Cannot get table from " + this);
long nRows = info.getNumberOfRows();
TableData table = call(client.getTablesFacility(),
tf -> tf.getTable(client.getCtx(), fileId,
TableData table = call(dm.getTablesFacility(),
tf -> tf.getTable(dm.getCtx(), fileId,
0, nRows - 1),
"Cannot get table from " + this);
String name = call(client.getTablesFacility(),
tf -> tf.getAvailableTables(client.getCtx(), data)
String name = call(dm.getTablesFacility(),
tf -> tf.getAvailableTables(dm.getCtx(), data)
.stream()
.filter(t -> t.getFileID() == fileId)
.map(FileAnnotationData::getDescription)
Expand All @@ -599,23 +599,23 @@ public TableWrapper getTable(DataManager client, Long fileId)
/**
* Gets all tables linked to the object in OMERO.
*
* @param client The client handling the connection.
* @param dm The data manager.
*
* @return See above.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List<TableWrapper> getTables(DataManager client)
public List<TableWrapper> getTables(DataManager dm)
throws ServiceException, AccessException, ExecutionException {
Collection<FileAnnotationData> tables = call(client.getTablesFacility(),
tf -> tf.getAvailableTables(client.getCtx(), data),
Collection<FileAnnotationData> tables = call(dm.getTablesFacility(),
tf -> tf.getAvailableTables(dm.getCtx(), data),
"Cannot get tables from " + this);

List<TableWrapper> tablesWrapper = new ArrayList<>(tables.size());
for (FileAnnotationData table : tables) {
TableWrapper tableWrapper = getTable(client, table.getFileID());
TableWrapper tableWrapper = getTable(dm, table.getFileID());
tableWrapper.setId(table.getId());
tablesWrapper.add(tableWrapper);
}
Expand All @@ -627,21 +627,21 @@ public List<TableWrapper> getTables(DataManager client)
/**
* Uploads a file and links it to the object
*
* @param client The client handling the connection.
* @param file File to add.
* @param dm The data manager.
* @param file File to add.
*
* @return ID of the file created in OMERO.
*
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws InterruptedException The thread was interrupted.
*/
public long addFile(DataManager client, File file)
public long addFile(DataManager dm, File file)
throws ExecutionException, InterruptedException {
String name = file.getName();
return client.getDMFacility()
.attachFile(client.getCtx(), file, null, "", name, data)
.get()
.getId();
return dm.getDMFacility()
.attachFile(dm.getCtx(), file, null, "", name, data)
.get()
.getId();
}


Expand Down
8 changes: 4 additions & 4 deletions src/main/java/fr/igred/omero/ObjectWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,17 @@ public String toString() {
/**
* Saves and updates object.
*
* @param client The client handling the connection.
* @param dm The data manager.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@SuppressWarnings("unchecked")
public void saveAndUpdate(DataManager client)
public void saveAndUpdate(DataManager dm)
throws ExecutionException, ServiceException, AccessException {
data = (T) call(client.getDMFacility(),
d -> d.saveAndReturnObject(client.getCtx(), data),
data = (T) call(dm.getDMFacility(),
d -> d.saveAndReturnObject(dm.getCtx(), data),
"Cannot save and update object.");
}

Expand Down
24 changes: 12 additions & 12 deletions src/main/java/fr/igred/omero/RepositoryObjectWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static List<Pixels> importCandidates(DataObject target, ImportLibrary li
/**
* Imports all images candidates in the paths to the target in OMERO.
*
* @param client The client handling the connection.
* @param conn The connection handler.
* @param target The import target.
* @param threads The number of threads (same value used for filesets and uploads).
* @param paths Paths to the image files on the computer.
Expand All @@ -123,19 +123,19 @@ private static List<Pixels> importCandidates(DataObject target, ImportLibrary li
* @throws AccessException Cannot access data.
* @throws IOException Cannot read file.
*/
protected static boolean importImages(ConnectionHandler client, DataObject target, int threads, String... paths)
protected static boolean importImages(ConnectionHandler conn, DataObject target, int threads, String... paths)
throws ServiceException, AccessException, IOException {
boolean success;

ImportConfig config = new ImportConfig();
String type = PojoMapper.getGraphType(target.getClass());
config.target.set(type + ":" + target.getId());
config.username.set(client.getUser().getUserName());
config.email.set(client.getUser().getEmail());
config.username.set(conn.getUser().getUserName());
config.email.set(conn.getUser().getEmail());
config.parallelFileset.set(threads);
config.parallelUpload.set(threads);

OMEROMetadataStoreClient store = client.getImportStore();
OMEROMetadataStoreClient store = conn.getImportStore();
try (OMEROWrapper reader = new OMEROWrapper(config)) {
ExceptionHandler.ofConsumer(store, s -> s.logVersionInfo(config.getIniVersionNumber()))
.handleServerAndService("Cannot log version information during import.")
Expand All @@ -150,7 +150,7 @@ protected static boolean importImages(ConnectionHandler client, DataObject targe
ImportCandidates candidates = new ImportCandidates(reader, paths, handler);
success = library.importCandidates(config, candidates);
} finally {
client.closeImport();
conn.closeImport();
}

return success;
Expand All @@ -160,7 +160,7 @@ protected static boolean importImages(ConnectionHandler client, DataObject targe
/**
* Imports one image file to the target in OMERO.
*
* @param client The client handling the connection.
* @param conn The connection handler.
* @param target The import target.
* @param path Path to the image file on the computer.
*
Expand All @@ -170,17 +170,17 @@ protected static boolean importImages(ConnectionHandler client, DataObject targe
* @throws AccessException Cannot access data.
* @throws IOException Cannot read file.
*/
protected static List<Long> importImage(ConnectionHandler client, DataObject target, String path)
protected static List<Long> importImage(ConnectionHandler conn, DataObject target, String path)
throws ServiceException, AccessException, IOException {
ImportConfig config = new ImportConfig();
String type = PojoMapper.getGraphType(target.getClass());
config.target.set(type + ":" + target.getId());
config.username.set(client.getUser().getUserName());
config.email.set(client.getUser().getEmail());
config.username.set(conn.getUser().getUserName());
config.email.set(conn.getUser().getEmail());

Collection<Pixels> pixels;

OMEROMetadataStoreClient store = client.getImportStore();
OMEROMetadataStoreClient store = conn.getImportStore();
try (OMEROWrapper reader = new OMEROWrapper(config)) {
ExceptionHandler.ofConsumer(store, s -> s.logVersionInfo(config.getIniVersionNumber()))
.handleServerAndService("Cannot log version information during import.")
Expand All @@ -195,7 +195,7 @@ protected static List<Long> importImage(ConnectionHandler client, DataObject tar
ImportCandidates candidates = new ImportCandidates(reader, new String[]{path}, handler);
pixels = importCandidates(target, library, config, candidates);
} finally {
client.closeImport();
conn.closeImport();
}

return pixels.stream()
Expand Down
Loading

0 comments on commit 588fe57

Please sign in to comment.