Skip to content

Commit

Permalink
Rename client variable to browser when appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed Nov 27, 2024
1 parent bec1550 commit 01bbd56
Show file tree
Hide file tree
Showing 12 changed files with 316 additions and 316 deletions.
96 changes: 48 additions & 48 deletions src/main/java/fr/igred/omero/AnnotatableWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected AnnotatableWrapper(T o) {
/**
* Checks if a specific annotation is linked to the object.
*
* @param client The client handling the connection.
* @param browser The data browser.
* @param annotation Annotation to be checked.
* @param <A> The type of the annotation.
*
Expand All @@ -97,9 +97,9 @@ protected AnnotatableWrapper(T o) {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public <A extends AnnotationWrapper<?>> boolean isLinked(Browser client, A annotation)
public <A extends AnnotationWrapper<?>> boolean isLinked(Browser browser, A annotation)
throws ServiceException, AccessException, ExecutionException {
return getAnnotations(client).stream().anyMatch(a -> a.getId() == annotation.getId());
return getAnnotations(browser).stream().anyMatch(a -> a.getId() == annotation.getId());
}


Expand Down Expand Up @@ -242,20 +242,20 @@ public void addTags(Client client, Long... ids)
/**
* Gets all tags linked to an object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @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<TagAnnotationWrapper> getTags(Browser client)
public List<TagAnnotationWrapper> getTags(Browser browser)
throws ServiceException, AccessException, ExecutionException {
List<Class<? extends AnnotationData>> types = singletonList(TagAnnotationData.class);

List<AnnotationData> annotations = call(client.getMetadata(),
m -> m.getAnnotations(client.getCtx(),
List<AnnotationData> annotations = call(browser.getMetadata(),
m -> m.getAnnotations(browser.getCtx(),
data,
types,
null),
Expand All @@ -273,19 +273,19 @@ public List<TagAnnotationWrapper> getTags(Browser client)
/**
* Gets all map annotations linked to an object in OMERO, if possible.
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @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<MapAnnotationWrapper> getMapAnnotations(Browser client)
public List<MapAnnotationWrapper> getMapAnnotations(Browser browser)
throws ServiceException, AccessException, ExecutionException {
List<Class<? extends AnnotationData>> types = singletonList(MapAnnotationData.class);
List<AnnotationData> annotations = call(client.getMetadata(),
m -> m.getAnnotations(client.getCtx(),
List<AnnotationData> annotations = call(browser.getMetadata(),
m -> m.getAnnotations(browser.getCtx(),
data,
types,
null),
Expand Down Expand Up @@ -322,28 +322,28 @@ public void addKeyValuePair(Client client, String key, String value)
/**
* Gets the List of Key-Value pairs associated to an object.
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @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<Map.Entry<String, String>> getKeyValuePairs(Browser client)
public List<Map.Entry<String, String>> getKeyValuePairs(Browser browser)
throws ServiceException, AccessException, ExecutionException {
return getMapAnnotations(client).stream()
.map(MapAnnotationWrapper::getContent)
.flatMap(List::stream)
.collect(toList());
return getMapAnnotations(browser).stream()
.map(MapAnnotationWrapper::getContent)
.flatMap(List::stream)
.collect(toList());
}


/**
* Gets the value from a Key-Value pair associated to the object.
*
* @param client The client handling the connection.
* @param key Key researched.
* @param browser The data browser.
* @param key Key researched.
*
* @return Value associated to the key.
*
Expand All @@ -352,21 +352,21 @@ public List<Map.Entry<String, String>> getKeyValuePairs(Browser client)
* @throws NoSuchElementException Key not found.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List<String> getValues(Browser client, String key)
public List<String> getValues(Browser browser, String key)
throws ServiceException, AccessException, ExecutionException {
return getMapAnnotations(client).stream()
.map(MapAnnotationWrapper::getContentAsMap)
.map(kv -> kv.get(key))
.filter(Objects::nonNull)
.flatMap(List::stream)
.collect(toList());
return getMapAnnotations(browser).stream()
.map(MapAnnotationWrapper::getContentAsMap)
.map(kv -> kv.get(key))
.filter(Objects::nonNull)
.flatMap(List::stream)
.collect(toList());
}


/**
* Returns all the ratings from the specified user IDs for this object.
*
* @param client The client handling the connection.
* @param browser The data browser.
* @param userIds List of user IDs (can be null, i. e. all users).
*
* @return See above.
Expand All @@ -375,14 +375,14 @@ public List<String> getValues(Browser client, String key)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
private List<RatingAnnotationWrapper> getRatings(Browser client, List<Long> userIds)
private List<RatingAnnotationWrapper> getRatings(Browser browser, List<Long> userIds)
throws ServiceException, AccessException, ExecutionException {
String error = "Cannot retrieve rating annotations from " + this;

List<Class<? extends AnnotationData>> types = singletonList(RatingAnnotationData.class);

List<AnnotationData> annotations = call(client.getMetadata(),
m -> m.getAnnotations(client.getCtx(),
List<AnnotationData> annotations = call(browser.getMetadata(),
m -> m.getAnnotations(browser.getCtx(),
data,
types,
userIds),
Expand All @@ -400,17 +400,17 @@ private List<RatingAnnotationWrapper> getRatings(Browser client, List<Long> user
/**
* Returns all the ratings from all users for this object.
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @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<RatingAnnotationWrapper> getRatings(Browser client)
public List<RatingAnnotationWrapper> getRatings(Browser browser)
throws ServiceException, AccessException, ExecutionException {
return getRatings(client, null);
return getRatings(browser, null);
}


Expand Down Expand Up @@ -449,19 +449,19 @@ public void rate(Client client, int rating)
/**
* Returns the user rating for this object (averaged if multiple ratings are linked).
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @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 int getMyRating(Browser client)
public int getMyRating(Browser browser)
throws ServiceException, AccessException, ExecutionException {
List<Long> userIds = singletonList(client.getCtx().getExperimenter());
List<Long> userIds = singletonList(browser.getCtx().getExperimenter());

List<RatingAnnotationWrapper> ratings = getRatings(client, userIds);
List<RatingAnnotationWrapper> ratings = getRatings(browser, userIds);
int score = 0;
for (RatingAnnotationWrapper rate : ratings) {
score += rate.getRating();
Expand Down Expand Up @@ -707,22 +707,22 @@ public long addAndReplaceFile(Client client, File file)
/**
* Returns the file annotations
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @return The list of tile annotations.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List<FileAnnotationWrapper> getFileAnnotations(Browser client)
public List<FileAnnotationWrapper> getFileAnnotations(Browser browser)
throws ExecutionException, ServiceException, AccessException {
String error = "Cannot retrieve file annotations from " + this;

List<Class<? extends AnnotationData>> types = singletonList(FileAnnotationData.class);

List<AnnotationData> annotations = call(client.getMetadata(),
m -> m.getAnnotations(client.getCtx(),
List<AnnotationData> annotations = call(browser.getMetadata(),
m -> m.getAnnotations(browser.getCtx(),
data,
types,
null),
Expand Down Expand Up @@ -825,36 +825,36 @@ protected void removeLink(Client client, String linkType, long childId)
/**
* Retrieves annotations linked to the object.
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @return A list of annotations, as AnnotationData.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
private List<AnnotationData> getAnnotationData(Browser client)
private List<AnnotationData> getAnnotationData(Browser browser)
throws AccessException, ServiceException, ExecutionException {
return call(client.getMetadata(),
m -> m.getAnnotations(client.getCtx(), data),
return call(browser.getMetadata(),
m -> m.getAnnotations(browser.getCtx(), data),
"Cannot get annotations from " + this);
}


/**
* Retrieves annotations linked to the object (of known types).
*
* @param client The client handling the connection.
* @param browser The data browser.
*
* @return A list of annotations.
*
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public AnnotationList getAnnotations(Browser client)
public AnnotationList getAnnotations(Browser browser)
throws AccessException, ServiceException, ExecutionException {
List<AnnotationData> annotationData = getAnnotationData(client);
List<AnnotationData> annotationData = getAnnotationData(browser);

AnnotationList annotations = new AnnotationList(annotationData.size());
annotationData.forEach(annotations::add);
Expand Down
Loading

0 comments on commit 01bbd56

Please sign in to comment.