diff --git a/src/main/java/org/vcell/vcellfiji/ExportDataRepresentation.java b/src/main/java/org/vcell/vcellfiji/ExportDataRepresentation.java new file mode 100644 index 0000000..1093970 --- /dev/null +++ b/src/main/java/org/vcell/vcellfiji/ExportDataRepresentation.java @@ -0,0 +1,57 @@ +package org.vcell.vcellfiji; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Stack; + +public class ExportDataRepresentation { + public ArrayList globalJobIDs; + public HashMap formatData; + + public ExportDataRepresentation(ArrayList globalJobIDs, HashMap formatData){ + this.globalJobIDs = globalJobIDs; + this.formatData = formatData; + } + + public static class FormatExportDataRepresentation { + public HashMap simulationDataMap; + public Stack formatJobIDs; + + public FormatExportDataRepresentation(HashMap simulationDataMap, Stack formatJobIDs){ + this.formatJobIDs = formatJobIDs; + this.simulationDataMap = simulationDataMap; + } + } + + public static class SimulationExportDataRepresentation { + public String exportDate; + public String uri; + public String jobID; + public String dataID; + public String simulationName; + public String applicationName; + public String biomodelName; + public String variables; + public String startAndEndTime; + + public ArrayList defaultParameterValues; + public ArrayList setParameterValues; + + public SimulationExportDataRepresentation(String exportDate, String uri, String jobID, String dataID, String simulationName, + String applicationName, String biomodelName, String variables, String startAndEndTime, + ArrayList defaultParameterValues, ArrayList setParameterValues){ + this.exportDate = exportDate; + this.uri = uri; + this.jobID = jobID; + this.dataID = dataID; + this.simulationName = simulationName; + this.applicationName = applicationName; + this.biomodelName = biomodelName; + this.variables = variables; + this.startAndEndTime = startAndEndTime; + this.defaultParameterValues = defaultParameterValues; + this.setParameterValues = setParameterValues; + } + } + +} diff --git a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java index 6bc9df1..1ba0f7d 100644 --- a/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java +++ b/src/main/java/org/vcell/vcellfiji/N5ImageHandler.java @@ -70,7 +70,6 @@ public void actionPerformed(ActionEvent e) { protected ArrayList doInBackground() throws Exception { vGui.setCursor(new Cursor(Cursor.WAIT_CURSOR)); ArrayList n5DataSetList = null; - if (e.getSource() == vGui.localFileDialog) { selectedLocalFile = vGui.localFileDialog.getSelectedFile(); n5DataSetList = getN5DatasetList(); @@ -79,19 +78,15 @@ protected ArrayList doInBackground() throws Exception { createS3Client(vGui.remoteFileSelection.getS3URL(), vGui.remoteFileSelection.returnCredentials(), vGui.remoteFileSelection.returnEndpoint()); n5DataSetList = getS3N5DatasetList(); } else if (e.getSource() == vGui.mostRecentExport) { - HashMap jsonData = getJsonData(); - if (jsonData != null) { - List set = (ArrayList) jsonData.get("jobIDs"); - LinkedTreeMap lastElement = null; - for (int i = set.size() - 1; i > -1; i--) { - lastElement = (LinkedTreeMap) jsonData.get(set.get(i)); - if (lastElement != null && lastElement.get("format").equalsIgnoreCase("n5")) { - break; - } - lastElement = null; - } + ExportDataRepresentation jsonData = getJsonData(); + if (jsonData != null && jsonData.formatData.containsKey("N5")) { + ExportDataRepresentation.FormatExportDataRepresentation formatExportDataRepresentation = jsonData.formatData.get("N5"); + Stack formatJobIDs = formatExportDataRepresentation.formatJobIDs; + String jobID = formatJobIDs.isEmpty() ? null : formatJobIDs.peek(); + + ExportDataRepresentation.SimulationExportDataRepresentation lastElement = jobID == null ? null : formatExportDataRepresentation.simulationDataMap.get(jobID); if (lastElement != null) { - String url = lastElement.get("uri"); + String url = lastElement.uri; createS3Client(url); n5DataSetList = getS3N5DatasetList(); } @@ -338,13 +333,12 @@ public static void main(String[] args) { n5ImageHandler.run(); } - public static HashMap getJsonData() throws FileNotFoundException { + public static ExportDataRepresentation getJsonData() throws FileNotFoundException { File jsonFile = new File(System.getProperty("user.home") + "/.vcell", "exportMetaData.json"); if (jsonFile.exists() && jsonFile.length() != 0){ - HashMap jsonHashMap; + ExportDataRepresentation jsonHashMap; Gson gson = new GsonBuilder().setPrettyPrinting().create(); - Type type = new TypeToken>() {}.getType(); - jsonHashMap = gson.fromJson(new FileReader(jsonFile.getAbsolutePath()), type); + jsonHashMap = gson.fromJson(new FileReader(jsonFile.getAbsolutePath()), ExportDataRepresentation.class); return jsonHashMap; } return null;