Skip to content

Commit

Permalink
URL Query Only
Browse files Browse the repository at this point in the history
Before the table would open results based upon the saved JSON attribute "saved file name", but now it does it on the URL query variable "DataSetName"
  • Loading branch information
AvocadoMoon committed Mar 26, 2024
1 parent ae97a10 commit 7e8749e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
11 changes: 9 additions & 2 deletions view-simulation-results/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-imglib2</artifactId>
<version>7.0.0</version>
<version>6.0.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.janelia.saalfeldlab/n5-aws-s3 -->
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-aws-s3</artifactId>
<version>4.0.1</version>
<version>4.0.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.janelia.saalfeldlab/n5-universe -->
Expand All @@ -161,6 +161,13 @@
<version>1.2.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.janelia.saalfeldlab/n5-ij -->
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-ij</artifactId>
<version>4.0.0</version>
</dependency>




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.AmazonS3URI;
import com.google.gson.GsonBuilder;
import ij.ImagePlus;
import net.imglib2.cache.img.CachedCellImg;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.type.numeric.real.DoubleType;
import org.janelia.saalfeldlab.n5.N5FSReader;
import org.janelia.saalfeldlab.n5.N5KeyValueReader;
import org.janelia.saalfeldlab.n5.N5Reader;
import org.janelia.saalfeldlab.n5.ij.N5IJUtils;
import org.janelia.saalfeldlab.n5.imglib2.N5Utils;
import org.janelia.saalfeldlab.n5.s3.AmazonS3KeyValueAccess;
import org.janelia.saalfeldlab.n5.s3.N5AmazonS3Reader;

import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -32,6 +37,7 @@ public class SimResultsLoader {
private String s3ObjectKey;
private URI uri;
private String dataSetChosen;
private String uriSafeDataSetChosen;

public SimResultsLoader(){

Expand Down Expand Up @@ -90,7 +96,7 @@ public void createS3Client(){
createS3Client(uri.toString(), null, null);
}
public void createS3Client(HashMap<String, String> credentials, HashMap<String, String> endpoint){createS3Client(uri.toString(), credentials, endpoint);}
public ArrayList<String> getS3N5DatasetList(){
public ArrayList<String> getS3N5DatasetList() throws IOException {

// used as a flag to tell that remote access is occurring, and that there is no local files
try(N5AmazonS3Reader n5AmazonS3Reader = new N5AmazonS3Reader(this.s3Client, this.bucketName)) {
Expand Down Expand Up @@ -122,27 +128,26 @@ public ImagePlus getImgPlusFromLocalN5File() throws IOException {
}

public ImagePlus getImgPlusFromN5File() throws IOException {
return getImgPlusFromN5File(dataSetChosen);
}

public ImagePlus getImgPlusFromN5File(String selectedDataset) throws IOException {
// AmazonS3KeyValueAccess amazonS3KeyValueAccess = new AmazonS3KeyValueAccess(s3Client, bucketName, false);
// N5KeyValueReader n5KeyValueReader = new N5KeyValueReader(amazonS3KeyValueAccess, s3ObjectKey, new GsonBuilder(), true);
N5AmazonS3Reader n5AmazonS3Reader = new N5AmazonS3Reader(s3Client, bucketName, "/" + s3ObjectKey);
return ImageJFunctions.wrap((CachedCellImg<DoubleType, ?>) N5Utils.open(n5AmazonS3Reader, selectedDataset), selectedDataset);
return ImageJFunctions.wrap((CachedCellImg<DoubleType, ?>) N5Utils.open(n5AmazonS3Reader, dataSetChosen), dataSetChosen);
}

public void setURI(URI uri){
this.uri = uri;
if(!(uri.getQuery() == null)){
dataSetChosen = uri.getQuery().split("=")[1]; // query should be "dataSetName=name", thus splitting it by = and getting the second entry gives the name
uriSafeDataSetChosen = uri.getQuery().split("=")[1]; // query should be "dataSetName=name", thus splitting it by = and getting the second entry gives the name
try {
dataSetChosen = URLDecoder.decode(dataSetChosen, "UTF-8");
dataSetChosen = URLDecoder.decode(uriSafeDataSetChosen, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
}

public void setDataSetChosen(String dataSetChosen){
public void setDataSetChosen(String dataSetChosen) throws UnsupportedEncodingException {
this.dataSetChosen = dataSetChosen;
uriSafeDataSetChosen = URLEncoder.encode(dataSetChosen, "UTF-8");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ public void actionPerformed(ActionEvent e) {
ArrayList<SimResultsLoader> filesToOpen = new ArrayList<>();
for(int row: exportListTable.getSelectedRows()){
String uri = n5ExportTableModel.getRowData(row).uri;
String datasetName = n5ExportTableModel.getRowData(row).savedFileName;
SimResultsLoader simResultsLoader = new SimResultsLoader(uri);
simResultsLoader.setDataSetChosen(datasetName);
filesToOpen.add(simResultsLoader);
}
openN5FileDataset(filesToOpen, openInMemory.isSelected());
Expand Down

0 comments on commit 7e8749e

Please sign in to comment.