Search in sources :

Example 6 with ExportServiceImpl

use of cbit.vcell.export.server.ExportServiceImpl in project vcell by virtualcell.

the class VirtualFrapWindowManager method startExportMovie.

public ExportEvent startExportMovie(ExportSpecs exportSpecs, OutputContext outputContext, ClientTaskStatusSupport clientTaskStatusSupport) throws Exception {
    ExportEvent exportEvt = null;
    ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
    DataServerImpl dataServerImpl = new DataServerImpl(localWorkSpace.getDataSetControllerImpl(), exportServiceImpl);
    exportServiceImpl.addExportListener(new ExportListener() {

        public void exportMessage(ExportEvent event) {
            System.out.println(event.toString());
        }
    });
    // the last parameter denotes whether the saved file is comporessed or not.
    exportEvt = exportServiceImpl.makeRemoteFile(outputContext, LocalWorkspace.getDefaultOwner(), dataServerImpl, exportSpecs, false, clientTaskStatusSupport);
    return exportEvt;
}
Also used : DataServerImpl(cbit.vcell.simdata.DataServerImpl) ExportEvent(cbit.rmi.event.ExportEvent) ExportListener(cbit.rmi.event.ExportListener) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl)

Example 7 with ExportServiceImpl

use of cbit.vcell.export.server.ExportServiceImpl in project vcell by virtualcell.

the class PDEExportDataPanel method startExport.

/**
 * Comment
 */
private void startExport() {
    if (getExportSettings1().getSelectedFormat() == ExportFormat.QUICKTIME && getJSlider1().getValue() == getJSlider2().getValue()) {
        DialogUtils.showWarningDialog(this, "User selected 'begin' and 'end' export times are the same.  'Movie' export format 'begin' and 'end' times must be different");
        return;
    }
    DisplayPreferences[] displayPreferences = null;
    @SuppressWarnings("deprecation") Object[] variableSelections = getJListVariables().getSelectedValues();
    boolean selectionHasVolumeVariables = false;
    boolean selectionHasMembraneVariables = false;
    switch(getExportSettings1().getSelectedFormat()) {
        case PLY:
        case QUICKTIME:
        case GIF:
        case FORMAT_JPEG:
        case ANIMATED_GIF:
            {
                displayPreferences = new DisplayPreferences[variableSelections.length];
                StringBuffer noScaleInfoNames = new StringBuffer();
                for (int i = 0; i < displayPreferences.length; i++) {
                    BitSet domainValid = null;
                    try {
                        if (dataInfoProvider != null) {
                            DataIdentifier varSelectionDataIdnetDataIdentifier = null;
                            for (int j = 0; j < dataInfoProvider.getPDEDataContext().getDataIdentifiers().length; j++) {
                                if (dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j].getName().equals(variableSelections[i])) {
                                    varSelectionDataIdnetDataIdentifier = dataInfoProvider.getPDEDataContext().getDataIdentifiers()[j];
                                }
                            }
                            if (varSelectionDataIdnetDataIdentifier != null) {
                                selectionHasVolumeVariables = selectionHasVolumeVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.POSTPROCESSING) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.VOLUME_REGION);
                                selectionHasMembraneVariables = selectionHasMembraneVariables || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE) || varSelectionDataIdnetDataIdentifier.getVariableType().equals(VariableType.MEMBRANE_REGION);
                                CartesianMesh cartesianMesh = dataInfoProvider.getPDEDataContext().getCartesianMesh();
                                int dataLength = cartesianMesh.getDataLength(varSelectionDataIdnetDataIdentifier.getVariableType());
                                domainValid = new BitSet(dataLength);
                                domainValid.clear();
                                for (int j = 0; j < dataLength; j++) {
                                    if (dataInfoProvider.isDefined(varSelectionDataIdnetDataIdentifier, j)) {
                                        domainValid.set(j);
                                    }
                                }
                            } else {
                                throw new Exception("No DataIdentifer found for variable name '" + variableSelections[i] + "'");
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        DialogUtils.showErrorDialog(this, "Error during domain evaluation:\n" + e.getMessage());
                        return;
                    }
                    displayPreferences[i] = new DisplayPreferences(getDisplayAdapterService().getDisplayPreferences((String) variableSelections[i]), domainValid);
                    if (!getDisplayAdapterService().hasStateID((String) variableSelections[i])) {
                        noScaleInfoNames.append("--- " + (String) variableSelections[i] + "\n");
                    }
                }
                break;
            }
        case CSV:
            {
                // check for membrane variables... warn for 3D geometry...
                // one gets the whole nine yards by index, not generally useful... except for a few people like Boris :)
                boolean mbVars = false;
                DataIdentifier[] dataIDs = getPdeDataContext().getDataIdentifiers();
                for (int i = 0; i < variableSelections.length; i++) {
                    String varName = (String) variableSelections[i];
                    for (int j = 0; j < dataIDs.length; j++) {
                        if (dataIDs[j].getName().equals(varName) && dataIDs[j].getVariableType().equals(VariableType.MEMBRANE)) {
                            mbVars = true;
                            break;
                        }
                    }
                }
                if (mbVars && getPdeDataContext().getCartesianMesh().getGeometryDimension() == 3 && getJRadioButtonSlice().isSelected()) {
                    String choice = PopupGenerator.showWarningDialog(this, getDataViewerManager().getUserPreferences(), UserMessage.warn_exportMembraneData3D, null);
                    if (choice.equals(UserMessage.OPTION_CANCEL)) {
                        // user canceled
                        return;
                    }
                }
                getExportSettings1().setSimulationSelector(createSimulationSelector());
                getExportSettings1().setIsCSVExport(true);
                break;
            }
        case NRRD:
        case IMAGEJ:
        case UCD:
        case VTK_IMAGE:
        case VTK_UNSTRUCT:
            break;
        default:
            break;
    }
    ;
    if (getJRadioButtonROI().isSelected() && getROISelections().getSelectedIndex() == -1) {
        PopupGenerator.showErrorDialog(this, "To export selections, you must select at least one item from the ROI selection list");
    }
    getExportSettings1().setTimeSpecs(new TimeSpecs(getJSlider1().getValue(), getJSlider2().getValue(), getPdeDataContext().getTimePoints(), ExportConstants.TIME_RANGE));
    getExportSettings1().setDisplayPreferences(displayPreferences, Arrays.asList(variableSelections).toArray(new String[0]), viewZoom);
    getExportSettings1().setSliceCount(FormatSpecificSpecs.getSliceCount(getJRadioButtonFull().isSelected(), getNormalAxis(), getPdeDataContext().getCartesianMesh()));
    getExportSettings1().setImageSizeCalculationInfo(getPdeDataContext().getCartesianMesh(), getNormalAxis());
    getExportSettings1().setIsSmoldyn(isSmoldyn);
    ExportFormat format = getSelectedFormat();
    if (format.equals(ExportFormat.PLY)) {
        getExportSettings1().setFormatSpecificSpecs(new PLYSpecs(true, displayPreferences));
    }
    if (format.requiresFollowOn()) {
        Frame theFrame = JOptionPane.getFrameForComponent(this);
        boolean okToExport = getExportSettings1().showFormatSpecificDialog(theFrame, selectionHasVolumeVariables, selectionHasMembraneVariables);
        if (!okToExport) {
            return;
        }
    }
    if (format.equals(ExportFormat.IMAGEJ)) {
        // export nrrd for imagej direct, the we'll send to imagej from vcell client
        getExportSettings1().setFormatSpecificSpecs(new RasterSpecs(ExportConstants.NRRD_SINGLE, false));
    }
    // determine of sim result is from local (quick) run or on server.
    final OutputContext outputContext = ((ClientPDEDataContext) getPdeDataContext()).getDataManager().getOutputContext();
    final ExportSpecs exportSpecs = getExportSpecs();
    boolean isLocalSimResult = false;
    VCDataIdentifier vcId = exportSpecs.getVCDataIdentifier();
    if (vcId instanceof LocalVCDataIdentifier) {
        isLocalSimResult = true;
    }
    // find out if smoldyn export choice is 'particle' - not available at this time
    boolean isParticle = false;
    if (getExportSettings1().getFormatSpecificSpecs() instanceof ImageSpecs) {
        isParticle = ((ImageSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
    } else if (getExportSettings1().getFormatSpecificSpecs() instanceof MovieSpecs) {
        isParticle = ((MovieSpecs) getExportSettings1().getFormatSpecificSpecs()).getParticleMode() == FormatSpecificSpecs.PARTICLE_SELECT;
    }
    if (isLocalSimResult && isParticle) {
        DialogUtils.showErrorDialog(this, "Particle export for Smoldyn particles unavailable in local data at this time.");
        return;
    }
    // pass the export request down the line; non-blocking call
    if (!isLocalSimResult) {
        // for sims that ran on server, do as before.
        getDataViewerManager().startExport(this, outputContext, exportSpecs);
    } else {
        final String SOURCE_FILE_KEY = "SOURCE_FILE_KEY";
        final String DESTINATION_FILE_KEY = "DEESTINATION_FILE_KEY";
        AsynchClientTask localExportTast = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                try {
                    File primaryDir = ResourceUtil.getLocalRootDir();
                    User usr = User.tempUser;
                    File usrDir = new File(primaryDir.getAbsolutePath(), usr.getName());
                    System.setProperty(PropertyLoader.exportBaseDirInternalProperty, usrDir.getAbsolutePath() + File.separator);
                    System.setProperty(PropertyLoader.exportBaseURLProperty, usrDir.toURI().toURL().toString());
                    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
                    ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
                    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, localExportServiceImpl);
                    ExportEvent localExportEvent = dataServerImpl.makeRemoteFile(outputContext, usr, exportSpecs);
                    File sourceFile = new File(usrDir, new File((new URL(localExportEvent.getLocation()).getPath())).getName());
                    hashTable.put(SOURCE_FILE_KEY, sourceFile);
                } catch (Exception e) {
                    throw new Exception("Unable to export local sim results data : " + e.getMessage(), e);
                }
            }
        };
        AsynchClientTask localSaveTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
                JFileChooser jFileChooser = new JFileChooser();
                jFileChooser.setSelectedFile(new File(sourceFile.getName()));
                if (jFileChooser.showSaveDialog(PDEExportDataPanel.this) == JFileChooser.APPROVE_OPTION) {
                    File destinationFile = jFileChooser.getSelectedFile();
                    if (destinationFile.exists()) {
                        final String OVERWRITE = "Overwrite";
                        final String CANCEL = "Cancel";
                        String response = DialogUtils.showWarningDialog(PDEExportDataPanel.this, "OK to Overwrite " + destinationFile.getAbsolutePath() + "?", new String[] { OVERWRITE, CANCEL }, OVERWRITE);
                        if (response == null || !response.equals(OVERWRITE)) {
                            return;
                        }
                    }
                    hashTable.put(DESTINATION_FILE_KEY, destinationFile);
                }
            }
        };
        AsynchClientTask localDeleteTempTask = new AsynchClientTask("Start Local Export", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING, false, false) {

            @Override
            public void run(Hashtable<String, Object> hashTable) throws Exception {
                File sourceFile = (File) hashTable.get(SOURCE_FILE_KEY);
                File destinationFile = (File) hashTable.get(DESTINATION_FILE_KEY);
                if (sourceFile != null && sourceFile.exists()) {
                    try {
                        if (destinationFile != null) {
                            copyFile(sourceFile, destinationFile);
                        }
                    } finally {
                        sourceFile.delete();
                    }
                }
            }
        };
        ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { localExportTast, localSaveTask, localDeleteTempTask }, false, true, null);
    }
}
Also used : DataServerImpl(cbit.vcell.simdata.DataServerImpl) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) User(org.vcell.util.document.User) RasterSpecs(cbit.vcell.export.server.RasterSpecs) ExportSpecs(cbit.vcell.export.server.ExportSpecs) ExportEvent(cbit.rmi.event.ExportEvent) URL(java.net.URL) DisplayPreferences(cbit.image.DisplayPreferences) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) TimeSpecs(cbit.vcell.export.server.TimeSpecs) Hashtable(java.util.Hashtable) PLYSpecs(cbit.vcell.export.server.PLYSpecs) BitSet(java.util.BitSet) ExportFormat(cbit.vcell.export.server.ExportFormat) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) IOException(java.io.IOException) UserCancelException(org.vcell.util.UserCancelException) OutputContext(cbit.vcell.simdata.OutputContext) CartesianMesh(cbit.vcell.solvers.CartesianMesh) MovieSpecs(cbit.vcell.export.server.MovieSpecs) JFileChooser(javax.swing.JFileChooser) ImageSpecs(cbit.vcell.export.server.ImageSpecs) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) LocalVCDataIdentifier(org.vcell.util.document.LocalVCDataIdentifier) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) File(java.io.File)

Example 8 with ExportServiceImpl

use of cbit.vcell.export.server.ExportServiceImpl in project vcell by virtualcell.

the class VCellClientDataServiceImpl method getVCSimulationDataIdentifier.

public VCSimulationDataIdentifier getVCSimulationDataIdentifier(SimulationDataSetRef simulationDataSetRef) throws FileNotFoundException {
    User user = new User(simulationDataSetRef.getUsername(), new KeyValue(simulationDataSetRef.getUserkey()));
    KeyValue simKeyValue = new KeyValue(simulationDataSetRef.getSimId());
    VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simKeyValue, user);
    if (simulationDataSetRef.isIsLocal()) {
        File primaryDir = ResourceUtil.getLocalRootDir();
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(null, primaryDir, null);
        ExportServiceImpl localExportServiceImpl = new ExportServiceImpl();
        LocalDataSetControllerProvider localDSCProvider = new LocalDataSetControllerProvider(user, dataSetControllerImpl, localExportServiceImpl);
        VCDataManager vcDataManager = new VCDataManager(localDSCProvider);
        File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
        VCSimulationDataIdentifier simulationDataIdentifier = new LocalVCSimulationDataIdentifier(vcSimulationIdentifier, 0, localSimDir);
        return simulationDataIdentifier;
    } else {
        VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, simulationDataSetRef.getJobIndex());
        return vcSimulationDataIdentifier;
    }
}
Also used : LocalDataSetControllerProvider(cbit.vcell.client.LocalDataSetControllerProvider) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) File(java.io.File) VCDataManager(cbit.vcell.simdata.VCDataManager) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) LocalVCSimulationDataIdentifier(cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier)

