Skip to content

Commit

Permalink
5.9.2 (#37)
Browse files Browse the repository at this point in the history
* Switch to pom-scijava 32.0.0
* Switch to JUnit5
* Send output from tests to target/logs
* Change setup to JDK 8
* Add methods to create a screen and refactor code to import images to screens
* Add method addAndReplaceTable (#32)
* Add test for addAndReplaceTable
* Make Client constructor with arguments public (#34)
* Add methods to retrieve well, plate and screen from an image (#35)
* Add LibraryChecker utility class to check if required libraries are available (#36)
* Make specific tests for LibraryChecker
* Add time increment to ImagePlus and set the position to the first slice
* Use float coordinates for IJ ROI conversion
* Split ImageTest
* Simplify key/value tests in ImageTest
* Prevent GatewayWrapper from containing null fields
* Override toString method in GatewayWrapper and add server information to context
* Change disconnect method so that a sudo client does not disconnect the gateway
* Replace System.err.println with logger
* Add tests
* Add serialVersionUID to classes that require it
* Fix and improve Javadoc
* Rename some variables
* Minor code improvements
  • Loading branch information
ppouchin authored Aug 31, 2022
1 parent 67f7050 commit a745816
Show file tree
Hide file tree
Showing 72 changed files with 2,575 additions and 1,585 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
*.iml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM maven:3.6.3-jdk-11
FROM maven:3.8.6-jdk-8
MAINTAINER [email protected]

COPY . /src
Expand Down
97 changes: 18 additions & 79 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<artifactId>pom-scijava</artifactId>
<groupId>org.scijava</groupId>
<version>30.0.0</version>
<version>32.0.0</version>
</parent>

<groupId>fr.igred</groupId>
<artifactId>simple-omero-client</artifactId>
<version>5.9.1</version>
<version>5.9.2</version>
<packaging>jar</packaging>

<name>Simple OMERO Client</name>
Expand Down Expand Up @@ -91,96 +91,37 @@
<maven.compiler.target>8</maven.compiler.target>
<license.licenseName>gpl_v2</license.licenseName>
<license.copyrightOwners>GReD</license.copyrightOwners>
<!-- 3.2.0 erroneously detects runtime dependencies as test-only. -->
<maven-dependency-plugin.version>3.3.0</maven-dependency-plugin.version>
<!-- User surefire 3.0.0-M7 for JUnit5. -->
<maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>omero-gateway</artifactId>
<version>5.6.7</version>
</dependency>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>omero-model</artifactId>
<version>5.6.3</version>
<version>${omero-model.version}</version>
<exclusions>
<exclusion>
<groupId>net.jcip</groupId>
<artifactId>jcip-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>omero-blitz</artifactId>
<version>5.5.8</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.pdfbox</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.postgresql</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.codahale.metrics</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.openmicroscopy</groupId>
<artifactId>ome-common</artifactId>
<version>6.0.7</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ome</groupId>
<artifactId>formats-api</artifactId>
<version>6.7.0</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -218,8 +159,8 @@

<repositories>
<repository>
<id>ome.maven</id>
<url>https://artifacts.openmicroscopy.org/artifactory/maven/</url>
<id>scijava.public</id>
<url>https://maven.scijava.org/content/groups/public</url>
</repository>
</repositories>

Expand All @@ -228,7 +169,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<version>${maven-assembly-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -266,7 +207,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -287,7 +228,6 @@
<configuration>
<source>8</source>
<detectJavaApiLink>false</detectJavaApiLink>
<additionalJOption>--no-module-directories</additionalJOption>
</configuration>
<executions>
<execution>
Expand All @@ -308,7 +248,6 @@
<configuration>
<source>8</source>
<detectJavaApiLink>false</detectJavaApiLink>
<additionalJOption>--no-module-directories</additionalJOption>
</configuration>
</plugin>
</plugins>
Expand Down
13 changes: 6 additions & 7 deletions src/main/java/fr/igred/omero/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import omero.gateway.model.ScreenData;
import omero.gateway.model.TagAnnotationData;
import omero.gateway.model.WellData;
import omero.log.SimpleLogger;
import omero.model.IObject;
import omero.model.TagAnnotation;

Expand Down Expand Up @@ -80,7 +79,7 @@ public class Client extends GatewayWrapper {
* Constructor of the Client class. Initializes the gateway.
*/
public Client() {
super(new Gateway(new SimpleLogger()));
super(null);
}


Expand All @@ -91,7 +90,7 @@ public Client() {
* @param ctx The security context
* @param user The user
*/
private Client(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user) {
public Client(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user) {
super(gateway, ctx, user);
}

Expand Down Expand Up @@ -769,7 +768,7 @@ public TagAnnotationWrapper getTag(Long id) throws OMEROServerError, ServiceExce
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws OMEROServerError If the thread was interrupted.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void delete(Collection<? extends GenericObjectWrapper<?>> objects)
Expand All @@ -793,7 +792,7 @@ public void delete(Collection<? extends GenericObjectWrapper<?>> objects)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws OMEROServerError If the thread was interrupted.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void delete(GenericObjectWrapper<?> object)
Expand All @@ -813,8 +812,8 @@ public void delete(GenericObjectWrapper<?> object)
* @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 If the thread was interrupted.
* @throws IllegalArgumentException ID not defined.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void delete(TableWrapper table)
Expand Down
52 changes: 38 additions & 14 deletions src/main/java/fr/igred/omero/GatewayWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import omero.gateway.facility.MetadataFacility;
import omero.gateway.facility.ROIFacility;
import omero.gateway.facility.TablesFacility;
import omero.gateway.model.ExperimenterData;
import omero.log.SimpleLogger;
import omero.model.FileAnnotationI;
import omero.model.IObject;

Expand All @@ -55,7 +57,7 @@
public abstract class GatewayWrapper {

/** Gateway linking the code to OMERO, only linked to one group. */
private final Gateway gateway;
private Gateway gateway;

/** Security context of the user, contains the permissions of the user in this group. */
private SecurityContext ctx;
Expand All @@ -76,15 +78,16 @@ protected GatewayWrapper(Gateway gateway) {

/**
* Abstract constructor of the GatewayWrapper class.
* <p> Null arguments will be replaced with default empty objects.
*
* @param gateway The Gateway.
* @param ctx The Security Context.
* @param user The connected user.
*/
protected GatewayWrapper(Gateway gateway, SecurityContext ctx, ExperimenterWrapper user) {
this.gateway = gateway;
this.ctx = ctx;
this.user = user;
this.gateway = gateway != null ? gateway : new Gateway(new SimpleLogger());
this.user = user != null ? user : new ExperimenterWrapper(new ExperimenterData());
this.ctx = ctx != null ? ctx : new SecurityContext(-1);
}


Expand Down Expand Up @@ -162,7 +165,7 @@ public String getSessionId() throws ServiceException {
* @return See above.
*/
public boolean isConnected() {
return gateway.isConnected() && ctx != null;
return gateway.isConnected();
}


Expand Down Expand Up @@ -237,20 +240,24 @@ public void connect(LoginCredentials cred) throws ServiceException {
}
this.ctx = new SecurityContext(user.getGroupId());
this.ctx.setExperimenter(this.user.asExperimenterData());
this.ctx.setServerInformation(cred.getServer());
}


/**
* Disconnects the user
*/
public void disconnect() {
if (gateway.isConnected()) {
if (ctx != null) {
ctx.setExperimenter(null);
if (isConnected()) {
boolean sudo = ctx.isSudo();
user = new ExperimenterWrapper(new ExperimenterData());
ctx = new SecurityContext(-1);
ctx.setExperimenter(user.asExperimenterData());
if (sudo) {
gateway = new Gateway(gateway.getLogger());
} else {
gateway.disconnect();
}
ctx = null;
user = null;
gateway.disconnect();
}
}

Expand Down Expand Up @@ -410,7 +417,7 @@ public IObject save(IObject object) throws ServiceException, AccessException, Ex
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws OMEROServerError If the thread was interrupted.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
void delete(IObject object)
Expand All @@ -432,7 +439,7 @@ void delete(IObject object)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws OMEROServerError If the thread was interrupted.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
void delete(List<IObject> objects)
Expand All @@ -454,7 +461,7 @@ void delete(List<IObject> objects)
* @throws ServiceException Cannot connect to OMERO.
* @throws AccessException Cannot access data.
* @throws ExecutionException A Facility can't be retrieved or instantiated.
* @throws OMEROServerError If the thread was interrupted.
* @throws OMEROServerError Server error.
* @throws InterruptedException If block(long) does not return.
*/
public void deleteFile(Long id)
Expand All @@ -463,5 +470,22 @@ public void deleteFile(Long id)
delete(file);
}


/**
* Overridden to return the host name, the group ID, the username and the connection status.
*
* @return See above.
*/
@Override
public String toString() {
String host = ctx.getServerInformation() != null ? ctx.getServerInformation().getHost() : "null";
return String.format("%s{host=%s, groupID=%d, userID=%d, connected=%b}",
getClass().getSimpleName(),
host,
ctx.getGroupID(),
user.getId(),
gateway.isConnected());
}

}

Loading

0 comments on commit a745816

Please sign in to comment.