Skip to content

Commit

Permalink
Extract more interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed Dec 1, 2024
1 parent dddc786 commit 0f075cf
Show file tree
Hide file tree
Showing 43 changed files with 459 additions and 440 deletions.
48 changes: 24 additions & 24 deletions src/main/java/fr/igred/omero/Annotatable.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import fr.igred.omero.annotations.RatingAnnotation;
import fr.igred.omero.annotations.TableWrapper;
import fr.igred.omero.annotations.TagAnnotation;
import fr.igred.omero.client.Browser;
import fr.igred.omero.client.BasicBrowser;
import fr.igred.omero.client.BasicDataManager;
import fr.igred.omero.client.Client;
import fr.igred.omero.client.DataManager;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.util.ReplacePolicy;
Expand Down Expand Up @@ -68,7 +68,7 @@ public interface Annotatable extends RemoteObject {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default <A extends Annotation> boolean isLinked(Browser browser, A annotation)
default <A extends Annotation> boolean isLinked(BasicBrowser browser, A annotation)
throws ServiceException, AccessException, ExecutionException {
return getAnnotations(browser).stream().anyMatch(a -> a.getId() == annotation.getId());
}
Expand All @@ -85,7 +85,7 @@ default <A extends Annotation> boolean isLinked(Browser browser, A annotation)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default <A extends AnnotationData> void link(DataManager dm, A annotation)
default <A extends AnnotationData> void link(BasicDataManager dm, A annotation)
throws ServiceException, AccessException, ExecutionException {
String error = String.format("Cannot add %s to %s", annotation, this);
call(dm.getDMFacility(),
Expand All @@ -105,7 +105,7 @@ default <A extends AnnotationData> void link(DataManager dm, A annotation)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default <A extends Annotation> void link(DataManager dm, A annotation)
default <A extends Annotation> void link(BasicDataManager dm, A annotation)
throws ServiceException, AccessException, ExecutionException {
if (!(annotation instanceof TagAnnotation) || !((TagAnnotation) annotation).isTagSet()) {
link(dm, annotation.asDataObject());
Expand All @@ -126,7 +126,7 @@ default <A extends Annotation> void link(DataManager dm, A annotation)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default void link(DataManager dm, Annotation... annotations)
default void link(BasicDataManager dm, Annotation... annotations)
throws ServiceException, AccessException, ExecutionException {
for (Annotation annotation : annotations) {
link(dm, annotation);
Expand Down Expand Up @@ -166,7 +166,7 @@ default void linkIfNotLinked(Client client, Annotation... annotations)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
void addTag(DataManager dm, String name, String description)
void addTag(BasicDataManager dm, String name, String description)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -180,7 +180,7 @@ void addTag(DataManager dm, String name, String description)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
void addTag(DataManager dm, Long id)
void addTag(BasicDataManager dm, Long id)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -194,7 +194,7 @@ void addTag(DataManager dm, Long id)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default void addTags(DataManager dm, Long... ids)
default void addTags(BasicDataManager dm, Long... ids)
throws ServiceException, AccessException, ExecutionException {
for (Long id : ids) {
addTag(dm, id);
Expand All @@ -213,7 +213,7 @@ default void addTags(DataManager dm, Long... ids)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<TagAnnotation> getTags(Browser browser)
List<TagAnnotation> getTags(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -228,7 +228,7 @@ List<TagAnnotation> getTags(Browser browser)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<MapAnnotation> getMapAnnotations(Browser browser)
List<MapAnnotation> getMapAnnotations(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -243,7 +243,7 @@ List<MapAnnotation> getMapAnnotations(Browser browser)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
void addKeyValuePair(DataManager dm, String key, String value)
void addKeyValuePair(BasicDataManager dm, String key, String value)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -258,7 +258,7 @@ void addKeyValuePair(DataManager dm, String key, String value)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default List<Map.Entry<String, String>> getKeyValuePairs(Browser browser)
default List<Map.Entry<String, String>> getKeyValuePairs(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException {
return getMapAnnotations(browser).stream()
.map(MapAnnotation::getContent)
Expand All @@ -280,7 +280,7 @@ default List<Map.Entry<String, String>> getKeyValuePairs(Browser browser)
* @throws NoSuchElementException Key not found.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default List<String> getValues(Browser browser, String key)
default List<String> getValues(BasicBrowser browser, String key)
throws ServiceException, AccessException, ExecutionException {
return getMapAnnotations(browser).stream()
.map(MapAnnotation::getContentAsMap)
Expand All @@ -303,7 +303,7 @@ default List<String> getValues(Browser browser, String key)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<RatingAnnotation> getRatings(Browser browser, List<Long> userIds)
List<RatingAnnotation> getRatings(BasicBrowser browser, List<Long> userIds)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -318,7 +318,7 @@ List<RatingAnnotation> getRatings(Browser browser, List<Long> userIds)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default List<RatingAnnotation> getRatings(Browser browser)
default List<RatingAnnotation> getRatings(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException {
return getRatings(browser, null);
}
Expand Down Expand Up @@ -351,7 +351,7 @@ void rate(Client client, int rating)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
int getMyRating(Browser browser)
int getMyRating(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -365,7 +365,7 @@ int getMyRating(Browser browser)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default void addTable(DataManager dm, TableWrapper table)
default void addTable(BasicDataManager dm, TableWrapper table)
throws ServiceException, AccessException, ExecutionException {
String error = "Cannot add table to " + this;

Expand Down Expand Up @@ -439,7 +439,7 @@ default void addAndReplaceTable(Client client, TableWrapper table)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
TableWrapper getTable(DataManager dm, Long fileId)
TableWrapper getTable(BasicDataManager dm, Long fileId)
throws ServiceException, AccessException, ExecutionException;


Expand All @@ -454,7 +454,7 @@ TableWrapper getTable(DataManager dm, Long fileId)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default List<TableWrapper> getTables(DataManager dm)
default List<TableWrapper> getTables(BasicDataManager dm)
throws ServiceException, AccessException, ExecutionException {
Collection<FileAnnotationData> tables = call(dm.getTablesFacility(),
tf -> tf.getAvailableTables(dm.getCtx(), asDataObject()),
Expand Down Expand Up @@ -482,7 +482,7 @@ default List<TableWrapper> getTables(DataManager dm)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws InterruptedException The thread was interrupted.
*/
default long addFile(DataManager dm, File file)
default long addFile(BasicDataManager dm, File file)
throws ExecutionException, InterruptedException {
String name = file.getName();
return dm.getDMFacility()
Expand Down Expand Up @@ -541,7 +541,7 @@ default long addAndReplaceFile(Client client, File file)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<FileAnnotation> getFileAnnotations(Browser browser)
List<FileAnnotation> getFileAnnotations(BasicBrowser browser)
throws ExecutionException, ServiceException, AccessException;


Expand Down Expand Up @@ -588,7 +588,7 @@ <A extends Annotation> void unlink(Client client, Collection<A> annotations)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
default List<AnnotationData> getAnnotationData(Browser browser)
default List<AnnotationData> getAnnotationData(BasicBrowser browser)
throws AccessException, ServiceException, ExecutionException {
return call(browser.getMetadataFacility(),
m -> m.getAnnotations(browser.getCtx(), asDataObject()),
Expand All @@ -607,7 +607,7 @@ default List<AnnotationData> getAnnotationData(Browser browser)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
List<Annotation> getAnnotations(Browser browser)
List<Annotation> getAnnotations(BasicBrowser browser)
throws AccessException, ServiceException, ExecutionException;


Expand Down
24 changes: 12 additions & 12 deletions src/main/java/fr/igred/omero/AnnotatableWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import fr.igred.omero.annotations.TableWrapper;
import fr.igred.omero.annotations.TagAnnotation;
import fr.igred.omero.annotations.TagAnnotationWrapper;
import fr.igred.omero.client.Browser;
import fr.igred.omero.client.BasicBrowser;
import fr.igred.omero.client.BasicDataManager;
import fr.igred.omero.client.Client;
import fr.igred.omero.client.DataManager;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.util.ReplacePolicy;
Expand Down Expand Up @@ -96,7 +96,7 @@ protected AnnotatableWrapper(T o) {
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public void addTag(DataManager dm, String name, String description)
public void addTag(BasicDataManager dm, String name, String description)
throws ServiceException, AccessException, ExecutionException {
TagAnnotation tag = new TagAnnotationWrapper(new TagAnnotationData(name));
tag.setDescription(description);
Expand All @@ -115,7 +115,7 @@ public void addTag(DataManager dm, String name, String description)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public void addTag(DataManager dm, Long id)
public void addTag(BasicDataManager dm, Long id)
throws ServiceException, AccessException, ExecutionException {
TagAnnotationI tag = new TagAnnotationI(id, false);
TagAnnotationData tagData = new TagAnnotationData(tag);
Expand All @@ -135,7 +135,7 @@ public void addTag(DataManager dm, Long id)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<TagAnnotation> getTags(Browser browser)
public List<TagAnnotation> getTags(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException {
List<Class<? extends AnnotationData>> types = singletonList(TagAnnotationData.class);

Expand Down Expand Up @@ -167,7 +167,7 @@ public List<TagAnnotation> getTags(Browser browser)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<MapAnnotation> getMapAnnotations(Browser browser)
public List<MapAnnotation> getMapAnnotations(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException {
List<Class<? extends AnnotationData>> types = singletonList(MapAnnotationData.class);
List<AnnotationData> annotations = call(browser.getMetadataFacility(),
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<MapAnnotation> getMapAnnotations(Browser browser)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public void addKeyValuePair(DataManager dm, String key, String value)
public void addKeyValuePair(BasicDataManager dm, String key, String value)
throws ServiceException, AccessException, ExecutionException {
MapAnnotation pkv = new MapAnnotationWrapper(key, value);
link(dm, pkv);
Expand All @@ -218,7 +218,7 @@ public void addKeyValuePair(DataManager dm, String key, String value)
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
public List<RatingAnnotation> getRatings(Browser browser, List<Long> userIds)
public List<RatingAnnotation> getRatings(BasicBrowser browser, List<Long> userIds)
throws ServiceException, AccessException, ExecutionException {
String error = "Cannot retrieve rating annotations from " + this;

Expand Down Expand Up @@ -285,7 +285,7 @@ public void rate(Client client, int rating)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public int getMyRating(Browser browser)
public int getMyRating(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException {
List<Long> userIds = singletonList(browser.getCtx().getExperimenter());

Expand Down Expand Up @@ -345,7 +345,7 @@ public void addAndReplaceTable(Client client, TableWrapper table, ReplacePolicy
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public TableWrapper getTable(DataManager dm, Long fileId)
public TableWrapper getTable(BasicDataManager dm, Long fileId)
throws ServiceException, AccessException, ExecutionException {
TableData info = call(dm.getTablesFacility(),
tf -> tf.getTableInfo(dm.getCtx(), fileId),
Expand Down Expand Up @@ -423,7 +423,7 @@ public long addAndReplaceFile(Client client, File file, ReplacePolicy policy)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<FileAnnotation> getFileAnnotations(Browser browser)
public List<FileAnnotation> getFileAnnotations(BasicBrowser browser)
throws ExecutionException, ServiceException, AccessException {
String error = "Cannot retrieve file annotations from " + this;

Expand Down Expand Up @@ -543,7 +543,7 @@ protected void removeLink(Client client, String linkType, long childId)
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
@Override
public List<Annotation> getAnnotations(Browser browser)
public List<Annotation> getAnnotations(BasicBrowser browser)
throws AccessException, ServiceException, ExecutionException {
return wrap(getAnnotationData(browser), Wrapper::wrap);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/igred/omero/ObjectWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package fr.igred.omero;


import fr.igred.omero.client.DataManager;
import fr.igred.omero.client.BasicDataManager;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.meta.Experimenter;
Expand Down Expand Up @@ -181,7 +181,7 @@ public String toString() {
*/
@Override
@SuppressWarnings("unchecked")
public void saveAndUpdate(DataManager dm)
public void saveAndUpdate(BasicDataManager dm)
throws ExecutionException, ServiceException, AccessException {
data = (T) call(dm.getDMFacility(),
d -> d.saveAndReturnObject(dm.getCtx(), data),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/igred/omero/RemoteObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package fr.igred.omero;


import fr.igred.omero.client.DataManager;
import fr.igred.omero.client.BasicDataManager;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;
import fr.igred.omero.meta.Experimenter;
Expand Down Expand Up @@ -155,7 +155,7 @@ List<U> flatten(Collection<? extends Collection<? extends U>> lists) {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
void saveAndUpdate(DataManager dm)
void saveAndUpdate(BasicDataManager dm)
throws ExecutionException, ServiceException, AccessException;


Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/igred/omero/RepositoryObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package fr.igred.omero;


import fr.igred.omero.client.Browser;
import fr.igred.omero.client.BasicBrowser;
import fr.igred.omero.exception.AccessException;
import fr.igred.omero.exception.ServiceException;

Expand Down Expand Up @@ -55,7 +55,7 @@ public interface RepositoryObject extends Annotatable {
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
*/
void reload(Browser browser)
void reload(BasicBrowser browser)
throws ServiceException, AccessException, ExecutionException;

}
3 changes: 2 additions & 1 deletion src/main/java/fr/igred/omero/annotations/Annotation.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import fr.igred.omero.RemoteObject;
import fr.igred.omero.client.BasicBrowser;
import fr.igred.omero.client.Browser;
import fr.igred.omero.containers.Dataset;
import fr.igred.omero.containers.Folder;
Expand Down Expand Up @@ -102,7 +103,7 @@ public interface Annotation extends RemoteObject {
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
*/
default int countAnnotationLinks(Browser browser)
default int countAnnotationLinks(BasicBrowser browser)
throws ServiceException, AccessException {
String q = "select link.parent from ome.model.IAnnotationLink link" +
" where link.child.id=" + getId();
Expand Down
Loading

0 comments on commit 0f075cf

Please sign in to comment.