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());
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class VCellClientDataServiceImpl method displayPostProcessingDataInVCell.
@Override
public void displayPostProcessingDataInVCell(SimulationDataSetRef simulationDataSetRef) throws NumberFormatException, DataAccessException {
User vcUser = vcellClient.getRequestManager().getDocumentManager().getUser();
VCSimulationIdentifier vcSimId = new VCSimulationIdentifier(new KeyValue(simulationDataSetRef.getSimId()), vcUser);
ClientDocumentManager clientDocumentManager = (ClientDocumentManager) vcellClient.getClientServerManager().getDocumentManager();
SimulationOwner simulationOwner = null;
if (simulationDataSetRef.isMathModel) {
simulationOwner = clientDocumentManager.getMathModel(new KeyValue(simulationDataSetRef.getModelId()));
} else {
BioModel bioModel = clientDocumentManager.getBioModel(new KeyValue(simulationDataSetRef.getModelId()));
simulationOwner = bioModel.getSimulationContext(simulationDataSetRef.getSimulationContextName());
}
ArrayList<AnnotatedFunction> outputFunctionsList = simulationOwner.getOutputFunctionContext().getOutputFunctionsList();
OutputContext outputContext = new OutputContext(outputFunctionsList.toArray(new AnnotatedFunction[outputFunctionsList.size()]));
VCSimulationDataIdentifier vcSimDataId = new VCSimulationDataIdentifier(vcSimId, simulationDataSetRef.getJobIndex());
PDEDataManager pdeDataManager = (PDEDataManager) vcellClient.getRequestManager().getDataManager(outputContext, vcSimDataId, true);
final ClientPDEDataContext newClientPDEDataContext = pdeDataManager.getPDEDataContext();
// this was the code before the windows refactoring; appears to just always get the first window???
// Enumeration<TopLevelWindowManager> windowManagers = vcellClient.getMdiManager().getWindowManagers();
// final Window window = FindWindow.getWindow(windowManagers.nextElement().getComponent());
Optional<TopLevelWindowManager> first = vcellClient.getMdiManager().getWindowManagers().stream().findFirst();
VCAssert.assertTrue(first.isPresent(), "window manager not present?");
final Window window = getWindow(first.get().getComponent());
AsynchClientTask task = new AsynchClientTask("Display Post Processing Statistics", AsynchClientTask.TASKTYPE_SWING_NONBLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
DataProcessingResultsPanel dataProcessingResultsPanel = new DataProcessingResultsPanel();
dataProcessingResultsPanel.update(newClientPDEDataContext);
DialogUtils.showComponentOKCancelDialog(window, dataProcessingResultsPanel, "Post Processing Statistics");
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
Vector<AsynchClientTask> tasksV = new Vector<AsynchClientTask>();
tasksV.add(task);
AsynchClientTask[] tasks = new AsynchClientTask[tasksV.size()];
tasksV.copyInto(tasks);
ClientTaskDispatcher.dispatch(window, hash, tasks, true);
}
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;
}
}
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();
}
}
}
}
Aggregations