diff --git a/docker/build/Dockerfile-data-dev b/docker/build/Dockerfile-data-dev index 4722073c16..eac428b101 100644 --- a/docker/build/Dockerfile-data-dev +++ b/docker/build/Dockerfile-data-dev @@ -59,7 +59,8 @@ ENV softwareVersion=SOFTWARE-VERSION-NOT-SET \ simdatadir_external=/path/to/external/simdata/ \ simdataCacheSize="simdataCacheSize-not-set" \ webDataPort="webDataPort-not-set" \ - servertype="servertype-not-set" + servertype="servertype-not-set" \ + s3ProxyPortExternal="80" ENV dbpswdfile=/run/secrets/dbpswd \ jmspswdfile=/run/secrets/jmspswd \ @@ -89,6 +90,8 @@ ENTRYPOINT java \ -Dvcell.python.executable=/usr/local/bin/python \ -Dvcell.primarySimdatadir.internal=/simdata \ -Dvcell.secondarySimdatadir.internal=/simdata_secondary \ + -Dvcell.n5DataDir.internal=/n5DataDir \ + -Dvcell.s3proxy.port.external="${s3ProxyPortExternal}" \ -Dvcell.primarySimdatadir.external="${simdatadir_external}" \ -Dvcell.simdataCacheSize="${simdataCacheSize}" \ -Dvcell.export.baseDir.internal=/exportdir/ \ diff --git a/docker/swarm/docker-compose.yml b/docker/swarm/docker-compose.yml index 9fb34111e4..dc48e123e0 100644 --- a/docker/swarm/docker-compose.yml +++ b/docker/swarm/docker-compose.yml @@ -269,6 +269,7 @@ services: - mongodb_host_internal=mongodb - mongodb_port_internal=27017 - mongodb_database=test + - s3ProxyPortExternal=${VCELL_S3PROXY_PORT_EXTERNAL} - webDataPort=${VCELL_WEB_DATA_PORT} diff --git a/docker/swarm/localconfig_mockslurm-not-used.sh b/docker/swarm/localconfig_mockslurm-not-used.sh index ddfc72eb2b..07c1cf4842 100755 --- a/docker/swarm/localconfig_mockslurm-not-used.sh +++ b/docker/swarm/localconfig_mockslurm-not-used.sh @@ -100,6 +100,7 @@ VCELL_API_PORT_EXTERNAL=$((8080 + _site_port_offset)) VCELL_JMS_SIM_PORT_EXTERNAL=$((61616 + _site_port_offset)) VCELL_JMS_SIM_RESTPORT_EXTERNAL=$((8161 + _site_port_offset)) VCELL_MONGO_PORT_EXTERNAL=$((27017 + _site_port_offset)) +VCELL_S3PROXY_PORT_EXTERNAL=$((8086 + _site_port_offset)) VCELL_HTC_NODELIST= VCELL_BATCH_DOCKER_IMAGE="${VCELL_REPO_NAMESPACE}/vcell-batch:${VCELL_TAG}" VCELL_BATCH_SINGULARITY_FILENAME="${VCELL_BATCH_DOCKER_IMAGE//[\/:]/_}.img" @@ -159,6 +160,8 @@ VCELL_OPT_SINGULARITY_FILENAME=$VCELL_OPT_SINGULARITY_FILENAME VCELL_OPT_SINGULARITY_IMAGE_EXTERNAL=$VCELL_OPT_SINGULARITY_IMAGE_EXTERNAL VCELL_REPO_NAMESPACE=$VCELL_REPO_NAMESPACE VCELL_SECRETS_DIR=${HOME}/vcellkeys +VCELL_S3PROXY_PORT_EXTERNAL=$VCELL_S3PROXY_PORT_EXTERNAL +VCELL_N5_DATADIR_HOST=/share/apps/vcell3/n5 VCELL_SIMDATADIR_EXTERNAL=${VCELL_DEPLOY_ROOT_DIR}/users VCELL_SIMDATADIR_HOST=${VCELL_DEPLOY_ROOT_DIR}/users VCELL_SIMDATADIR_SECONDARY_HOST=/Volumes/vcell/users diff --git a/docker/swarm/localconfig_realslurm_oracle_zeke.sh b/docker/swarm/localconfig_realslurm_oracle_zeke.sh index 4658b590a2..3111457133 100755 --- a/docker/swarm/localconfig_realslurm_oracle_zeke.sh +++ b/docker/swarm/localconfig_realslurm_oracle_zeke.sh @@ -119,8 +119,8 @@ VCELL_OPT_SINGULARITY_IMAGE_EXTERNAL="/state/partition1/singularityImages/${VCEL VCELL_SMTP_HOSTNAME=vdsmtp.cam.uchc.edu VCELL_SMTP_PORT=25 VCELL_SMTP_EMAILADDRESS=VCell_Support@uchc.edu -VCELL_EXPORT_BASEURL=http://vcell.org/export/ -VCELL_EXPORTDIR_HOST=/Volumes/vcell/export/ +VCELL_EXPORT_BASEURL=http://localhost/ +VCELL_EXPORTDIR_HOST=/media/zeke/DiskDrive/Home/Work/CCAM/TempStorage/export VCELL_MAX_JOBS_PER_SCAN=100 VCELL_MAX_ODE_JOBS_PER_USER=100 VCELL_MAX_PDE_JOBS_PER_USER=40 @@ -136,65 +136,70 @@ VCELL_SSH_CMD_RESTORE_TIMEOUT=5 cat <"$_outputfile" VCELL_API_HOST_EXTERNAL=$VCELL_API_HOST_EXTERNAL VCELL_API_PORT_EXTERNAL=$VCELL_API_PORT_EXTERNAL + VCELL_BATCH_DOCKER_IMAGE=$VCELL_BATCH_DOCKER_IMAGE VCELL_BATCH_HOST=$VCELL_BATCH_HOST VCELL_BATCH_SINGULARITY_FILENAME=$VCELL_BATCH_SINGULARITY_FILENAME VCELL_BATCH_SINGULARITY_IMAGE_EXTERNAL=$VCELL_BATCH_SINGULARITY_IMAGE_EXTERNAL VCELL_BATCH_USER=vcell + VCELL_BIOFORMATS_JAR_FILE=vcell-bioformats-0.0.9-jar-with-dependencies.jar VCELL_BIOFORMATS_JAR_URL=http://vcell.org/webstart/vcell-bioformats-0.0.9-jar-with-dependencies.jar + VCELL_BUILD_NUMBER=$VCELL_BUILD_NUMBER VCELL_CLIENT_APPID=${_applicationId} + VCELL_DB_DRIVER=$VCELL_DB_DRIVER VCELL_DB_URL=$VCELL_DB_URL VCELL_DB_USER=$VCELL_DB_USER + VCELL_DEBUG_PORT_VCELL_API=$((VCELL_DEBUG_PORT_BASE+1)) VCELL_DEBUG_PORT_VCELL_DATA=$((VCELL_DEBUG_PORT_BASE+2)) VCELL_DEBUG_PORT_VCELL_DB=$((VCELL_DEBUG_PORT_BASE+3)) VCELL_DEBUG_PORT_VCELL_SCHED=$((VCELL_DEBUG_PORT_BASE+4)) VCELL_DEBUG_PORT_VCELL_SUBMIT=$((VCELL_DEBUG_PORT_BASE+5)) VCELL_DEBUG_PORT_VCELL_WEB=$((VCELL_DEBUG_PORT_BASE+6)) -VCELL_DEPLOY_SECRETS_DIR=${HOME}/vcellkeys_oracle + +VCELL_DEPLOY_SECRETS_DIR=/media/zeke/DiskDrive/Home/Work/CCAM/VCellDummyFiles VCELL_EXPORT_BASEURL=$VCELL_EXPORT_BASEURL VCELL_EXPORTDIR_HOST=$VCELL_EXPORTDIR_HOST VCELL_HTC_NODELIST=$VCELL_HTC_NODELIST VCELL_HTCLOGS_EXTERNAL=/share/apps/vcell3/dev_htclogs -VCELL_HTCLOGS_HOST=/Volumes/vcell/dev_htclogs -VCELL_INSTALLER_JRE_LINUX32=linux-x86-1.8.0_66 -VCELL_INSTALLER_JRE_LINUX64=linux-amd64-1.8.0_66 -VCELL_INSTALLER_JRE_MAC=macosx-amd64-1.8.0_141 -VCELL_INSTALLER_JRE_WIN32=windows-x86-1.8.0_141 -VCELL_INSTALLER_JRE_WIN64=windows-amd64-1.8.0_141 -VCELL_INSTALLER_JREDIR=${HOME}/.install4j6/jres +VCELL_HTCLOGS_HOST=/media/zeke/DiskDrive/Home/Work/CCAM/TempStorage/dev_htclogs + VCELL_JMS_SIM_HOST_EXTERNAL=$VCELL_JMS_SIM_HOST_EXTERNAL VCELL_JMS_SIM_PORT_EXTERNAL=$VCELL_JMS_SIM_PORT_EXTERNAL VCELL_JMS_SIM_RESTPORT_EXTERNAL=$VCELL_JMS_SIM_RESTPORT_EXTERNAL + VCELL_MAX_JOBS_PER_SCAN=$VCELL_MAX_JOBS_PER_SCAN VCELL_MAX_ODE_JOBS_PER_USER=$VCELL_MAX_ODE_JOBS_PER_USER VCELL_MAX_PDE_JOBS_PER_USER=$VCELL_MAX_PDE_JOBS_PER_USER + VCELL_MONGO_HOST_EXTERNAL=$VCELL_MONGO_HOST_EXTERNAL VCELL_MONGO_PORT_EXTERNAL=$VCELL_MONGO_PORT_EXTERNAL + VCELL_NATIVESOLVERDIR_EXTERNAL=/share/apps/vcell3/nativesolvers VCELL_OPT_DOCKER_IMAGE=$VCELL_OPT_DOCKER_IMAGE VCELL_OPT_SINGULARITY_FILENAME=$VCELL_OPT_SINGULARITY_FILENAME VCELL_OPT_SINGULARITY_IMAGE_EXTERNAL=$VCELL_OPT_SINGULARITY_IMAGE_EXTERNAL + VCELL_REPO_NAMESPACE=$VCELL_REPO_NAMESPACE -VCELL_SECRETS_DIR=${HOME}/vcellkeys_oracle -VCELL_N5_DATADIR_HOST=/share/apps/vcell3/n5 +VCELL_SECRETS_DIR=/media/zeke/DiskDrive/Home/Work/CCAM/VCellDummyFiles +VCELL_N5_DATADIR_HOST=/media/zeke/DiskDrive/Home/Work/CCAM/TempStorage/N5Dir VCELL_S3PROXY_PORT_EXTERNAL=$VCELL_S3PROXY_PORT_EXTERNAL + VCELL_SIMDATADIR_ARCHIVE_EXTERNAL=/share/apps/vcell12/users VCELL_SIMDATADIR_ARCHIVE_INTERNAL=/share/apps/vcell12/users -VCELL_SIMDATADIR_ARCHIVE_HOST=/Volumes/vcell-1/users -VCELL_SIMDATADIR_ARCHIVE_HOST_ORIG=/Volumes/vcell-2/users +VCELL_SIMDATADIR_ARCHIVE_HOST=/media/zeke/DiskDrive/Home/Work/CCAM/TempStorage/users VCELL_SIMDATADIR_EXTERNAL=/share/apps/vcell3/users -VCELL_SIMDATADIR_HOST=/Volumes/vcell/users +VCELL_SIMDATADIR_HOST=/media/zeke/DiskDrive/Home/Work/CCAM/TempStorage/users VCELL_SIMDATADIR_SECONDARY_EXTERNAL=/share/apps/vcell3/users -VCELL_SIMDATADIR_SECONDARY_HOST=/Volumes/vcell/users -VCELL_SIMDATADIR_SECONDARY_EXTERNAL_ORIG=/share/apps/vcell7/users -VCELL_SIMDATADIR_SECONDARY_HOST_ORIG=/Volumes/vcell-1/users +VCELL_SIMDATADIR_SECONDARY_HOST=~/Mnts/RemoteVolumes/VCell05/users VCELL_SIMDATADIR_PARALLEL_EXTERNAL=/share/apps/vcell3parallel + VCELL_SITE_CAMEL=${_site_camel} VCELL_SITE=$VCELL_SITE + VCELL_SLURM_CENTRAL_SINGULARITY_DIR=${VCELL_SLURM_CENTRAL_SINGULARITY_DIR} VCELL_SLURM_CMD_SACCT=$VCELL_SLURM_CMD_SACCT VCELL_SLURM_CMD_SBATCH=$VCELL_SLURM_CMD_SBATCH @@ -208,16 +213,21 @@ VCELL_SLURM_QOS=$VCELL_SLURM_QOS VCELL_SLURM_RESERVATION_PU=$VCELL_SLURM_RESERVATION_PU VCELL_SLURM_RESERVATION=$VCELL_SLURM_RESERVATION VCELL_SLURM_TMPDIR=$VCELL_SLURM_TMPDIR + VCELL_SMTP_EMAILADDRESS=${VCELL_SMTP_EMAILADDRESS} VCELL_SMTP_HOSTNAME=${VCELL_SMTP_HOSTNAME} VCELL_SMTP_PORT=${VCELL_SMTP_PORT} + VCELL_SSH_CMD_RESTORE_TIMEOUT=$VCELL_SSH_CMD_RESTORE_TIMEOUT VCELL_SSH_CMD_TIMEOUT=$VCELL_SSH_CMD_TIMEOUT + VCELL_SSL_IGNORE_CERT_PROBLEMS=true VCELL_SSL_IGNORE_HOST_MISMATCH=true + VCELL_SUBMIT_SERVICE_HOST=submit VCELL_TAG=$VCELL_TAG VCELL_UPDATE_SITE=http://vcell.org/webstart/${_site_camel} + VCELL_VERSION_NUMBER=$VCELL_VERSION_NUMBER VCELL_VERSION=${_site_camel}_Version_${VCELL_VERSION_NUMBER}_build_${VCELL_BUILD_NUMBER} VCELL_WEB_DATA_PORT=$VCELL_WEB_DATA_PORT diff --git a/vcell-api/src/main/java/org/vcell/rest/n5data/N5GetInfoRestlet.java b/vcell-api/src/main/java/org/vcell/rest/n5data/N5GetInfoRestlet.java index bbdb8e286c..2c7bd9ae3e 100644 --- a/vcell-api/src/main/java/org/vcell/rest/n5data/N5GetInfoRestlet.java +++ b/vcell-api/src/main/java/org/vcell/rest/n5data/N5GetInfoRestlet.java @@ -45,16 +45,17 @@ public void handle(Request req, Response response) { switch (desiredInfo){ case VCellApiApplication.N5_INFO_SUPPORTED_SPECIES: - User user = application.getVCellUser(req.getChallengeResponse(), VCellApiApplication.AuthenticationPolicy.ignoreInvalidCredentials); - N5Service n5Service = new N5Service(simID, user); - ArrayList listOfSupportedSpecies = n5Service.supportedSpecies(); - Gson gson = new Gson(); - response.setEntity(gson.toJson(listOfSupportedSpecies), MediaType.APPLICATION_JSON); +// User user = application.getVCellUser(req.getChallengeResponse(), VCellApiApplication.AuthenticationPolicy.ignoreInvalidCredentials); +// N5Service n5Service = new N5Service(simID, user); +// ArrayList listOfSupportedSpecies = n5Service.supportedSpecies(); +// Gson gson = new Gson(); +// response.setEntity(gson.toJson(listOfSupportedSpecies), MediaType.APPLICATION_JSON); return; default: - lg.info("No information type was specified in getting N5 info"); - response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST); - response.setEntity("failed to specify type of N5 information request for sim ID: " + simID, MediaType.TEXT_PLAIN); + return; +// lg.info("No information type was specified in getting N5 info"); +// response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST); +// response.setEntity("failed to specify type of N5 information request for sim ID: " + simID, MediaType.TEXT_PLAIN); } } catch (Exception e) { lg.error(e.getMessage(), e); diff --git a/vcell-api/src/main/java/org/vcell/rest/n5data/N5Service.java b/vcell-api/src/main/java/org/vcell/rest/n5data/N5Service.java index c1776da9e5..221e963a10 100644 --- a/vcell-api/src/main/java/org/vcell/rest/n5data/N5Service.java +++ b/vcell-api/src/main/java/org/vcell/rest/n5data/N5Service.java @@ -3,7 +3,6 @@ import cbit.vcell.math.MathException; import cbit.vcell.resource.PropertyLoader; import cbit.vcell.simdata.DataIdentifier; -import cbit.vcell.simdata.n5.N5Exporter; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.janelia.saalfeldlab.n5.Compression; @@ -38,21 +37,20 @@ public N5Service(String simID, User user) { public void exportToN5(String[] species, Compression compression) throws IOException, DataAccessException, MathException { - N5Exporter n5Exporter = new N5Exporter(); - n5Exporter.initalizeDataControllers(simID, user.getName(), user.getID().toString()); - ArrayList dataIdentifiers = new ArrayList<>(); - for(String specie: species){ - dataIdentifiers.add(n5Exporter.getSpecificDI(specie)); - } - n5Exporter.exportToN5(dataIdentifiers, compression); +// N5Exporter n5Exporter = new N5Exporter(); +// n5Exporter.initalizeDataControllers(simID, user.getName(), user.getID().toString()); +// ArrayList dataIdentifiers = new ArrayList<>(); +// for(String specie: species){ +// dataIdentifiers.add(n5Exporter.getSpecificDI(specie)); +// } +// n5Exporter.exportToN5(dataIdentifiers, compression); + return; } - public ArrayList supportedSpecies() throws IOException, DataAccessException { - N5Exporter n5Exporter = new N5Exporter(); - n5Exporter.initalizeDataControllers(simID, user.getName(), user.getID().toString()); - return n5Exporter.getSupportedSpecies(); - } +// public ArrayList supportedSpecies() throws IOException, DataAccessException { +// +// } diff --git a/vcell-client/src/main/java/cbit/vcell/client/ClientRequestManager.java b/vcell-client/src/main/java/cbit/vcell/client/ClientRequestManager.java index 1b939a25c3..e30824678a 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/ClientRequestManager.java +++ b/vcell-client/src/main/java/cbit/vcell/client/ClientRequestManager.java @@ -68,6 +68,7 @@ import javax.swing.Timer; import javax.swing.filechooser.FileFilter; +import cbit.vcell.export.server.N5Specs; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpStatus; @@ -2540,6 +2541,9 @@ public static void downloadExportedData(final Component requester, final UserPre if (exportsRecord.contains(evt.getJobID() + "")) { return; } + if (evt.getLocation().toLowerCase().endsWith("." + N5Specs.n5Suffix)){ + return; + } AsynchClientTask task1 = new AsynchClientTask("Retrieving data from '" + evt.getLocation() + "'", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) { diff --git a/vcell-client/src/main/java/cbit/vcell/client/data/ExportSettings.java b/vcell-client/src/main/java/cbit/vcell/client/data/ExportSettings.java index 00ae994d10..f8cb2fad20 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/data/ExportSettings.java +++ b/vcell-client/src/main/java/cbit/vcell/client/data/ExportSettings.java @@ -16,15 +16,11 @@ import javax.swing.JDialog; import javax.swing.JPanel; +import cbit.vcell.export.gui.*; import org.vcell.client.logicalwindow.transition.LWJDialogDecorator; import org.vcell.util.gui.GeneralGuiUtils; import org.vcell.util.VCAssert; -import cbit.vcell.export.gui.ASCIISettingsPanel; -import cbit.vcell.export.gui.ASCIISettingsPanelListener; -import cbit.vcell.export.gui.MediaSettingsPanel; -import cbit.vcell.export.gui.RasterSettingsPanel; -import cbit.vcell.export.gui.RasterSettingsPanelListener; import cbit.vcell.export.server.ExportConstants; import cbit.vcell.export.server.ExportFormat; import cbit.vcell.export.server.ExportSpecs; @@ -49,6 +45,9 @@ public class ExportSettings implements ASCIISettingsPanelListener, RasterSetting private JDialog ivjJDialogRasterSettings = null; private RasterSettingsPanel ivjRasterSettingsPanel1 = null; + private JDialog ivjJDialogN5Settings = null; + private N5SettingsPanel ivjJDialogN5Panel = null; + /** * ExportSettings constructor comment. */ @@ -82,124 +81,7 @@ private void closeOK(JDialog dialog) { dialog.dispose(); } -/** - * connEtoC10: (ASCIISettingsPanel1.ASCIISettingsPanel.JButtonCancelAction_actionPerformed(java.util.EventObject) --> ExportSettings.closeCancel(Ljavax.swing.JDialog;)V) - * @param arg1 java.util.EventObject - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC10(java.util.EventObject arg1) { - try { - // user code begin {1} - // user code end - this.closeCancel(ivjJDialogASCIISettings); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC11: (RasterSettingsPanel1.rasterSettingsPanel.JButtonCancelAction_actionPerformed(java.util.EventObject) --> ExportSettings.closeCancel(Ljavax.swing.JDialog;)V) - * @param arg1 java.util.EventObject - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC11(java.util.EventObject arg1) { - try { - // user code begin {1} - // user code end - this.closeCancel(ivjJDialogRasterSettings); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** - * connEtoC6: ( (ASCIISettingsPanel1,ASCIISettingsPanel.JButtonOKAction_actionPerformed(java.util.EventObject) --> ExportSettings,formatSpecificSpecs).normalResult --> ExportSettings.closeOK(Ljavax.swing.JDialog;)V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC6() { - try { - // user code begin {1} - // user code end - this.closeOK(ivjJDialogASCIISettings); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC7: ( (RasterSettingsPanel1,rasterSettingsPanel.JButtonOKAction_actionPerformed(java.util.EventObject) --> ExportSettings,formatSpecificSpecs).normalResult --> ExportSettings.closeOK(Ljavax.swing.JDialog;)V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC7() { - try { - // user code begin {1} - // user code end - this.closeOK(ivjJDialogRasterSettings); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** - * connEtoM1: (RasterSettingsPanel1.rasterSettingsPanel.JButtonOKAction_actionPerformed(java.util.EventObject) --> ExportSettings.formatSpecificSpecs) - * @param arg1 java.util.EventObject - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM1(java.util.EventObject arg1) { - try { - // user code begin {1} - // user code end - this.setFormatSpecificSpecs(getRasterSettingsPanel1().getRasterSpecs()); - connEtoC7(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoM4: (ASCIISettingsPanel1.ASCIISettingsPanel.JButtonOKAction_actionPerformed(java.util.EventObject) --> ExportSettings.formatSpecificSpecs) - * @param arg1 java.util.EventObject - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM4(java.util.EventObject arg1) { - try { - // user code begin {1} - // user code end - this.setFormatSpecificSpecs(getASCIISettingsPanel1().getAsciiSpecs()); - connEtoC6(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** + /** * connPtoP7SetTarget: (ExportSettings.simDataType <--> ASCIISettingsPanel1.simDataType) */ /* WARNING: THIS METHOD WILL BE REGENERATED. */ @@ -245,6 +127,22 @@ private ASCIISettingsPanel getASCIISettingsPanel1() { return ivjASCIISettingsPanel1; } +private N5SettingsPanel getN5SettingsPanel(){ + if (ivjJDialogN5Panel == null){ + try { + ivjJDialogN5Panel = new cbit.vcell.export.gui.N5SettingsPanel(); + ivjJDialogN5Panel.setName("N5SettingsPnael"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJDialogN5Panel; +} + /** * Gets the formatSpecificSpecs property (cbit.vcell.export.server.FormatSpecificSpecs) value. * @return The formatSpecificSpecs property value. @@ -281,6 +179,32 @@ private javax.swing.JDialog getJDialogASCIISettings(Frame reference) { return ivjJDialogASCIISettings; } +/** + * Return the JDialog1 property value. + * @return javax.swing.JDialog + */ +/* WARNING: THIS METHOD WILL BE REGENERATED. */ +private javax.swing.JDialog getJDialogN5Settings(Frame reference){ + if (ivjJDialogN5Settings == null){ + try { + ivjJDialogN5Settings = new javax.swing.JDialog(reference); + ivjJDialogN5Settings.setName("JDialogN5Settings"); + ivjJDialogN5Settings.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + ivjJDialogN5Settings.setBounds(123, 502, 176, 183); + ivjJDialogN5Settings.setModal(true); + ivjJDialogN5Settings.setTitle("N5 Settings"); + ivjJDialogN5Settings.add(getN5SettingsPanel()); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJDialogN5Settings; +} + /** * Return the JDialogContentPane property value. * @return javax.swing.JPanel @@ -487,6 +411,8 @@ public void actionPerformed(ActionEvent e) { } }); getRasterSettingsPanel1().addRasterSettingsPanelListener(this); + getN5SettingsPanel().addN5SettingsPanelListener(this); + connPtoP7SetTarget(); } @@ -521,14 +447,19 @@ private boolean isClosedOK() { * @param newEvent java.util.EventObject */ public void JButtonCancelAction_actionPerformed(java.util.EventObject newEvent) { - // user code begin {1} - // user code end - if (newEvent.getSource() == getASCIISettingsPanel1()) - connEtoC10(newEvent); - if (newEvent.getSource() == getRasterSettingsPanel1()) - connEtoC11(newEvent); - // user code begin {2} - // user code end + try{ + if (newEvent.getSource() == getASCIISettingsPanel1()) + this.closeCancel(ivjJDialogASCIISettings); + + if (newEvent.getSource() == getRasterSettingsPanel1()) + this.closeCancel(ivjJDialogRasterSettings); + + if (newEvent.getSource() == getN5SettingsPanel()) + this.closeCancel(ivjJDialogN5Settings); + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } } /** @@ -537,14 +468,26 @@ public void JButtonCancelAction_actionPerformed(java.util.EventObject newEvent) */ /* WARNING: THIS METHOD WILL BE REGENERATED. */ public void JButtonOKAction_actionPerformed(java.util.EventObject newEvent) { - // user code begin {1} - // user code end - if (newEvent.getSource() == getASCIISettingsPanel1()) - connEtoM4(newEvent); - if (newEvent.getSource() == getRasterSettingsPanel1()) - connEtoM1(newEvent); - // user code begin {2} - // user code end + try{ + if (newEvent.getSource() == getASCIISettingsPanel1()){ + this.setFormatSpecificSpecs(getASCIISettingsPanel1().getAsciiSpecs()); + this.closeOK(ivjJDialogASCIISettings); + } + + if (newEvent.getSource() == getRasterSettingsPanel1()) + { + this.setFormatSpecificSpecs(getRasterSettingsPanel1().getRasterSpecs()); + this.closeOK(ivjJDialogRasterSettings); + } + + if (newEvent.getSource() == getN5SettingsPanel()){ + this.setFormatSpecificSpecs(getN5SettingsPanel().getN5Specs()); + this.closeOK(ivjJDialogN5Settings); + } + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } } /** @@ -659,6 +602,7 @@ public void setIsCSVExport(boolean isCSVExport){ } /** * Comment + * Pop up dialog for data exported, specific to that format */ @SuppressWarnings("incomplete-switch") public boolean showFormatSpecificDialog(Frame reference,boolean selectionHasVolumeVars,boolean selectionHasMembraneVars) { @@ -691,6 +635,9 @@ public boolean showFormatSpecificDialog(Frame reference,boolean selectionHasVolu case NRRD: dialogToShow = getJDialogRasterSettings(reference); break; + case N5: + dialogToShow = getJDialogN5Settings(reference); + break; } dialogToShow.pack(); GeneralGuiUtils.centerOnComponent(dialogToShow, reference); diff --git a/vcell-client/src/main/java/cbit/vcell/client/data/PDEExportDataPanel.java b/vcell-client/src/main/java/cbit/vcell/client/data/PDEExportDataPanel.java index 225a6c5fe3..d7b94821eb 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/data/PDEExportDataPanel.java +++ b/vcell-client/src/main/java/cbit/vcell/client/data/PDEExportDataPanel.java @@ -175,28 +175,37 @@ public class PDEExportDataPanel extends JPanel implements ExportConstants { class IvjEventHandler implements java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.beans.PropertyChangeListener, javax.swing.event.ChangeListener, javax.swing.event.ListDataListener, javax.swing.event.ListSelectionListener { public void actionPerformed(java.awt.event.ActionEvent e) { - if (e.getSource() == PDEExportDataPanel.this.getJTextField1()) - connEtoC5(e); - if (e.getSource() == PDEExportDataPanel.this.getJTextField2()) - connEtoC6(e); - if (e.getSource() == PDEExportDataPanel.this.getJButtonExport()) - connEtoM1(e); - if (e.getSource() == PDEExportDataPanel.this.getJButtonExport()) - connEtoC9(e); -// if (e.getSource() == NewPDEExportPanel.this.getJButtonAdd()) + try{ + if (e.getSource() == PDEExportDataPanel.this.getJTextField1()) + PDEExportDataPanel.this.setTimeFromTextField(getJTextField1(), getJSlider1()); + + if (e.getSource() == PDEExportDataPanel.this.getJTextField2()) + PDEExportDataPanel.this.setTimeFromTextField(getJTextField2(), getJSlider2()); + + if (e.getSource() == PDEExportDataPanel.this.getJButtonExport()) + getExportSettings1().setSimDataType(PDEExportDataPanel.this.dataType()); + + if (e.getSource() == PDEExportDataPanel.this.getJButtonExport()) + PDEExportDataPanel.this.startExport(); +// if (e.getSource() == NewPDEExportPanel.this.getJButtonAdd()) // connEtoM4(e); -// if (e.getSource() == NewPDEExportPanel.this.getJButtonRemove()) +// if (e.getSource() == NewPDEExportPanel.this.getJButtonRemove()) // connEtoM5(e); - if (e.getSource() == PDEExportDataPanel.this.getVolVarRadioButton()){ - vol_memb_both_change(); - } - if (e.getSource() == PDEExportDataPanel.this.getMembVarRadioButton()){ - vol_memb_both_change(); + if (e.getSource() == PDEExportDataPanel.this.getVolVarRadioButton()){ + vol_memb_both_change(); + } + if (e.getSource() == PDEExportDataPanel.this.getMembVarRadioButton()){ + vol_memb_both_change(); + } + if (e.getSource() == PDEExportDataPanel.this.getBothVarRadioButton()){ + vol_memb_both_change(); + } } - if (e.getSource() == PDEExportDataPanel.this.getBothVarRadioButton()){ - vol_memb_both_change(); + catch (Throwable ivjExc){ + handleException(ivjExc); } + }; public void contentsChanged(javax.swing.event.ListDataEvent e) { if (e.getSource() == PDEExportDataPanel.this.getDefaultListModelCivilizedSelections()) @@ -204,10 +213,16 @@ public void contentsChanged(javax.swing.event.ListDataEvent e) { }; public void focusGained(java.awt.event.FocusEvent e) {}; public void focusLost(java.awt.event.FocusEvent e) { - if (e.getSource() == PDEExportDataPanel.this.getJTextField1()) - connEtoC7(e); - if (e.getSource() == PDEExportDataPanel.this.getJTextField2()) - connEtoC8(e); + try{ + if (e.getSource() == PDEExportDataPanel.this.getJTextField1()) + PDEExportDataPanel.this.setTimeFromTextField(getJTextField1(), getJSlider1()); + + if (e.getSource() == PDEExportDataPanel.this.getJTextField2()) + PDEExportDataPanel.this.setTimeFromTextField(getJTextField2(), getJSlider2()); + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } }; public void intervalAdded(javax.swing.event.ListDataEvent e) { if (e.getSource() == PDEExportDataPanel.this.getDefaultListModelCivilizedSelections()) @@ -219,7 +234,11 @@ public void intervalRemoved(javax.swing.event.ListDataEvent e) { }; public void itemStateChanged(java.awt.event.ItemEvent e) { if (e.getSource() == PDEExportDataPanel.this.getFormatComboBox()){ - connEtoM6(e); + try { + getExportSettings1().setSelectedFormat(getSelectedFormat()); + } catch (Throwable ivjExc) { + handleException(ivjExc); + } updateChoiceVariableType(getPdeDataContext()); updateChoiceROI(); updateInterface(); @@ -228,34 +247,61 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { public void propertyChange(java.beans.PropertyChangeEvent evt) { // if (evt.getSource() == NewPDEExportPanel.this && (evt.getPropertyName().equals(PROP_SELECTEDREGION))) // connEtoC10(evt); - if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals("slice"))) - connEtoC11(evt); - if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals("normalAxis"))) - connEtoC12(evt); - if (evt.getSource() == PDEExportDataPanel.this.getExportSettings1() && (evt.getPropertyName().equals("selectedFormat"))) - connEtoC13(evt); - if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals(PDEDataContext.PROP_PDE_DATA_CONTEXT))) - connPtoP3SetTarget(); - if (evt.getSource() == PDEExportDataPanel.this.getpdeDataContext1() && (evt.getPropertyName().equals("timePoints"))) - connEtoC14(evt); - if (evt.getSource() == PDEExportDataPanel.this.getButtonGroupCivilized1() && (evt.getPropertyName().equals("selection"))) - connEtoC16(evt); - if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals(PROP_SELECTEDREGION))) - connEtoC18(evt); - if (evt.getSource() == PDEExportDataPanel.this.getpdeDataContext1() && (evt.getPropertyName().equals(SimDataConstants.PROPERTY_NAME_DATAIDENTIFIERS))) - connEtoC20(evt); + try{ + if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals("slice"))) + PDEExportDataPanel.this.updateSlice(PDEExportDataPanel.this.getSlice(), PDEExportDataPanel.this.getNormalAxis()); + + if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals("normalAxis"))) + PDEExportDataPanel.this.updateSlice(PDEExportDataPanel.this.getSlice(), PDEExportDataPanel.this.getNormalAxis()); + + if (evt.getSource() == PDEExportDataPanel.this.getExportSettings1() && (evt.getPropertyName().equals("selectedFormat"))) + PDEExportDataPanel.this.updateExportFormat(getExportSettings1().getSelectedFormat()); + + if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals(PDEDataContext.PROP_PDE_DATA_CONTEXT))) + connPtoP3SetTarget(); + + if (evt.getSource() == PDEExportDataPanel.this.getpdeDataContext1() && (evt.getPropertyName().equals("timePoints"))) + PDEExportDataPanel.this.updateTimes(getpdeDataContext1().getTimePoints()); + + if (evt.getSource() == PDEExportDataPanel.this.getButtonGroupCivilized1() && (evt.getPropertyName().equals("selection"))) + PDEExportDataPanel.this.updateInterface(); + + if (evt.getSource() == PDEExportDataPanel.this && (evt.getPropertyName().equals(PROP_SELECTEDREGION))) + PDEExportDataPanel.this.updateInterface(); + + if (evt.getSource() == PDEExportDataPanel.this.getpdeDataContext1() && (evt.getPropertyName().equals(SimDataConstants.PROPERTY_NAME_DATAIDENTIFIERS))) + if ((getpdeDataContext1() != null)) { + PDEExportDataPanel.this.updateAllChoices(getpdeDataContext1()); + } + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } + }; public void stateChanged(javax.swing.event.ChangeEvent e) { - if (e.getSource() == PDEExportDataPanel.this.getJSlider1()) - connEtoC3(e); - if (e.getSource() == PDEExportDataPanel.this.getJSlider2()) - connEtoC4(e); + try { + if (e.getSource() == PDEExportDataPanel.this.getJSlider1()) + PDEExportDataPanel.this.setTimeFromSlider(getJSlider1(), getJTextField1()); + if (e.getSource() == PDEExportDataPanel.this.getJSlider2()) + PDEExportDataPanel.this.setTimeFromSlider(getJSlider2(), getJTextField2()); + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } }; + + public void valueChanged(javax.swing.event.ListSelectionEvent e) { - if (e.getSource() == PDEExportDataPanel.this.getJListVariables()) - connEtoC15(e); - if (e.getSource() == PDEExportDataPanel.this.getROISelections()) - connEtoC19(e); + try{ + if (e.getSource() == PDEExportDataPanel.this.getJListVariables()) + PDEExportDataPanel.this.updateInterface(); + if (e.getSource() == PDEExportDataPanel.this.getROISelections()) + PDEExportDataPanel.this.updateInterface(); + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } }; }; @@ -282,26 +328,6 @@ public synchronized void addPropertyChangeListener(java.beans.PropertyChangeList getPropertyChange().addPropertyChangeListener(listener); } - -/** - * connEtoC1: (pdeDataContext1.this --> PDEExportPanel.updateChoices(Lcbit.vcell.simdata.PDEDataContext;)V) - * @param value cbit.vcell.simdata.PDEDataContext - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC1(PDEDataContext value) { - try { - // user code begin {1} - // user code end - this.updateAllChoices(getpdeDataContext1()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - ///** // * connEtoC10: (NewPDEExportPanel.selectedRegion --> NewPDEExportPanel.updateCurrentSelection(Lcbit.vcell.simdata.gui.SpatialSelection;)V) // * @param arg1 java.beans.PropertyChangeEvent @@ -322,127 +348,7 @@ private void connEtoC1(PDEDataContext value) { //} -/** - * connEtoC11: (NewPDEExportPanel.slice --> NewPDEExportPanel.updateSlice(II)V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC11(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateSlice(this.getSlice(), this.getNormalAxis()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC12: (NewPDEExportPanel.normalAxis --> NewPDEExportPanel.updateSlice(II)V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC12(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateSlice(this.getSlice(), this.getNormalAxis()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC13: (ExportSettings1.selectedFormat --> PDEExportPanel.updateExportFormat(I)V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC13(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateExportFormat(getExportSettings1().getSelectedFormat()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC14: (pdeDataContext1.timePoints --> NewPDEExportPanel.updateTimes([D)V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC14(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateTimes(getpdeDataContext1().getTimePoints()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC15: (JListVariables.listSelection.valueChanged(javax.swing.event.ListSelectionEvent) --> PDEExportPanel.updateInterface()V) - * @param arg1 javax.swing.event.ListSelectionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC15(javax.swing.event.ListSelectionEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateInterface(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC16: (ButtonGroupCivilized1.selection --> PDEExportPanel.updateInterface()V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC16(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateInterface(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** + /** * connEtoC17: (DefaultListModelCivilizedSelections.listData. --> PDEExportPanel.updateInterface()V) */ /* WARNING: THIS METHOD WILL BE REGENERATED. */ @@ -460,285 +366,7 @@ private void connEtoC17() { } } - -/** - * connEtoC18: (NewPDEExportPanel.selectedRegion --> NewPDEExportPanel.updateInterface()V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC18(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateInterface(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC19: (JListSelections.listSelection.valueChanged(javax.swing.event.ListSelectionEvent) --> PDEExportPanel.updateInterface()V) - * @param arg1 javax.swing.event.ListSelectionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC19(javax.swing.event.ListSelectionEvent arg1) { - try { - // user code begin {1} - // user code end - this.updateInterface(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC2: (ODEExportPanel.initialize() --> ODEExportPanel.initFormatChoices()V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC2() { - try { - // user code begin {1} - // user code end - this.setFormatChoices_0(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC20: (pdeDataContext1.dataIdentifiers --> NewPDEExportPanel.updateAllChoices(Lcbit.vcell.simdata.PDEDataContext;)V) - * @param arg1 java.beans.PropertyChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC20(java.beans.PropertyChangeEvent arg1) { - try { - // user code begin {1} - // user code end - if ((getpdeDataContext1() != null)) { - this.updateAllChoices(getpdeDataContext1()); - } - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC3: (JSlider1.change.stateChanged(javax.swing.event.ChangeEvent) --> PDEExportPanel.setTimeFromSlider(ILjavax.swing.JTextField;)V) - * @param arg1 javax.swing.event.ChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC3(javax.swing.event.ChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromSlider(getJSlider1(), getJTextField1()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC4: (JSlider2.change.stateChanged(javax.swing.event.ChangeEvent) --> PDEExportPanel.setTimeFromSlider(ILjavax.swing.JTextField;)V) - * @param arg1 javax.swing.event.ChangeEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC4(javax.swing.event.ChangeEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromSlider(getJSlider2(), getJTextField2()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC5: (JTextField1.action.actionPerformed(java.awt.event.ActionEvent) --> ODEExportPanel.setTimeFromTextField(Ljavax.swing.JTextField;Ljavax.swing.JSlider;)V) - * @param arg1 java.awt.event.ActionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC5(java.awt.event.ActionEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromTextField(getJTextField1(), getJSlider1()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC6: (JTextField2.action.actionPerformed(java.awt.event.ActionEvent) --> ODEExportPanel.setTimeFromTextField(Ljavax.swing.JTextField;Ljavax.swing.JSlider;)V) - * @param arg1 java.awt.event.ActionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC6(java.awt.event.ActionEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromTextField(getJTextField2(), getJSlider2()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC7: (JTextField1.focus.focusLost(java.awt.event.FocusEvent) --> ODEExportPanel.setTimeFromTextField(Ljavax.swing.JTextField;Ljavax.swing.JSlider;)V) - * @param arg1 java.awt.event.FocusEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC7(java.awt.event.FocusEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromTextField(getJTextField1(), getJSlider1()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC8: (JTextField2.focus.focusLost(java.awt.event.FocusEvent) --> ODEExportPanel.setTimeFromTextField(Ljavax.swing.JTextField;Ljavax.swing.JSlider;)V) - * @param arg1 java.awt.event.FocusEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC8(java.awt.event.FocusEvent arg1) { - try { - // user code begin {1} - // user code end - this.setTimeFromTextField(getJTextField2(), getJSlider2()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoC9: (JButtonExport.action.actionPerformed(java.awt.event.ActionEvent) --> ODEExportPanel.startExport()V) - * @param arg1 java.awt.event.ActionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoC9(java.awt.event.ActionEvent arg1) { - try { - // user code begin {1} - // user code end - this.startExport(); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoM1: (JButtonExport.action.actionPerformed(java.awt.event.ActionEvent) --> ExportSettings1.simDataType) - * @param arg1 java.awt.event.ActionEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM1(java.awt.event.ActionEvent arg1) { - try { - // user code begin {1} - // user code end - getExportSettings1().setSimDataType(this.dataType()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** - * connEtoM2: (PDEExportPanel.initialize() --> ButtonGroupCivilized1.add(Ljavax.swing.AbstractButton;)V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM2() { - try { - // user code begin {1} - // user code end - getButtonGroupCivilized1().add(getJRadioButtonSlice()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** - * connEtoM3: (PDEExportPanel.initialize() --> ButtonGroupCivilized1.add(Ljavax.swing.AbstractButton;)V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM3() { - try { - // user code begin {1} - // user code end - getButtonGroupCivilized1().add(getJRadioButtonROI()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** + /** * connEtoM4: (JButtonAdd.action.actionPerformed(java.awt.event.ActionEvent) --> DefaultListModelCivilizedSelections.addNewElement(Ljava.lang.Object;)V) */ /* WARNING: THIS METHOD WILL BE REGENERATED. */ @@ -796,26 +424,7 @@ private void updateChoiceROI() { // } //} -/** - * connEtoM6: (JComboBox1.item.itemStateChanged(java.awt.event.ItemEvent) --> ExportSettings1.selectedFormat) - * @param arg1 java.awt.event.ItemEvent - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM6(java.awt.event.ItemEvent arg1) { - try { - // user code begin {1} - // user code end - getExportSettings1().setSelectedFormat(getSelectedFormat()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - -/** + /** * @return format selected in combobox */ private ExportFormat getSelectedFormat( ) { @@ -825,27 +434,7 @@ private ExportFormat getSelectedFormat( ) { } - -/** - * connEtoM7: (PDEExportPanel.initialize() --> ButtonGroupCivilized1.add(Ljavax.swing.AbstractButton;)V) - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void connEtoM7() { - try { - // user code begin {1} - // user code end - getButtonGroupCivilized1().add(getJRadioButtonFull()); - // user code begin {2} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {3} - // user code end - handleException(ivjExc); - } -} - - -/** + /** * connPtoP1SetTarget: (DefaultListModel1.this <--> JList1.model) */ /* WARNING: THIS METHOD WILL BE REGENERATED. */ @@ -919,8 +508,34 @@ private void connPtoP3SetTarget() { // user code begin {1} // user code end ivjConnPtoP3Aligning = true; - setpdeDataContext1(this.getPdeDataContext()); - // user code begin {2} + PDEDataContext newValue = this.getPdeDataContext(); + if (ivjpdeDataContext1 != newValue) { + try { + PDEDataContext oldValue = getpdeDataContext1(); + /* Stop listening for events from the current object */ + if (ivjpdeDataContext1 != null) { + ivjpdeDataContext1.removePropertyChangeListener(ivjEventHandler); + } + ivjpdeDataContext1 = newValue; + + /* Listen for events from the new object */ + if (ivjpdeDataContext1 != null) { + ivjpdeDataContext1.addPropertyChangeListener(ivjEventHandler); + } + connPtoP3SetSource(); + try { + this.updateAllChoices(getpdeDataContext1()); + } catch (Throwable ivjExc) { + handleException(ivjExc); + } + firePropertyChange(PDEDataContext.PROP_PDE_DATA_CONTEXT, oldValue, newValue); + } catch (Throwable ivjExc) { + handleException(ivjExc); + } + }; + // user code begin {3} + // user code end +// user code begin {2} // user code end ivjConnPtoP3Aligning = false; } @@ -2116,6 +1731,7 @@ private void setFormatChoices_0(/*boolean bMembrane*/){ cb.addItem(ExportFormat.ANIMATED_GIF); cb.addItem(ExportFormat.FORMAT_JPEG); cb.addItem(ExportFormat.NRRD); + cb.addItem(ExportFormat.N5); // cb.addItem(ExportFormat.IMAGEJ); cb.addItem(ExportFormat.UCD); cb.addItem(ExportFormat.PLY); @@ -2186,10 +1802,14 @@ private void initialize() { constraintsJPanelRegion.insets = new java.awt.Insets(4, 4, 4, 4); add(getJPanelRegion(), constraintsJPanelRegion); initConnections(); - connEtoC2(); - connEtoM2(); - connEtoM7(); - connEtoM3(); + try { + this.setFormatChoices_0(); + getButtonGroupCivilized1().add(getJRadioButtonSlice()); + getButtonGroupCivilized1().add(getJRadioButtonFull()); + getButtonGroupCivilized1().add(getJRadioButtonROI()); + } catch (Throwable ivjExc) { + handleException(ivjExc); + } getExportSettings1().setSelectedFormat(getSelectedFormat()); } catch (java.lang.Throwable ivjExc) { handleException(ivjExc); @@ -2286,39 +1906,7 @@ public void setPdeDataContext(PDEDataContext pdeDataContext,ExportSpecs.SimNameS } -/** - * Set the pdeDataContext1 to a new value. - * @param newValue cbit.vcell.simdata.PDEDataContext - */ -/* WARNING: THIS METHOD WILL BE REGENERATED. */ -private void setpdeDataContext1(PDEDataContext newValue) { - if (ivjpdeDataContext1 != newValue) { - try { - PDEDataContext oldValue = getpdeDataContext1(); - /* Stop listening for events from the current object */ - if (ivjpdeDataContext1 != null) { - ivjpdeDataContext1.removePropertyChangeListener(ivjEventHandler); - } - ivjpdeDataContext1 = newValue; - - /* Listen for events from the new object */ - if (ivjpdeDataContext1 != null) { - ivjpdeDataContext1.addPropertyChangeListener(ivjEventHandler); - } - connPtoP3SetSource(); - connEtoC1(ivjpdeDataContext1); - firePropertyChange(PDEDataContext.PROP_PDE_DATA_CONTEXT, oldValue, newValue); - // user code begin {1} - // user code end - } catch (java.lang.Throwable ivjExc) { - // user code begin {2} - // user code end - handleException(ivjExc); - } - }; - // user code begin {3} - // user code end -} + /* WARNING: THIS METHOD WILL BE REGENERATED. */ ///** // * Sets the selectedRegion property (cbit.vcell.simdata.gui.SpatialSelection) value. @@ -2828,6 +2416,18 @@ private void updateInterface() { case VTK_UNSTRUCT: //no operation? break; + case N5: + getJRadioButtonROI().setEnabled(false); + getJRadioButtonSlice().setEnabled(false); + getMembVarRadioButton().setEnabled(false); + getBothVarRadioButton().setEnabled(false); + + // Time Section +// getJPanelTime().setEnabled(false); +// getJSlider1().setEnabled(false); +// getJSlider2().setEnabled(false); +// getJTextField1().setEnabled(false); +// getJTextField2().setEnabled(false); default: break; } diff --git a/vcell-client/src/main/java/cbit/vcell/export/gui/N5SettingsPanel.java b/vcell-client/src/main/java/cbit/vcell/export/gui/N5SettingsPanel.java new file mode 100644 index 0000000000..8962fac43b --- /dev/null +++ b/vcell-client/src/main/java/cbit/vcell/export/gui/N5SettingsPanel.java @@ -0,0 +1,529 @@ +package cbit.vcell.export.gui; + +import cbit.vcell.export.server.*; + +import javax.swing.*; +import java.awt.*; + +public class N5SettingsPanel extends javax.swing.JPanel implements ExportConstants, java.awt.event.ActionListener, java.awt.event.ItemListener, java.beans.PropertyChangeListener, javax.swing.event.ChangeListener { + private javax.swing.JButton ivjJButtonOK = null; + private javax.swing.JLabel ivjJLabelDataType = null; + private javax.swing.JRadioButton ivjJRadioButtonParticles = null; + private javax.swing.JRadioButton ivjJRadioButtonVariables = null; + protected transient cbit.vcell.export.gui.ASCIISettingsPanelListener fieldASCIISettingsPanelListenerEventMulticaster = null; + private javax.swing.JCheckBox ivjJCheckBoxSwitch = null; + private javax.swing.JLabel ivjJLabelAdditional = null; + private ExportConstants.DataType fieldExportDataType; + private javax.swing.JButton ivjCancelJButton = null; + private javax.swing.JPanel mainPanel = null; + private ExportSpecs.SimulationSelector simulationSelector; + + private JRadioButton ivjRadioButtonBZIP = null; + private JRadioButton ivjRadioButtonGZIP = null; + private JRadioButton radioButtonRAW = null; + private N5Specs.CompressionLevel compressionLevel = N5Specs.CompressionLevel.RAW; + private JLabel dataSetNameLabel = null; + private JTextField dataSetName = null; + /** + * Constructor + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + public N5SettingsPanel() { + super(); + initialize(); + } + /** + * MovieSettingsPanel constructor comment. + * @param layout java.awt.LayoutManager + */ + public N5SettingsPanel(java.awt.LayoutManager layout) { + super(layout); + } + /** + * MovieSettingsPanel constructor comment. + * @param layout java.awt.LayoutManager + * @param isDoubleBuffered boolean + */ + public N5SettingsPanel(java.awt.LayoutManager layout, boolean isDoubleBuffered) { + super(layout, isDoubleBuffered); + } + /** + * MovieSettingsPanel constructor comment. + * @param isDoubleBuffered boolean + */ + public N5SettingsPanel(boolean isDoubleBuffered) { + super(isDoubleBuffered); + } + + + public void setSimulationSelector(ExportSpecs.SimulationSelector simulationSelector){ + this.simulationSelector = simulationSelector; + + } + + public void actionPerformed(java.awt.event.ActionEvent e) { + try{ + if (e.getSource() == getJButtonOK()) + this.fireJButtonOKAction_actionPerformed(new java.util.EventObject(this)); + if (e.getSource() == getCancelJButton()) + this.fireJButtonCancelAction_actionPerformed(new java.util.EventObject(this)); + + if (e.getSource() == getJRadioButtonBZIP()) + compressionLevel = N5Specs.CompressionLevel.BZIP; + if (e.getSource() == getJRadioButtonGZIP()) + compressionLevel = N5Specs.CompressionLevel.GZIP; + if (e.getSource() == getRadioButtonRAW()) + compressionLevel = N5Specs.CompressionLevel.RAW; + } + catch (Throwable ivjExc){ + handleException(ivjExc); + } + + // user code begin {2} + // user code end + } + /** + * + * @param newListener cbit.vcell.export.ASCIISettingsPanelListener + */ + public void addN5SettingsPanelListener(cbit.vcell.export.gui.ASCIISettingsPanelListener newListener) { + fieldASCIISettingsPanelListenerEventMulticaster = cbit.vcell.export.gui.ASCIISettingsPanelListenerEventMulticaster.add(fieldASCIISettingsPanelListenerEventMulticaster, newListener); + return; + } + + /** + * Method to support listener events. + * @param newEvent java.util.EventObject + */ + protected void fireJButtonCancelAction_actionPerformed(java.util.EventObject newEvent) { + if (fieldASCIISettingsPanelListenerEventMulticaster == null) { + return; + }; + fieldASCIISettingsPanelListenerEventMulticaster.JButtonCancelAction_actionPerformed(newEvent); + } + /** + * Method to support listener events. + * @param newEvent java.util.EventObject + */ + protected void fireJButtonOKAction_actionPerformed(java.util.EventObject newEvent) { + String dataSetName = getJTextFieldDataSetName().getText(); + boolean textConditions = dataSetName.isEmpty() || !dataSetName.matches("^[a-zA-Z 0-9]*$"); //Regex expression only allows spaces, a-z, A-Z, and 0-9. If it has anything else there is no Regex match + if (fieldASCIISettingsPanelListenerEventMulticaster == null || textConditions) { + return; + }; + fieldASCIISettingsPanelListenerEventMulticaster.JButtonOKAction_actionPerformed(newEvent); + } + + /** + * Return the CancelJButton property value. + * @return javax.swing.JButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JButton getCancelJButton() { + if (ivjCancelJButton == null) { + try { + ivjCancelJButton = new javax.swing.JButton(); + ivjCancelJButton.setName("CancelJButton"); + ivjCancelJButton.setText("Cancel"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjCancelJButton; + } + + /** + * Return the JButtonOK property value. + * @return javax.swing.JButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JButton getJButtonOK() { + if (ivjJButtonOK == null) { + try { + ivjJButtonOK = new javax.swing.JButton(); + ivjJButtonOK.setName("JButtonOK"); + ivjJButtonOK.setFont(new java.awt.Font("dialog", 1, 12)); + ivjJButtonOK.setText("OK"); + ivjJButtonOK.setMaximumSize(new java.awt.Dimension(100, 50)); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJButtonOK; + } + + /** + * Return the JLabelAdditional property value. + * @return javax.swing.JLabel + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JLabel getJLabelAdditional() { + if (ivjJLabelAdditional == null) { + try { + ivjJLabelAdditional = new javax.swing.JLabel(); + ivjJLabelAdditional.setName("JLabelAdditional"); + ivjJLabelAdditional.setPreferredSize(new java.awt.Dimension(108, 27)); + ivjJLabelAdditional.setText("Additional formatting:"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJLabelAdditional; + } + /** + * Return the JLabelDataFormat property value. + * @return javax.swing.JLabel + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JLabel getJLabelCompressionType() { + if (ivjJLabelDataType == null) { + try { + ivjJLabelDataType = new javax.swing.JLabel(); + ivjJLabelDataType.setName("JLabelCompressionType"); + ivjJLabelDataType.setPreferredSize(new java.awt.Dimension(108, 27)); + ivjJLabelDataType.setText("Compression Type:"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJLabelDataType; + } + + private javax.swing.JLabel getJLabelDatasetName() { + if (dataSetNameLabel == null) { + try { + dataSetNameLabel = new javax.swing.JLabel(); + dataSetNameLabel.setName("JLabelDatasetName"); + dataSetNameLabel.setPreferredSize(new java.awt.Dimension(108, 27)); + dataSetNameLabel.setText("Dataset Name:"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return dataSetNameLabel; + } + /** + * Return the JPanel1 property value. + * @return javax.swing.JPanel + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JPanel getMainPanel() { + if (mainPanel == null) { + try { + mainPanel = new javax.swing.JPanel(); + mainPanel.setName("MainPanel"); + mainPanel.setLayout(new java.awt.GridBagLayout()); + + java.awt.GridBagConstraints constraintsJButtonOK = new java.awt.GridBagConstraints(); + constraintsJButtonOK.fill = GridBagConstraints.HORIZONTAL; + constraintsJButtonOK.gridx = 0; constraintsJButtonOK.gridy = 0; + mainPanel.add(getJButtonOK(), constraintsJButtonOK); + + java.awt.GridBagConstraints constraintsCancelJButton = new java.awt.GridBagConstraints(); + constraintsCancelJButton.fill = GridBagConstraints.HORIZONTAL; + constraintsCancelJButton.gridx = 1; constraintsCancelJButton.gridy = 0; + mainPanel.add(getCancelJButton(), constraintsCancelJButton); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return mainPanel; + } + /** + * Return the JRadioButtonCompressed property value. + * @return javax.swing.JRadioButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JRadioButton getJRadioButtonParticles() { + if (ivjJRadioButtonParticles == null) { + try { + ivjJRadioButtonParticles = new javax.swing.JRadioButton(); + ivjJRadioButtonParticles.setName("JRadioButtonParticles"); + ivjJRadioButtonParticles.setText("Particle data"); + ivjJRadioButtonParticles.setEnabled(false); + } catch (java.lang.Throwable ivjExc) { + handleException(ivjExc); + } + } + return ivjJRadioButtonParticles; + } + /** + * Return the JRadioButtonUncompressed property value. + * @return javax.swing.JRadioButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JRadioButton getJRadioButtonVariables() { + if (ivjJRadioButtonVariables == null) { + try { + ivjJRadioButtonVariables = new javax.swing.JRadioButton(); + ivjJRadioButtonVariables.setName("JRadioButtonVariables"); + ivjJRadioButtonVariables.setSelected(true); + ivjJRadioButtonVariables.setText("Variable values"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjJRadioButtonVariables; + } + + /** + * Return the JRadioButtonUncompressed property value. + * @return javax.swing.JRadioButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JRadioButton getJRadioButtonBZIP() { + if (ivjRadioButtonBZIP == null) { + try { + ivjRadioButtonBZIP = new javax.swing.JRadioButton(); + ivjRadioButtonBZIP.setName("JRadioButtonBZIP"); + ivjRadioButtonBZIP.setSelected(true); + ivjRadioButtonBZIP.setText("BZIP"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return ivjRadioButtonBZIP; + } + + private JRadioButton getRadioButtonRAW(){ + if (radioButtonRAW == null) { + try { + radioButtonRAW = new javax.swing.JRadioButton(); + radioButtonRAW.setName("JRadioButtonRAW"); + radioButtonRAW.setSelected(true); + radioButtonRAW.setText("RAW"); + // user code begin {1} + // user code end + } catch (java.lang.Throwable ivjExc) { + // user code begin {2} + // user code end + handleException(ivjExc); + } + } + return radioButtonRAW; + } + + /** + * Return the JRadioButtonUncompressed property value. + * @return javax.swing.JRadioButton + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private javax.swing.JRadioButton getJRadioButtonGZIP() { + if (ivjRadioButtonGZIP == null) { + try { + ivjRadioButtonGZIP = new javax.swing.JRadioButton(); + ivjRadioButtonGZIP.setName("JRadioButtonGZIP"); + ivjRadioButtonGZIP.setSelected(true); + ivjRadioButtonGZIP.setText("GZIP"); + } catch (java.lang.Throwable ivjExc) { + handleException(ivjExc); + } + } + return ivjRadioButtonGZIP; + } + + private javax.swing.JTextField getJTextFieldDataSetName() { + if (dataSetName == null) { + try { + dataSetName = new javax.swing.JTextField(); + dataSetName.setName("JTextFieldDataSetName"); + dataSetName.setToolTipText("Only A-Z and 1-9"); + } catch (java.lang.Throwable ivjExc) { + handleException(ivjExc); + } + } + return dataSetName; + } + + /** + * Called whenever the part throws an exception. + * @param exception java.lang.Throwable + */ + private void handleException(Throwable exception) { + + /* Uncomment the following lines to print uncaught exceptions to stdout */ + System.out.println("--------- UNCAUGHT EXCEPTION ---------"); + exception.printStackTrace(System.out); + } + /** + * Initializes connections + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private void initConnections() throws java.lang.Exception { + // user code begin {1} + // user code end + getJButtonOK().addActionListener(this); + getJRadioButtonVariables().addItemListener(this); + this.addPropertyChangeListener(this); + getCancelJButton().addActionListener(this); + + getJRadioButtonGZIP().addActionListener(this); + getJRadioButtonBZIP().addActionListener(this); + } + /** + * Initialize the class. + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + private void initialize() { + try { + // user code begin {1} + // user code end + setName("N5SettingsPanel"); + setLayout(new java.awt.GridBagLayout()); + setSize(235, 403); + + java.awt.GridBagConstraints constraintsJLabelDataType = new java.awt.GridBagConstraints(); + constraintsJLabelDataType.gridx = 0; constraintsJLabelDataType.gridy = 0; + constraintsJLabelDataType.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJLabelDataType.weightx = 1.0; + constraintsJLabelDataType.insets = new Insets(10, 5, 5, 5); + add(getJLabelCompressionType(), constraintsJLabelDataType); + + java.awt.GridBagConstraints constraintsJRadioButtonVariables = new java.awt.GridBagConstraints(); + constraintsJRadioButtonVariables.anchor = GridBagConstraints.WEST; + constraintsJRadioButtonVariables.gridx = 0; constraintsJRadioButtonVariables.gridy = 1; + constraintsJRadioButtonVariables.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJRadioButtonVariables.weightx = 1.0; + constraintsJRadioButtonVariables.insets = new Insets(0, 5, 5, 5); + add(getJRadioButtonBZIP(), constraintsJRadioButtonVariables); + + java.awt.GridBagConstraints constraintsJRadioButtonParticles = new java.awt.GridBagConstraints(); + constraintsJRadioButtonParticles.anchor = GridBagConstraints.WEST; + constraintsJRadioButtonParticles.gridx = 0; constraintsJRadioButtonParticles.gridy = 2; + constraintsJRadioButtonParticles.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJRadioButtonParticles.weightx = 1.0; + constraintsJRadioButtonParticles.insets = new Insets(0, 5, 5, 5); + add(getJRadioButtonGZIP(), constraintsJRadioButtonParticles); + + java.awt.GridBagConstraints constraintsJRadioButtonRAW = new java.awt.GridBagConstraints(); + constraintsJRadioButtonRAW.anchor = GridBagConstraints.WEST; + constraintsJRadioButtonRAW.gridx = 0; constraintsJRadioButtonRAW.gridy = 3; + constraintsJRadioButtonRAW.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJRadioButtonRAW.weightx = 1.0; + constraintsJRadioButtonRAW.insets = new Insets(0, 5, 5, 5); + add(getRadioButtonRAW(), constraintsJRadioButtonRAW); + + java.awt.GridBagConstraints constraintsJLabelDataSetName = new java.awt.GridBagConstraints(); + constraintsJLabelDataSetName.anchor = GridBagConstraints.WEST; + constraintsJLabelDataSetName.gridx = 0; constraintsJLabelDataSetName.gridy = 4; + constraintsJLabelDataSetName.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJLabelDataSetName.weightx = 1.0; + constraintsJLabelDataSetName.insets = new Insets(0, 5, 5, 5); + add(getJLabelDatasetName(), constraintsJLabelDataSetName); + + java.awt.GridBagConstraints constraintsJTextFieldDataSetName = new java.awt.GridBagConstraints(); + constraintsJTextFieldDataSetName.anchor = GridBagConstraints.WEST; + constraintsJTextFieldDataSetName.gridx = 0; constraintsJTextFieldDataSetName.gridy = 5; + constraintsJTextFieldDataSetName.fill = java.awt.GridBagConstraints.HORIZONTAL; + constraintsJTextFieldDataSetName.weightx = 1.0; + constraintsJTextFieldDataSetName.insets = new Insets(0, 5, 5, 5); + add(getJTextFieldDataSetName(), constraintsJTextFieldDataSetName); + + ButtonGroup compressionButtons = new ButtonGroup(); + compressionButtons.add(getJRadioButtonBZIP()); + compressionButtons.add(getJRadioButtonGZIP()); + compressionButtons.add(getRadioButtonRAW()); + + + java.awt.GridBagConstraints constraintsJPanel1 = new java.awt.GridBagConstraints(); + constraintsJPanel1.gridx = 0; constraintsJPanel1.gridy = 6; + add(getMainPanel(), constraintsJPanel1); + initConnections(); + + } catch (java.lang.Throwable ivjExc) { + handleException(ivjExc); + } + // user code begin {2} + // user code end + } + + public static void main(String[] args) { + N5SettingsPanel n5SettingsPanel = new N5SettingsPanel(); + n5SettingsPanel.initialize(); + JFrame jFrame = new JFrame(); + jFrame.add(n5SettingsPanel.getMainPanel()); + jFrame.setSize(400, 400); + jFrame.setVisible(true); + n5SettingsPanel.getMainPanel().show(); + } + + /** + * Method to handle events for the ItemListener interface. + * @param e java.awt.event.ItemEvent + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + public void itemStateChanged(java.awt.event.ItemEvent e) { + return; + } + + /** + * Method to handle events for the PropertyChangeListener interface. + * @param evt java.beans.PropertyChangeEvent + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + public void propertyChange(java.beans.PropertyChangeEvent evt) { + return; + } + + /** + * Method to handle events for the ChangeListener interface. + * @param e javax.swing.event.ChangeEvent + */ + /* WARNING: THIS METHOD WILL BE REGENERATED. */ + public void stateChanged(javax.swing.event.ChangeEvent e) { + return; + } + + public N5Specs getN5Specs(){ + ExportSpecs.SimNameSimDataID[] simDataID = simulationSelector == null ? null : simulationSelector.getSelectedSimDataInfo(); + int[] paramScanIndexes = simulationSelector == null ? null : simulationSelector.getselectedParamScanIndexes(); + String dataSetName = getJTextFieldDataSetName().getText(); + + return new N5Specs(DataType.PDE_VARIABLE_DATA, ExportFormat.N5, compressionLevel, dataSetName); + } + + private JLabel lblSeeVcellHelp; + + private JLabel getLblSeeVcellHelp() { + if (lblSeeVcellHelp == null) { + lblSeeVcellHelp = new JLabel("Data set layout is xyzt"); // was "See VCell Help (Biomodel Applications/Simulations/Simulation Results/Exporting Spatial Simulation Results)" + lblSeeVcellHelp.setMinimumSize(new Dimension(300, 15)); + lblSeeVcellHelp.setMaximumSize(new Dimension(300, 15)); + lblSeeVcellHelp.setPreferredSize(new Dimension(300, 15)); + lblSeeVcellHelp.setToolTipText("See VCell Help (Biomodel Applications/Simulations/Simulation Results/Exporting Spatial Simulation Results)"); + } + return lblSeeVcellHelp; + } +} diff --git a/vcell-core/pom.xml b/vcell-core/pom.xml index 51b05306e9..f3032a914a 100644 --- a/vcell-core/pom.xml +++ b/vcell-core/pom.xml @@ -383,8 +383,7 @@ ${commons-codec.version} - - + diff --git a/vcell-core/src/main/java/cbit/vcell/export/server/ExportFormat.java b/vcell-core/src/main/java/cbit/vcell/export/server/ExportFormat.java index 39f172d904..d6f0311e5c 100644 --- a/vcell-core/src/main/java/cbit/vcell/export/server/ExportFormat.java +++ b/vcell-core/src/main/java/cbit/vcell/export/server/ExportFormat.java @@ -18,6 +18,7 @@ public enum ExportFormat { VTK_IMAGE("VTK Image (*.vtk)", false), PLY("Stanford Poly Texture (*.ply)", false), // IMAGEJ("ImageJ direct", false) + N5("Remote Storage Compatable with ImageJ (*." + N5Specs.n5Suffix.toUpperCase() + ")", true), ; ExportFormat(String label, boolean requiresFollowOn ) { this.label = label; diff --git a/vcell-core/src/main/java/cbit/vcell/export/server/ExportServiceImpl.java b/vcell-core/src/main/java/cbit/vcell/export/server/ExportServiceImpl.java index cb0030a39d..fd237c5825 100644 --- a/vcell-core/src/main/java/cbit/vcell/export/server/ExportServiceImpl.java +++ b/vcell-core/src/main/java/cbit/vcell/export/server/ExportServiceImpl.java @@ -16,6 +16,7 @@ import java.io.IOException; import java.io.ObjectOutputStream; import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.util.Collection; import java.util.Hashtable; @@ -58,6 +59,8 @@ public class ExportServiceImpl implements ExportConstants, ExportService { private IMGExporter imgExporter = new IMGExporter(this); private RasterExporter rrExporter = new RasterExporter(this); + private N5Exporter n5Exporter = new N5Exporter(this); + /** * Insert the method's description here. @@ -223,6 +226,9 @@ public ExportEvent makeRemoteFile(OutputContext outputContext,User user, DataSer case NRRD: fileFormat = "NRRD"; break; + case N5: + fileFormat = N5Specs.n5Suffix.toUpperCase(); + break; // case IMAGEJ: // fileFormat = "IMAGEJ"; // break; @@ -233,6 +239,7 @@ public ExportEvent makeRemoteFile(OutputContext outputContext,User user, DataSer String exportBaseURL = PropertyLoader.getRequiredProperty(PropertyLoader.exportBaseURLProperty); String exportBaseDir = PropertyLoader.getRequiredProperty(PropertyLoader.exportBaseDirInternalProperty); + String exportN5Dir = PropertyLoader.getRequiredProperty(PropertyLoader.n5DataDir); // // see if we've done this before, and try to get it @@ -305,6 +312,13 @@ public ExportEvent makeRemoteFile(OutputContext outputContext,User user, DataSer case VTK_UNSTRUCT: exportOutputs = rrExporter.makeVTKUnstructuredData(outputContext,newExportJob, user, dataServerImpl, exportSpecs,fileDataContainerManager); return makeRemoteFile(fileFormat, exportBaseDir, exportBaseURL, exportOutputs, exportSpecs, newExportJob,fileDataContainerManager); + case N5: + long jobID = ((VCSimulationDataIdentifier) exportSpecs.getVCDataIdentifier()).getJobIndex(); + n5Exporter.initalizeDataControllers(exportSpecs.getVCDataIdentifier().getDataKey().toString() ,user.getName(), user.getID().toString(), jobID); + ExportOutput exportOutput = n5Exporter.makeN5Data(outputContext, newExportJob, exportSpecs, fileDataContainerManager); + URI uri = new URI(PropertyLoader.getRequiredProperty(PropertyLoader.exportBaseURLProperty)); + String url = uri.getScheme() + "://" + uri.getHost() + ":" + PropertyLoader.getRequiredProperty(PropertyLoader.s3ProxyExternalPort) + "/" + n5Exporter.n5BucketName + "/"; + return makeRemoteN5File(fileFormat, n5Exporter.getN5FileNameHash(), url + n5Exporter.getN5FileNameHash() + "." + N5Specs.n5Suffix, exportOutput, exportSpecs, newExportJob); default: throw new DataAccessException("Unknown export format requested"); } @@ -464,6 +478,18 @@ private ExportEvent makeRemoteFile_Unzipped(String fileFormat, String exportBase } +private ExportEvent makeRemoteN5File(String fileFormat, String fileName, String exportBaseURL, ExportOutput exportOutput, ExportSpecs exportSpecs, JobRequest newExportJob) throws DataFormatException, IOException{ + if (exportOutput.isValid()) { + completedExportRequests.put(exportSpecs, newExportJob); + if (lg.isTraceEnabled()) lg.trace("ExportServiceImpl.makeRemoteFile(): Successfully exported to file: " + fileName); + return fireExportCompleted(newExportJob.getJobID(), exportSpecs.getVCDataIdentifier(), fileFormat, exportBaseURL, exportSpecs); + } + else { + throw new DataFormatException("Export Server could not produce valid data !"); + } +} + + /** * Insert the method's description here. * Creation date: (3/29/2001 5:18:16 PM) diff --git a/vcell-core/src/main/java/cbit/vcell/export/server/N5Exporter.java b/vcell-core/src/main/java/cbit/vcell/export/server/N5Exporter.java new file mode 100644 index 0000000000..7534ca8fd7 --- /dev/null +++ b/vcell-core/src/main/java/cbit/vcell/export/server/N5Exporter.java @@ -0,0 +1,274 @@ +/* + * Copyright (C) 1999-2011 University of Connecticut Health Center + * + * Licensed under the MIT License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.opensource.org/licenses/mit-license.php + */ + +package cbit.vcell.export.server; + +import cbit.vcell.math.MathException; +import cbit.vcell.math.VariableType; +import cbit.vcell.resource.PropertyLoader; +import cbit.vcell.simdata.*; +import cbit.vcell.solver.AnnotatedFunction; +import cbit.vcell.solver.VCSimulationDataIdentifier; +import cbit.vcell.solver.VCSimulationIdentifier; +import com.google.gson.GsonBuilder; +import edu.uchc.connjur.wb.ExecutionTrace; +import org.apache.commons.codec.binary.Hex; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.janelia.saalfeldlab.n5.DatasetAttributes; +import org.janelia.saalfeldlab.n5.DoubleArrayDataBlock; +import org.janelia.saalfeldlab.n5.N5FSWriter; +import org.vcell.util.*; +import org.vcell.util.document.*; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.util.*; + + +public class N5Exporter implements ExportConstants { + private final static Logger lg = LogManager.getLogger(N5Exporter.class); + + private ExportServiceImpl exportServiceImpl = null; + + private DataSetControllerImpl dataSetController; + + private VCSimulationDataIdentifier vcDataID; + public String n5BucketName = "n5Data"; + + public static final ArrayList unsupportedTypes = new ArrayList<>(Arrays.asList( + VariableType.MEMBRANE, + VariableType.VOLUME_REGION, + VariableType.MEMBRANE_REGION, + VariableType.UNKNOWN, + VariableType.POINT_VARIABLE, + VariableType.NONSPATIAL, + VariableType.CONTOUR, + VariableType.CONTOUR_REGION, + VariableType.POSTPROCESSING + )); + + private VCData vcData; + + + public N5Exporter(ExportServiceImpl exportServiceImpl) { + this.exportServiceImpl = exportServiceImpl; +} + + private ExportOutput exportToN5(OutputContext outputContext, long jobID, N5Specs n5Specs, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) throws MathException, DataAccessException, IOException { + double[] allTimes = vcData.getDataTimes(); + // output context expects a list of annotated functions, vcData seems to already have a set of annotated functions + + // With Dex's dataset ID get the data block during the first time instance t + + // All variables can be visually represented, its just that some have its data already computed, and others are derived + // from that data, so if we want to visualize that data we need to compute the results. + + // according to Jim what should happen is that the VCdata should automatically derive the data for me since it knows everything + // and the only reason why this wouldn't work is due to some misconfiguration, but what is that misconfig + + ArrayList species = new ArrayList<>(); + for (String specie: exportSpecs.getVariableSpecs().getVariableNames()){ + species.add(getSpecificDI(specie)); + } + + + for (DataIdentifier specie: species) { + if (unsupportedTypes.contains(specie.getVariableType())) { + throw new RuntimeException("Tried to export a variable type that is not supported!"); + } + } + // DexDataIdentifier.getVariableType(); + + int numVariables = species.size(); + int numTimes = exportSpecs.getTimeSpecs().getEndTimeIndex() - exportSpecs.getTimeSpecs().getBeginTimeIndex(); + long[] dimensions = {vcData.getMesh().getSizeX(), vcData.getMesh().getSizeY(), numVariables, vcData.getMesh().getSizeZ(), numTimes}; + // 51X, 51Y, 1Z, 1C, 2T + int[] blockSize = {vcData.getMesh().getSizeX(), vcData.getMesh().getSizeY(), 1, vcData.getMesh().getSizeZ(), 1}; + + + // rewrite so that it still results in a tmp file does not raise File already exists error + N5FSWriter n5FSWriter = new N5FSWriter(getN5FileAbsolutePath(), new GsonBuilder()); + DatasetAttributes datasetAttributes = new DatasetAttributes(dimensions, blockSize, org.janelia.saalfeldlab.n5.DataType.FLOAT64, n5Specs.getCompression()); + HashMap additionalMetaData = new HashMap<>(); + + String dataSetName = getN5DataSetTemplatedName(n5Specs.dataSetName); + + n5FSWriter.createDataset(dataSetName, datasetAttributes); + N5Specs.imageJMetaData(n5FSWriter, dataSetName, vcData, numVariables, additionalMetaData); + + + for (int variableIndex=0; variableIndex < numVariables; variableIndex++){ + //place to add tracking, each variable can be measured in tracking + double varFrac = (double) variableIndex / numVariables; + for (int timeIndex=exportSpecs.getTimeSpecs().getBeginTimeIndex(); timeIndex < exportSpecs.getTimeSpecs().getEndTimeIndex(); timeIndex++){ + //another place to add tracking, each time index can be used to determine how much has been exported + // data does get returned, but it does not seem to cover the entire region of space, but only returns regions where there is activity + double[] data = this.dataSetController.getSimDataBlock(outputContext, this.vcDataID, species.get(variableIndex).getName(), allTimes[timeIndex]).getData(); + DoubleArrayDataBlock doubleArrayDataBlock = new DoubleArrayDataBlock(blockSize, new long[]{0, 0, variableIndex, 0, timeIndex}, data); + n5FSWriter.writeBlock(dataSetName, datasetAttributes, doubleArrayDataBlock); + if(timeIndex % 5 == 0){ + double timeFrac = (double) timeIndex / exportSpecs.getTimeSpecs().getEndTimeIndex(); + double progress = (varFrac + timeFrac) / (numVariables + exportSpecs.getTimeSpecs().getEndTimeIndex()); + exportServiceImpl.fireExportProgress(jobID, vcDataID, N5Specs.n5Suffix.toUpperCase(), progress); + } + } + } + n5FSWriter.close(); + ExportOutput exportOutput = new ExportOutput(true, "." + N5Specs.n5Suffix, vcDataID.getID(), getN5FileNameHash(), fileDataContainerManager); + return exportOutput; + } + + public void initalizeDataControllers(String simKeyID, String userName, String userKey, long jobIndex) throws IOException, DataAccessException { + // Set my user ID associated with VC database + // set simulation key + // make an object that ties the user to that simulation key + // make an object that then identifies the simulation + User user = new User(userName, new KeyValue(userKey)); + + KeyValue simKey = new KeyValue(simKeyID); + VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, user); + this.vcDataID = new VCSimulationDataIdentifier(vcSimID, (int)jobIndex); + + // Point a data controller to the directory where the sim data is and use the vcdID to retrieve information regarding the sim, need to ask about what size this should be + Cachetable cachetable = new Cachetable(10 * Cachetable.minute, Long.parseLong(PropertyLoader.getRequiredProperty(PropertyLoader.simdataCacheSizeProperty))); + File primaryDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)); + File secodaryDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)); + this.dataSetController = new DataSetControllerImpl(cachetable, primaryDir, secodaryDir); + + // get dataset identifier from the simulation + + this.vcData = this.dataSetController.getVCData(vcDataID); + } + + public void initalizeDataControllers(){ + + } + + public VCData getVCData(){ + return vcData; + } + + public VCSimulationDataIdentifier getVcDataID(){return vcDataID;} + + public DataSetControllerImpl getDataSetController() { + return dataSetController; + } + + + + public DataIdentifier getRandomDI() throws IOException, DataAccessException { + ArrayList list = new ArrayList<>(Arrays.asList(dataSetController.getDataIdentifiers(new OutputContext(new AnnotatedFunction[0]), vcDataID))); + Random random = new Random(); + DataIdentifier df = list.remove(random.nextInt(list.size())); + while (unsupportedTypes.contains(df.getVariableType())){ + df = list.remove(random.nextInt(list.size())); + } + return df; + } + + public DataIdentifier getSpecificDI(String diName) throws IOException, DataAccessException { + ArrayList list = new ArrayList<>(Arrays.asList(dataSetController.getDataIdentifiers(new OutputContext(new AnnotatedFunction[0]), vcDataID))); + for(DataIdentifier dataIdentifier: list){ + if(dataIdentifier.getName().equals(diName)){ + list.remove(dataIdentifier); + return dataIdentifier; + } + } + return null; + } + + public ArrayList getSupportedSpecies() throws IOException, DataAccessException { + OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); + DataIdentifier[] dataSetIdentifiers = this.vcData.getVarAndFunctionDataIdentifiers(outputContext); + + ArrayList supportedSpecies = new ArrayList<>(); + + for(DataIdentifier specie: dataSetIdentifiers){ + if(!unsupportedTypes.contains(specie.getVariableType())){ + supportedSpecies.add(specie.getName()); + } + } + + return supportedSpecies; + } + + public String getN5FileAbsolutePath(){ + File outPutDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.n5DataDir) + "/" + n5BucketName + "/" + this.getN5FileNameHash() + "." + N5Specs.n5Suffix); + return outPutDir.getAbsolutePath(); + } + + public String getN5FileNameHash(){ + return actualHash(vcDataID.getDataKey().toString(), String.valueOf(vcDataID.getJobIndex())); + } + + public String getN5DataSetTemplatedName(String nonTemplatedName){ + return nonTemplatedName + "_" + vcDataID.getJobIndex(); + } + + public static String getN5FileNameHash(String simID, String jobID){ + return actualHash(simID, jobID); + } + + private static String actualHash(String simID, String jobID) { + MessageDigest sha256 = DigestUtils.getSha256Digest(); + sha256.update(simID.getBytes(StandardCharsets.UTF_8)); +// sha256.update(jobID.getBytes(StandardCharsets.UTF_8)); + + return Hex.encodeHexString(sha256.digest()); + } + + +/** + * This method was created in VisualAge. + * @throws IOException + */ + public ExportOutput makeN5Data(OutputContext outputContext, JobRequest jobRequest, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) + throws DataAccessException, IOException, MathException { + FormatSpecificSpecs formatSpecs = exportSpecs.getFormatSpecificSpecs( ); + if (formatSpecs instanceof N5Specs n5Specs){ + return exportToN5( + outputContext, + jobRequest.getJobID(), + n5Specs, + exportSpecs, + fileDataContainerManager + ); + } + else { + throw new IllegalArgumentException("Export spec " + ExecutionTrace.justClassName(formatSpecs) + " not instance of " + ExecutionTrace.justClassName(N5Specs.class)); + } + } + + public ExportOutput makeN5Data(OutputContext outputContext, long jobID, ExportSpecs exportSpecs, FileDataContainerManager fileDataContainerManager) + throws DataAccessException, IOException, MathException { + FormatSpecificSpecs formatSpecs = exportSpecs.getFormatSpecificSpecs( ); + if (formatSpecs instanceof N5Specs n5Specs) { + return exportToN5( + outputContext, + jobID, + n5Specs, + exportSpecs, + fileDataContainerManager + ); + } else { + throw new IllegalArgumentException("Export spec " + ExecutionTrace.justClassName(formatSpecs) + " not instance of " + ExecutionTrace.justClassName(N5Specs.class)); + } + } + +/** + * manage sending progress percent info for {@link N5Exporter#exportParticleData(OutputContext, long, User, DataServerImpl, ExportSpecs, ASCIISpecs, FileDataContainerManager) + * + */ + +} diff --git a/vcell-core/src/main/java/cbit/vcell/export/server/N5Specs.java b/vcell-core/src/main/java/cbit/vcell/export/server/N5Specs.java new file mode 100644 index 0000000000..5a180b014a --- /dev/null +++ b/vcell-core/src/main/java/cbit/vcell/export/server/N5Specs.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 1999-2011 University of Connecticut Health Center + * + * Licensed under the MIT License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.opensource.org/licenses/mit-license.php + */ + +package cbit.vcell.export.server; + +import cbit.vcell.math.MathException; +import cbit.vcell.simdata.VCData; +import org.janelia.saalfeldlab.n5.*; +import org.vcell.util.Compare; +import org.vcell.util.DataAccessException; + +import java.io.IOException; +import java.io.Serializable; +import java.util.HashMap; + +/** + * This type was created in VisualAge. + */ +@SuppressWarnings("serial") +public class N5Specs extends FormatSpecificSpecs implements Serializable { + private final ExportFormat format; + private final ExportConstants.DataType dataType; + private final CompressionLevel compression; + + public final String dataSetName; + + public static String n5Suffix = "n5"; + + public static enum CompressionLevel{ + RAW, + BZIP, + GZIP + } + +/** + * TextSpecs constructor comment. + */ + public N5Specs(ExportConstants.DataType dataType, ExportFormat format, CompressionLevel compressionLevel, String dataSetName) { + this.format = format; + this.dataType = dataType; + this.compression = compressionLevel; + this.dataSetName = dataSetName; + } + /** + * This method was created in VisualAge. + * @return int + */ + public ExportConstants.DataType getDataType() { + return dataType; + } + /** + * This method was created in VisualAge. + * @return int + */ + public ExportFormat getFormat() { + return format; + } + + public Compression getCompression(){ + switch (compression){ + case RAW: + return new RawCompression(); + case BZIP: + return new Bzip2Compression(); + case GZIP: + return new GzipCompression(); + default: + return new RawCompression(); + } + } + + + public boolean equals(Object object) { + return false; + } + + /** + * Insert the method's description here. + * Creation date: (4/2/2001 5:08:46 PM) + * @return java.lang.String + */ + public String toString() { + return "N5Specs: [compression: " + format + ", chunking: " + dataType + ", switchRowsColumns: " + "]"; + } + + + public static void imageJMetaData(N5FSWriter n5FSWriter, String datasetPath, VCData vcData, int numChannels, HashMap additionalMetData) throws MathException, DataAccessException { + HashMap metaData = new HashMap<>(); + metaData.put("name", "TestName"); + metaData.put("fps", 0.0); + metaData.put("frameInterval", 0.0); + metaData.put("pixelWidth", 1.0); + metaData.put("pixelHeight", 1.0); + metaData.put("pixelDepth", 1.0); + metaData.put("xOrigin", 0.0); + metaData.put("yOrigin", 0.0); + metaData.put("zOrigin", 0.0); + metaData.put("numChannels", numChannels); // + metaData.put("numSlices", vcData.getMesh().getSizeZ()); + metaData.put("numFrames", vcData.getDataTimes().length); + metaData.put("type", 2); //https://imagej.nih.gov/ij/developer/api/ij/ij/ImagePlus.html#getType() Grayscale with float types + metaData.put("unit", "uM"); //https://imagej.nih.gov/ij/developer/api/ij/ij/measure/Calibration.html#getUnit() + metaData.put("properties", additionalMetData); + + try { + n5FSWriter.setAttributes(datasetPath, metaData); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + +} diff --git a/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java b/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java index 9d90847f9d..394732e7ce 100644 --- a/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java +++ b/vcell-core/src/main/java/cbit/vcell/resource/PropertyLoader.java @@ -60,6 +60,7 @@ public static void setConfigProvider(VCellConfigProvider configProvider) { public static final String vcellServerIDProperty = record("vcell.server.id",ValueType.GEN); public static final String n5DataDir = record("vcell.n5DataDir.internal", ValueType.DIR); + public static final String s3ProxyExternalPort = record("vcell.s3proxy.port.external", ValueType.GEN); public static final String simPerUserMemoryLimitFile = record("vcell.htc.simPerUserMemLimitFile",ValueType.GEN); public static final String primarySimDataDirInternalProperty = record("vcell.primarySimdatadir.internal",ValueType.DIR); public static final String secondarySimDataDirInternalProperty = record("vcell.secondarySimdatadir.internal",ValueType.DIR); diff --git a/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5Exporter.java b/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5Exporter.java deleted file mode 100644 index b6ddd6b317..0000000000 --- a/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5Exporter.java +++ /dev/null @@ -1,240 +0,0 @@ -package cbit.vcell.simdata.n5; - -import cbit.vcell.export.server.ExportConstants; -import cbit.vcell.math.MathException; -import cbit.vcell.math.VariableType; -import cbit.vcell.resource.PropertyLoader; -import cbit.vcell.simdata.*; -import cbit.vcell.solver.AnnotatedFunction; -import cbit.vcell.solver.VCSimulationDataIdentifier; -import cbit.vcell.solver.VCSimulationIdentifier; -import com.google.gson.GsonBuilder; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.janelia.saalfeldlab.n5.Compression; -import org.janelia.saalfeldlab.n5.DatasetAttributes; -import org.janelia.saalfeldlab.n5.DoubleArrayDataBlock; -import org.janelia.saalfeldlab.n5.N5FSWriter; -import org.vcell.util.DataAccessException; -import org.vcell.util.document.KeyValue; -import org.vcell.util.document.User; - -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; - -/* - Variables can be considered channels, and each variable may not have a spatial representation, but for the ones that do - they should be considered separate domains and segmented within their own channel. - - The chunking of content is such that each block contains X,Y,Z information, and they are separated by channels and time. - This way external libraries won't have to be used to manipulate the matrices represented as arrays and can save computational time due to not - having to rearrange the already existing matrices by adding time and channel data to them. Although the current chunking may not - be the most efficient for retrieval. - - It seems that it doesn't matter whether the data is row or column major since N5 data block writer handles both appropriately, only when - I started to add extra dimensions to the array matrix did it start to misbehave. - - //vcData.addFunction(new AugmentedFunction("function_name", new Expression("x + 100*y + sin(t)")) - - // X,Y,Z raster for time 0 for variable cAMP - // index in matrix c + nc * ri 2D - // (c + nc * ri) * block_size + zi 3D - //positive y goes down instead of up - */ -public class N5Exporter implements ExportConstants { - private final static Logger lg = LogManager.getLogger(N5Exporter.class); - private static OutputContext outputContext; - private DataSetControllerImpl dataSetController; - - private VCSimulationDataIdentifier vcDataID; - - public static final ArrayList unsupportedTypes = new ArrayList<>(Arrays.asList( - VariableType.MEMBRANE, - VariableType.VOLUME_REGION, - VariableType.MEMBRANE_REGION, - VariableType.UNKNOWN, - VariableType.POINT_VARIABLE, - VariableType.NONSPATIAL, - VariableType.CONTOUR, - VariableType.CONTOUR_REGION, - VariableType.POSTPROCESSING - )); - - private VCData vcData; - - // Have the HDF5 exporter export its data to a file, then read with N5HDF5 reader, then block by block write it into N5 - // Grab the object that has the data for sim files in blocks, then instead of writting the file, feed it into N5FSwriter - // Get the simulated datablock output, then rewrite that as chunks within the N5 dataset, not having to - - //intake the variables people want, don't just take them all - public void exportToN5(ArrayList species, Compression compression) throws MathException, DataAccessException, IOException { - double[] allTimes = vcData.getDataTimes(); - - - // output context expects a list of annotated functions, vcData seems to already have a set of annotated functions - - OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); - // With Dex's dataset ID get the data block during the first time instance t - - // All variables can be visually represented, its just that some have its data already computed, and others are derived - // from that data, so if we want to visualize that data we need to compute the results. - - // according to Jim what should happen is that the VCdata should automatically derive the data for me since it knows everything - // and the only reason why this wouldn't work is due to some misconfiguration, but what is that misconfig - - for (DataIdentifier specie: species){ - if(unsupportedTypes.contains(specie.getVariableType())){ - throw new RuntimeException("Tried to export a variable type that is not supported!"); - } - } - - -// DexDataIdentifier.getVariableType(); - - int numVariables = species.size(); - int numTimes = allTimes.length; - long[] dimensions = {vcData.getMesh().getSizeX(), vcData.getMesh().getSizeY(), numVariables, vcData.getMesh().getSizeZ(), numTimes}; - // 51X, 51Y, 1Z, 1C, 2T - int[] blockSize = {vcData.getMesh().getSizeX(), vcData.getMesh().getSizeY(), 1, vcData.getMesh().getSizeZ(), 1}; - String dataSet = vcDataID.getID(); - - - N5FSWriter n5FSWriter = new N5FSWriter(this.getN5FileAbsolutePath(), new GsonBuilder()); - DatasetAttributes datasetAttributes = new DatasetAttributes(dimensions, blockSize, org.janelia.saalfeldlab.n5.DataType.FLOAT64, compression); - HashMap additionalMetaData = new HashMap<>(); - - n5FSWriter.createDataset(dataSet, datasetAttributes); - N5MetaData.imageJMetaData(n5FSWriter, dataSet, vcData, numVariables, additionalMetaData); - - - - for (int variableIndex=0; variableIndex < numVariables; variableIndex++){ - - //place to add tracking, each variable can be measured in tracking - - - for (int timeIndex=0; timeIndex < numTimes; timeIndex++){ - //another place to add tracking, each time index can be used to determine how much has been exported - - - // data does get returned, but it does not seem to cover the entire region of space, but only returns regions where there is activity - double[] data = this.dataSetController.getSimDataBlock(outputContext, this.vcDataID, species.get(variableIndex).getName(), allTimes[timeIndex]).getData(); -// double [] data = vcData.getSimDataBlock(outputContext, volumeDataIDs.get(channelIndex).getName(), allTimes[timeIndex]).getData(); - DoubleArrayDataBlock doubleArrayDataBlock = new DoubleArrayDataBlock(blockSize, new long[]{0, 0, variableIndex, 0, timeIndex}, data); - n5FSWriter.writeBlock(dataSet, datasetAttributes, doubleArrayDataBlock); - } - } - - n5FSWriter.close(); - } - - public void initalizeDataControllers(String simKeyID, String userName, String userKey) throws IOException, DataAccessException { - // Set my user ID associated with VC database - // set simulation key - // make an object that ties the user to that simulation key - // make an object that then identifies the simulation - User user = new User(userName, new KeyValue(userKey)); - - KeyValue simKey = new KeyValue(simKeyID); - VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, user); - this.vcDataID = new VCSimulationDataIdentifier(vcSimID, 0); - - // Point a data controller to the directory where the sim data is and use the vcdID to retrieve information regarding the sim - Cachetable cachetable = new Cachetable(10 * Cachetable.minute, 1000000L); - File primaryDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)); - this.dataSetController = new DataSetControllerImpl(cachetable, primaryDir, null); - - // get dataset identifier from the simulation - - this.vcData = this.dataSetController.getVCData(vcDataID); - } - - public VCData getVCData(){ - return vcData; - } - - public DataSetControllerImpl getDataSetController() { - return dataSetController; - } - - public VCSimulationDataIdentifier getVcDataID() { - return vcDataID; - } - - public Double[] unitConversion(){ - return null; - } - - - - public DataIdentifier getRandomDI() throws IOException, DataAccessException { - ArrayList list = new ArrayList<>(Arrays.asList(dataSetController.getDataIdentifiers(new OutputContext(new AnnotatedFunction[0]), vcDataID))); - Random random = new Random(); - DataIdentifier df = list.remove(random.nextInt(list.size())); - while (unsupportedTypes.contains(df.getVariableType())){ - df = list.remove(random.nextInt(list.size())); - } - return df; - } - - public DataIdentifier getSpecificDI(String diName) throws IOException, DataAccessException { - ArrayList list = new ArrayList<>(Arrays.asList(dataSetController.getDataIdentifiers(new OutputContext(new AnnotatedFunction[0]), vcDataID))); - for(DataIdentifier dataIdentifier: list){ - if(dataIdentifier.getName().equals(diName)){ - list.remove(dataIdentifier); - return dataIdentifier; - } - } - return null; - } - - public ArrayList getSupportedSpecies() throws IOException, DataAccessException { - OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); - DataIdentifier[] dataSetIdentifiers = this.vcData.getVarAndFunctionDataIdentifiers(outputContext); - - ArrayList supportedSpecies = new ArrayList<>(); - - for(DataIdentifier specie: dataSetIdentifiers){ - if(!unsupportedTypes.contains(specie.getVariableType())){ - supportedSpecies.add(specie.getName()); - } - } - - return supportedSpecies; - } - - public String getN5FileAbsolutePath(){ - File outPutDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.n5DataDir) + "/" + this.n5FileNameHash() + ".n5"); - return outPutDir.getAbsolutePath(); - } - - public String getN5DatasetName(){ - return vcDataID.getID(); - } - - public String n5FileNameHash(){ - return actualHash(vcDataID.getID(), String.valueOf(vcDataID.getJobIndex())); - } - - public static String n5FileNameHash(String simID, String jobID){ - return actualHash(simID, jobID); - } - - private static String actualHash(String simID, String jobID) { - MessageDigest sha256 = DigestUtils.getSha256Digest(); - sha256.update(simID.getBytes(StandardCharsets.UTF_8)); - sha256.update(jobID.getBytes(StandardCharsets.UTF_8)); - - return Hex.encodeHexString(sha256.digest()); - } - - -} \ No newline at end of file diff --git a/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5MetaData.java b/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5MetaData.java deleted file mode 100644 index a51356f892..0000000000 --- a/vcell-core/src/main/java/cbit/vcell/simdata/n5/N5MetaData.java +++ /dev/null @@ -1,55 +0,0 @@ -package cbit.vcell.simdata.n5; - -import cbit.vcell.math.MathException; -import cbit.vcell.simdata.VCData; -import org.janelia.saalfeldlab.n5.DatasetAttributes; -import org.janelia.saalfeldlab.n5.N5FSWriter; -import org.vcell.util.DataAccessException; - -import java.io.IOException; -import java.util.HashMap; - -/* - Take the VCell sim data, and create metadata that can be used within different applications - Focus for now is ImageJ, creating the metadata that can be used for it - https://github.com/saalfeldlab/n5-ij/wiki/N5-Metadata-Dialects - Dataset has to already be made, then use the N5FSWriter to add attributes to it, using some sort of hash map with all of the required attributes - - The units vary between different variables so need to ask someone about this?? - - - pixelWidth: number (float) - pixel spacing of the x axis (see Calibration.pixelWidth) - corresponds to scale[0] in (Physical space) - */ -public class N5MetaData { - //https://github.com/saalfeldlab/n5-ij/wiki/TranslateMetadata#setscale2d - public static void imageJMetaData(N5FSWriter n5FSWriter, String datasetPath, VCData vcData, int numChannels, HashMap additionalMetData) throws MathException, DataAccessException { - HashMap metaData = new HashMap<>(); - metaData.put("name", "TestName"); - metaData.put("fps", 0.0); - metaData.put("frameInterval", 0.0); - metaData.put("pixelWidth", 1.0); - metaData.put("pixelHeight", 1.0); - metaData.put("pixelDepth", 1.0); - metaData.put("xOrigin", 0.0); - metaData.put("yOrigin", 0.0); - metaData.put("zOrigin", 0.0); - metaData.put("numChannels", numChannels); // - metaData.put("numSlices", vcData.getMesh().getSizeZ()); - metaData.put("numFrames", vcData.getDataTimes().length); - metaData.put("type", 2); //https://imagej.nih.gov/ij/developer/api/ij/ij/ImagePlus.html#getType() Grayscale with float types - metaData.put("unit", "uM"); //https://imagej.nih.gov/ij/developer/api/ij/ij/measure/Calibration.html#getUnit() - metaData.put("properties", additionalMetData); - - try { - n5FSWriter.setAttributes(datasetPath, metaData); - } catch (IOException e) { - throw new RuntimeException(e); - } - - } - - - -} diff --git a/vcell-core/src/test/java/simdata/n5/N5ExporterTest.java b/vcell-core/src/test/java/cbit/vcell/export/N5ExporterTest.java similarity index 66% rename from vcell-core/src/test/java/simdata/n5/N5ExporterTest.java rename to vcell-core/src/test/java/cbit/vcell/export/N5ExporterTest.java index 3af0d15b27..abb1637d5d 100644 --- a/vcell-core/src/test/java/simdata/n5/N5ExporterTest.java +++ b/vcell-core/src/test/java/cbit/vcell/export/N5ExporterTest.java @@ -1,4 +1,4 @@ -package simdata.n5; +package cbit.vcell.export; @@ -13,13 +13,10 @@ be the control. */ +import cbit.vcell.export.server.*; import cbit.vcell.math.MathException; import cbit.vcell.resource.PropertyLoader; -import cbit.vcell.simdata.DataIdentifier; -import cbit.vcell.simdata.DataSetControllerImpl; -import cbit.vcell.simdata.OutputContext; -import cbit.vcell.simdata.VCData; -import cbit.vcell.simdata.n5.N5Exporter; +import cbit.vcell.simdata.*; import cbit.vcell.solver.AnnotatedFunction; import cbit.vcell.solver.VCSimulationDataIdentifier; import org.janelia.saalfeldlab.n5.*; @@ -31,9 +28,7 @@ import org.vcell.test.Fast; import org.vcell.util.DataAccessException; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.ArrayList; import java.util.Arrays; import java.util.Objects; @@ -44,10 +39,10 @@ public class N5ExporterTest { private N5Reader n5Reader; private VCData controlModel; - private String dataSetName; private DataSetControllerImpl controlModelController; private VCSimulationDataIdentifier vcDataID; private ArrayList variables; + private N5Exporter n5Exporter; private static final String fourDModelID = "597714292"; private static final String fiveDModelID = "1107466895"; private final ArrayList testModels = new ArrayList<>(Arrays.asList( @@ -57,7 +52,9 @@ public class N5ExporterTest { private static String previousInstallRoot; private static String previousPrimarySimDir; - + private static String previousSecondarySimDir; + private static String previousSecondaryInternalSimDir; + private static String previousSimCacheSize; private static String previousN5Path; public final File temporaryFolder = new File(System.getProperty("java.io.tmpdir")); @@ -103,8 +100,20 @@ public void setUp() throws IOException { previousPrimarySimDir = PropertyLoader.getProperty(PropertyLoader.primarySimDataDirInternalProperty, null); PropertyLoader.setProperty(PropertyLoader.primarySimDataDirInternalProperty, temporaryFolder.getAbsolutePath()); + previousSecondarySimDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirExternalProperty, null); + System.setProperty(PropertyLoader.secondarySimDataDirExternalProperty, temporaryFolder.getAbsolutePath()); + + previousSecondarySimDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirExternalProperty, null); + System.setProperty(PropertyLoader.secondarySimDataDirExternalProperty, temporaryFolder.getAbsolutePath()); + previousN5Path = PropertyLoader.getProperty(PropertyLoader.n5DataDir, null); PropertyLoader.setProperty(PropertyLoader.n5DataDir, n5ExportDir.getAbsolutePath()); + + previousSecondarySimDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null); + PropertyLoader.setProperty(PropertyLoader.secondarySimDataDirInternalProperty, "k"); + + previousSimCacheSize = PropertyLoader.getProperty(PropertyLoader.simdataCacheSizeProperty, null); + PropertyLoader.setProperty(PropertyLoader.simdataCacheSizeProperty, "100000"); } @After @@ -122,6 +131,17 @@ public void restore() throws IOException { PropertyLoader.setProperty(PropertyLoader.n5DataDir, previousN5Path); } + if (previousSecondarySimDir != null){ + System.setProperty(PropertyLoader.secondarySimDataDirExternalProperty, previousSecondarySimDir); + } + + if (previousSecondaryInternalSimDir != null){ + System.setProperty(PropertyLoader.secondarySimDataDirInternalProperty, previousSecondaryInternalSimDir); + } + + if (previousSimCacheSize != null){ + System.setProperty(PropertyLoader.simdataCacheSizeProperty, previousSimCacheSize); + } if (n5Reader != null){ n5Reader.close(); @@ -129,18 +149,46 @@ public void restore() throws IOException { } - public void initalizeModel(String simKeyID, Compression compression) throws IOException, DataAccessException, MathException { - N5Exporter n5Exporter = new N5Exporter(); + public void makeN5Model(N5Specs.CompressionLevel compressionLevel, int startTimeIndex, int endTimeIndex, String modelID) throws MathException, IOException, DataAccessException { + OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); + + VariableSpecs variableSpecs = new VariableSpecs(variables.stream().map(di -> di.getName()).toList(), Integer.parseInt(modelID)); + GeometrySpecs geometrySpecs = new GeometrySpecs(new SpatialSelection[0], 0, 0, 0); + N5Specs n5Specs = new N5Specs(ExportConstants.DataType.PDE_VARIABLE_DATA, ExportFormat.N5, compressionLevel, modelID); + + double[] allTimes = n5Exporter.getDataSetController().getDataSetTimes(n5Exporter.getVcDataID()); + TimeSpecs timeSpecs = new TimeSpecs(startTimeIndex, endTimeIndex, allTimes, variableSpecs.getModeID()); + ExportSpecs exportSpecs = new ExportSpecs(n5Exporter.getVcDataID(), ExportFormat.N5, variableSpecs, timeSpecs, geometrySpecs, n5Specs, "", ""); + FileDataContainerManager fileDataContainerManager = new FileDataContainerManager(); + + ExportOutput exportOutput = n5Exporter.makeN5Data(outputContext, 0, exportSpecs, fileDataContainerManager); +// File file = new File(PropertyLoader.getRequiredProperty(PropertyLoader.n5DataDir) + "/" + n5Exporter.getN5FileNameHash() + ".N5"); +// FileOutputStream fileOut = new FileOutputStream(file); +// BufferedOutputStream out= new BufferedOutputStream(fileOut); +// exportOutput.writeDataToOutputStream(out, fileDataContainerManager); +// out.close(); + + if(n5Reader != null){ + n5Reader.close(); + } + this.n5Reader = new N5FSReader(n5Exporter.getN5FileAbsolutePath()); + } + + public void initalizeModel(String simKeyID) throws IOException, DataAccessException, MathException { + ExportServiceImpl exportService = new ExportServiceImpl(); + long jobId = 0; + + n5Exporter = new N5Exporter(exportService); if (simKeyID.equals(fourDModelID)){ // the test model can only support one species at this time - n5Exporter.initalizeDataControllers(fourDModelID, "ezequiel23", "258925427"); + n5Exporter.initalizeDataControllers(fourDModelID, "ezequiel23", "258925427", jobId); this.variables = new ArrayList<>(Arrays.asList( n5Exporter.getRandomDI() )); } else if (simKeyID.equals(fiveDModelID)){ - n5Exporter.initalizeDataControllers(fiveDModelID, "ezequiel23", "258925427"); + n5Exporter.initalizeDataControllers(fiveDModelID, "ezequiel23", "258925427", jobId); this.variables = new ArrayList<>(Arrays.asList( n5Exporter.getRandomDI(), n5Exporter.getRandomDI(), @@ -152,12 +200,7 @@ else if (simKeyID.equals(fiveDModelID)){ this.vcDataID = n5Exporter.getVcDataID(); this.controlModelController = n5Exporter.getDataSetController(); - n5Exporter.exportToN5(variables, compression); - if(n5Reader != null){ - n5Reader.close(); - } - this.n5Reader = new N5FSReader(n5Exporter.getN5FileAbsolutePath()); - this.dataSetName = n5Exporter.getN5DatasetName(); + } @@ -165,11 +208,12 @@ else if (simKeyID.equals(fiveDModelID)){ public void testMetaData() throws MathException, DataAccessException, IOException { for(String model: testModels){ - this.initalizeModel(model, new RawCompression()); + this.initalizeModel(model); + this.makeN5Model(N5Specs.CompressionLevel.RAW, 0, controlModel.getDataTimes().length, model); //X, Y, T, Z, Channels long[] controlDimensions = {controlModel.getMesh().getSizeX(), controlModel.getMesh().getSizeY(), variables.size(), controlModel.getMesh().getSizeZ(), controlModel.getDataTimes().length}; // tests the metadata, and the metadata may be accurate but the actual raw array of data may be wrong - DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(dataSetName); + DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(n5Exporter.getN5DataSetTemplatedName(model)); long[] exportDimensions = datasetAttributes.getDimensions(); Assert.assertArrayEquals("Testing dimension results for model " + model, controlDimensions, exportDimensions); @@ -190,14 +234,15 @@ public void testRawDataEquivelance() throws IOException, DataAccessException, Ma //each block is entire XYZ, broken in time and channels for(String model: testModels){ - this.initalizeModel(model, new RawCompression()); + this.initalizeModel(model); OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); double[] times = controlModel.getDataTimes(); + makeN5Model(N5Specs.CompressionLevel.RAW, 0, times.length, model); for(int i = 0; i < variables.size(); i++){ for(int timeSlice = 0; timeSlice < times.length; timeSlice++){ - DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(dataSetName); - DataBlock dataBlock = n5Reader.readBlock(dataSetName, datasetAttributes, new long[]{0, 0, i, 0, timeSlice}); + DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(n5Exporter.getN5DataSetTemplatedName(model)); + DataBlock dataBlock = n5Reader.readBlock(n5Exporter.getN5DataSetTemplatedName(model), datasetAttributes, new long[]{0, 0, i, 0, timeSlice}); double[] exportedRawData = (double[]) dataBlock.getData(); Assert.assertArrayEquals("Equal raw data of model " + model + " with species " + variables.get(i).getName() + " with type " + variables.get(i).getVariableType() + " at time " + timeSlice, @@ -213,25 +258,26 @@ public void testRawDataEquivelance() throws IOException, DataAccessException, Ma // and random variable, this way it doesn't take forever to test @Test public void testDataCompressionEquivelance() throws MathException, IOException, DataAccessException { - ArrayList compressions = new ArrayList<>(Arrays.asList( - new Bzip2Compression(), - new GzipCompression() + ArrayList compressions = new ArrayList<>(Arrays.asList( + N5Specs.CompressionLevel.BZIP, + N5Specs.CompressionLevel.GZIP )); Random random = new Random(5); - for (Compression compression: compressions){ + for (N5Specs.CompressionLevel compression: compressions){ for(String model: testModels){ - this.initalizeModel(model, compression); - OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); + initalizeModel(model); double[] times = controlModel.getDataTimes(); - DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(dataSetName); + makeN5Model(compression, 0 , times.length, model); + OutputContext outputContext = new OutputContext(new AnnotatedFunction[0]); + DatasetAttributes datasetAttributes = n5Reader.getDatasetAttributes(n5Exporter.getN5DataSetTemplatedName(model)); for(int j = 0; j< 8; j++){ int timeSlice = random.nextInt(times.length); int chosenVariable = random.nextInt(variables.size()); - DataBlock dataBlock = n5Reader.readBlock(dataSetName, datasetAttributes, new long[]{0, 0, chosenVariable, 0, timeSlice}); + DataBlock dataBlock = n5Reader.readBlock(n5Exporter.getN5DataSetTemplatedName(model), datasetAttributes, new long[]{0, 0, chosenVariable, 0, timeSlice}); double[] exportedData = (double[]) dataBlock.getData(); - Assert.assertArrayEquals("Equal data with " + compression.getType() + " compression", + Assert.assertArrayEquals("Equal data with " + compression + " compression", controlModelController.getSimDataBlock(outputContext, this.vcDataID, variables.get(chosenVariable).getName(), times[timeSlice]).getData(), exportedData, 0); @@ -241,5 +287,7 @@ public void testDataCompressionEquivelance() throws MathException, IOException, } + // Test annotated functions, and multiple different parameters for data conversion, for multiple scans use different template file name + } diff --git a/vcell-server/src/main/java/cbit/vcell/message/server/data/SimDataServerMain.java b/vcell-server/src/main/java/cbit/vcell/message/server/data/SimDataServerMain.java index 1c1b51e2c3..347e586aa2 100644 --- a/vcell-server/src/main/java/cbit/vcell/message/server/data/SimDataServerMain.java +++ b/vcell-server/src/main/java/cbit/vcell/message/server/data/SimDataServerMain.java @@ -48,6 +48,8 @@ public static void main(String[] args) { private static final String REQUIRED_SERVICE_PROPERTIES[] = { PropertyLoader.primarySimDataDirInternalProperty, PropertyLoader.primarySimDataDirExternalProperty, + PropertyLoader.n5DataDir, + PropertyLoader.s3ProxyExternalPort, PropertyLoader.vcellServerIDProperty, PropertyLoader.installationRoot, PropertyLoader.mongodbHostInternal,