Skip to content

Instantly share code, notes, and snippets.

@dominikl
Created December 13, 2018 11:27
Show Gist options
  • Save dominikl/46894aa878b8bfe487431de3ab04ae71 to your computer and use it in GitHub Desktop.
Save dominikl/46894aa878b8bfe487431de3ab04ae71 to your computer and use it in GitHub Desktop.
import omero.api.IQueryPrx;
import omero.gateway.Gateway;
import omero.gateway.LoginCredentials;
import omero.gateway.SecurityContext;
import omero.gateway.model.ExperimenterData;
import omero.gateway.model.FilesetData;
import omero.log.SimpleLogger;
import omero.model.Fileset;
import omero.sys.ParametersI;
public class GetFilePaths {
public static void main(String[] args) throws Exception {
try (Gateway gw = new Gateway(new SimpleLogger())) {
LoginCredentials lc = new LoginCredentials("user", "pass", "localhost");
ExperimenterData user = gw.connect(lc);
SecurityContext ctx = new SecurityContext(user.getGroupId());
long imageId = 119202;
IQueryPrx qs = gw.getQueryService(ctx);
String query = "select fs from Fileset as fs "
+ "join fetch fs.images as image "
+ "left outer join fetch fs.usedFiles as usedFile "
+ "join fetch usedFile.originalFile as f "
+ "where image.id = :imageId";
ParametersI param = new ParametersI();
param.add("imageId", omero.rtypes.rlong(imageId));
Fileset queryResult = (Fileset) qs.findByQuery(query, param);
FilesetData fs = new FilesetData(queryResult);
System.out.println("Imported from:");
for (String path : fs.getUsedFilePaths()) {
System.out.println(path);
}
System.out.println("\nPath on server:");
for (String path : fs.getAbsolutePaths()) {
System.out.println(path);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment