Search in sources :

Example 31 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class MathModelWindowManager method checkValidSimulationDataViewerFrames.

/**
 * Insert the method's description here.
 * Creation date: (7/20/2004 1:13:06 PM)
 */
private void checkValidSimulationDataViewerFrames() {
    SimulationWindow[] simWindows = (SimulationWindow[]) BeanUtils.getArray(simulationWindowsHash.elements(), SimulationWindow.class);
    Simulation[] sims = getMathModel().getSimulations();
    Hashtable<VCSimulationIdentifier, Simulation> hash = new Hashtable<VCSimulationIdentifier, Simulation>();
    for (int i = 0; i < sims.length; i++) {
        SimulationInfo simInfo = sims[i].getSimulationInfo();
        if (simInfo != null) {
            VCSimulationIdentifier vcSimulationIdentifier = simInfo.getAuthoritativeVCSimulationIdentifier();
            hash.put(vcSimulationIdentifier, sims[i]);
        }
    }
    for (int i = 0; i < simWindows.length; i++) {
        if (hash.containsKey(simWindows[i].getVcSimulationIdentifier())) {
            simWindows[i].resetSimulation((Simulation) hash.get(simWindows[i].getVcSimulationIdentifier()));
        } else {
            ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getJPanel());
            ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindows[i]);
            if (childWindow != null) {
                childWindow.close();
            }
        }
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Simulation(cbit.vcell.solver.Simulation) Hashtable(java.util.Hashtable) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 32 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class TopLevelWindowManager method prepareDocumentToLoad.

public void prepareDocumentToLoad(VCDocument doc, boolean bInNewWindow) throws Exception {
    if (doc instanceof BioModel) {
        Simulation[] simulations = ((BioModel) doc).getSimulations();
        ArrayList<VCSimulationIdentifier> simIDs = new ArrayList<VCSimulationIdentifier>();
        for (int i = 0; i < simulations.length; i++) {
            SimulationInfo simulationInfo = simulations[i].getSimulationInfo();
            if (simulationInfo != null) {
                simIDs.add(simulationInfo.getAuthoritativeVCSimulationIdentifier());
            }
        }
        RequestManager rm = getRequestManager();
        ConnectionStatus stat = rm.getConnectionStatus();
        if (stat.getStatus() == ConnectionStatus.CONNECTED) {
            rm.getDocumentManager().preloadSimulationStatus(simIDs.toArray(new VCSimulationIdentifier[0]));
        }
    } else if (doc instanceof MathModel) {
        Geometry geometry = ((MathModel) doc).getMathDescription().getGeometry();
        geometry.precomputeAll(new GeometryThumbnailImageFactoryAWT());
        Simulation[] simulations = ((MathModel) doc).getSimulations();
        // VCSimulationIdentifier simIDs[] = new VCSimulationIdentifier[simulations.length];
        ArrayList<VCSimulationIdentifier> simIDs = new ArrayList<>();
        for (int i = 0; i < simulations.length; i++) {
            if (simulations[i].getSimulationInfo() != null) {
                simIDs.add(simulations[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier());
            }
        }
        getRequestManager().getDocumentManager().preloadSimulationStatus(simIDs.toArray(new VCSimulationIdentifier[0]));
    } else if (doc instanceof Geometry) {
        ((Geometry) doc).precomputeAll(new GeometryThumbnailImageFactoryAWT());
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) MathModel(cbit.vcell.mathmodel.MathModel) ArrayList(java.util.ArrayList) Geometry(cbit.vcell.geometry.Geometry) GeometryThumbnailImageFactoryAWT(cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) ConnectionStatus(cbit.vcell.client.server.ConnectionStatus) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 33 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class ApplicationComponents method cleanSimWindowsHash.

/**
 * Remove server side sim results windows that are no longer in use
 */
public void cleanSimWindowsHash() {
    Iterator<Entry<VCSimulationIdentifier, SimulationWindow>> iter = simulationWindowsHash.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<VCSimulationIdentifier, SimulationWindow> es = iter.next();
        SimulationWindow sw = es.getValue();
        if (!sw.isShowingLocalSimulation()) {
            VCSimulationIdentifier vcsid = es.getKey();
            Simulation[] sims = simulationWorkspace.getSimulations();
            boolean bFound = false;
            for (int i = 0; i < sims.length; i += 1) {
                if (sims[i].getSimulationInfo() != null && sims[i].getSimulationInfo().getAuthoritativeVCSimulationIdentifier().equals(vcsid)) {
                    bFound = true;
                    break;
                }
            }
            if (!bFound) {
                iter.remove();
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Simulation(cbit.vcell.solver.Simulation) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow)

Example 34 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class ChomboSimpleDataViewer method retrieveVariablesAndTimes.

private void retrieveVariablesAndTimes() {
    AsynchClientTask task0 = new AsynchClientTask("clear", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            DefaultComboBoxModel dcm = new DefaultComboBoxModel();
            timeComboBox.setModel(dcm);
            DefaultListModel dlm = new DefaultListModel();
            varList.setModel(dlm);
            solTableModel.clear();
            meshMetricsTableModel.clear();
            meanTextField.setText(null);
            maxErrorTextField.setText(null);
            sumVolFracTextField.setText(null);
            l2ErrorTextField.setText(null);
        }
    };
    AsynchClientTask task1 = new AsynchClientTask("retrieve data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            String simId = simIdField.getText().trim();
            if (simId == null || simId.length() == 0) {
                throw new RuntimeException("Please provide a simulation id.");
            }
            String username = userNameTextField.getText().trim();
            if (username == null || username.length() == 0) {
                throw new RuntimeException("Please provide a user name.");
            }
            VCSimulationDataIdentifier vcDataId = new VCSimulationDataIdentifier(new VCSimulationIdentifier(new KeyValue(simId), new User(username, null)), 0);
            SimDataInfoHolder simDataInfoHolder = null;
            String datadir = dataDirTextField.getText();
            if (datadir == null || datadir.length() == 0) {
                simDataInfoHolder = createSimulationDataFromRemote(username, vcDataId);
                datadir = simDataInfoHolder.userDir.getParent();
                dataDirTextField.setText(datadir);
            } else {
                simDataInfoHolder = createSimulationDataFromDir(new File(datadir), username, vcDataId);
            }
            simData = simDataInfoHolder.simData;
            simData.readVarAndFunctionDataIdentifiers();
            usernames.add(username);
            userNameTextField.setAutoCompletionWords(usernames);
            datadirs.add(datadir);
            dataDirTextField.setAutoCompletionWords(datadirs);
            simIds.add(simId);
            simIdField.setAutoCompletionWords(simIds);
        }
    };
    AsynchClientTask task2 = new AsynchClientTask("show data", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            double[] times = simData.getDataTimes();
            DefaultComboBoxModel dcm = new DefaultComboBoxModel();
            for (double t : times) {
                dcm.addElement(t);
            }
            timeComboBox.setModel(dcm);
            meshMetricsTableModel.setData(simData.getChomboMesh().getMetricsColumnNames(), simData.getChomboMesh().getMetricsNumbers());
            List<DataSetIdentifier> dsiList = simData.getDataSetIdentifiers();
            DefaultListModel dlm = new DefaultListModel();
            for (DataSetIdentifier dsi : dsiList) {
                dlm.addElement(dsi);
            }
            varList.setModel(dlm);
            if (times.length > 0) {
                timeComboBox.setSelectedIndex(0);
            }
            if (dsiList.size() > 0) {
                varList.setSelectedIndex(0);
            }
            meshMetricsTableModel.refreshTable();
        }
    };
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), new AsynchClientTask[] { task0, task1, task2 }, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Hashtable(java.util.Hashtable) DataSetIdentifier(cbit.vcell.simdata.DataSetIdentifier) DefaultListModel(javax.swing.DefaultListModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) File(java.io.File)

Example 35 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier 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)

Aggregations

VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)59 KeyValue (org.vcell.util.document.KeyValue)37 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)27 User (org.vcell.util.document.User)20 File (java.io.File)17 Simulation (cbit.vcell.solver.Simulation)16 BigString (org.vcell.util.BigString)14 UserLoginInfo (org.vcell.util.document.UserLoginInfo)11 BioModel (cbit.vcell.biomodel.BioModel)10 Hashtable (java.util.Hashtable)10 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)9 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)9 SQLException (java.sql.SQLException)7 CartesianMesh (cbit.vcell.solvers.CartesianMesh)6 FileNotFoundException (java.io.FileNotFoundException)6 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 VCMessageSession (cbit.vcell.message.VCMessageSession)5 VCellConnection (cbit.vcell.server.VCellConnection)5 XMLSource (cbit.vcell.xml.XMLSource)5