Example 9 with ExportServiceImpl

use of cbit.vcell.export.server.ExportServiceImpl in project vcell by virtualcell.

the class VtkMeshGenerator method generateVtkMeshes.

private void generateVtkMeshes(User owner, KeyValue simKey, int jobIndex) throws DataAccessException, IOException {
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
    VCSimulationDataIdentifier vcdataID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
    Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20);
    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
    ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
    // @SuppressWarnings("unused")
    if (!dataSetControllerImpl.getIsMovingBoundary(vcdataID)) {
        // 
        // precompute single static vtk mesh
        // 
        VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, 0);
    } else {
        // 
        // precompute static vtk mesh for each saved time point
        // 
        double[] times = dataServerImpl.getDataSetTimes(owner, vcdataID);
        for (int i = 0; i < times.length; i++) {
            VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, i);
        }
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) File(java.io.File)

Example 10 with ExportServiceImpl

use of cbit.vcell.export.server.ExportServiceImpl in project vcell by virtualcell.

the class LocalVCellConnectionFactory method createVCellConnection.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.server.VCellConnection
 */
public VCellConnection createVCellConnection() throws AuthenticationException, ConnectionException {
    try {
        if (connectionFactory == null) {
            connectionFactory = DatabaseService.getInstance().createConnectionFactory();
        }
        KeyFactory keyFactory = connectionFactory.getKeyFactory();
        LocalVCellConnection.setDatabaseResources(connectionFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(connectionFactory);
        boolean bEnableRetry = false;
        boolean isLocal = true;
        User user = adminDbTopLevel.getUser(userLoginInfo.getUserName(), userLoginInfo.getDigestedPassword(), bEnableRetry, isLocal);
        if (user != null) {
            userLoginInfo.setUser(user);
        } else {
            throw new AuthenticationException("failed to authenticate as user " + userLoginInfo.getUserName());
        }
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(connectionFactory, keyFactory);
        boolean bCache = false;
        Cachetable cacheTable = null;
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
        SimulationDatabaseDirect simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, bCache);
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        LocalVCellConnection vcConn = new LocalVCellConnection(userLoginInfo, simulationDatabase, dataSetControllerImpl, exportServiceImpl);
        linkHDFLib();
        return vcConn;
    } catch (Throwable exc) {
        lg.error(exc.getMessage(), exc);
        throw new ConnectionException(exc.getMessage());
    }
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) User(org.vcell.util.document.User) AuthenticationException(org.vcell.util.AuthenticationException) SimulationDatabaseDirect(cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) File(java.io.File) KeyFactory(org.vcell.db.KeyFactory) ConnectionException(cbit.vcell.server.ConnectionException)

Aggregations

ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)10 File (java.io.File)8 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)7 DataServerImpl (cbit.vcell.simdata.DataServerImpl)5 User (org.vcell.util.document.User)5 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)4 ExportEvent (cbit.rmi.event.ExportEvent)3 Cachetable (cbit.vcell.simdata.Cachetable)3 VCDataManager (cbit.vcell.simdata.VCDataManager)3 ExportListener (cbit.rmi.event.ExportListener)2 LocalVCSimulationDataIdentifier (cbit.vcell.client.ClientSimManager.LocalVCSimulationDataIdentifier)2 LocalDataSetControllerProvider (cbit.vcell.client.LocalDataSetControllerProvider)2 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 VCMessagingService (cbit.vcell.message.VCMessagingService)2 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)2 ServiceInstanceStatus (cbit.vcell.message.server.ServiceInstanceStatus)2 SimulationDatabaseDirect (cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect)2 VtkManager (cbit.vcell.simdata.VtkManager)2 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 Date (java.util.Date)2