use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class PDEDataViewerPostProcess method createPostProcessPDEDataContext.
public static PostProcessDataPDEDataContext createPostProcessPDEDataContext(final ClientPDEDataContext parentPDEDataContext) throws Exception {
final DataOperationResults.DataProcessingOutputInfo dataProcessingOutputInfo = (DataOperationResults.DataProcessingOutputInfo) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputInfoOP(parentPDEDataContext.getVCDataIdentifier(), false, parentPDEDataContext.getDataManager().getOutputContext()));
if (dataProcessingOutputInfo == null) {
return null;
}
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return new DataSetController() {
// DataIdentifier[] dataIdentifiers;
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new DataAccessException("Not implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getTimeSeriesValues(timeSeriesJobSpec);
DataOperation.DataProcessingOutputTimeSeriesOP dataProcessingOutputTimeSeriesOP = new DataOperation.DataProcessingOutputTimeSeriesOP(vcdataID, timeSeriesJobSpec, outputContext, getDataSetTimes(vcdataID));
DataOperationResults.DataProcessingOutputTimeSeriesValues dataopDataProcessingOutputTimeSeriesValues = (DataOperationResults.DataProcessingOutputTimeSeriesValues) parentPDEDataContext.doDataOperation(dataProcessingOutputTimeSeriesOP);
return dataopDataProcessingOutputTimeSeriesValues.getTimeSeriesJobResults();
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataManager().getSimDataBlock(varName, time);
DataOperationResults.DataProcessingOutputDataValues dataProcessingOutputValues = (DataOperationResults.DataProcessingOutputDataValues) parentPDEDataContext.doDataOperation(new DataOperation.DataProcessingOutputDataValuesOP(vcdataID, varName, TimePointHelper.createSingleTimeTimePointHelper(time), DataIndexHelper.createAllDataIndexesDataIndexHelper(), outputContext, null));
PDEDataInfo pdeDataInfo = new PDEDataInfo(vcdataID.getOwner(), vcdataID.getID(), varName, time, Long.MIN_VALUE);
SimDataBlock simDataBlock = new SimDataBlock(pdeDataInfo, dataProcessingOutputValues.getDataValues()[0], VariableType.POSTPROCESSING);
return simDataBlock;
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// throw new DataAccessException("PostProcessData mesh not available at this level");
return null;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new DataAccessException("Remote getLineScan method should not be called for PostProcess");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return outputContext.getOutputFunctions();
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return dataProcessingOutputInfo.getVariableTimePoints();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// return parentPDEDataContext.getDataIdentifiers();
ArrayList<DataIdentifier> postProcessDataIDs = new ArrayList<DataIdentifier>();
if (outputContext != null && outputContext.getOutputFunctions() != null) {
for (int i = 0; i < outputContext.getOutputFunctions().length; i++) {
if (outputContext.getOutputFunctions()[i].isPostProcessFunction()) {
postProcessDataIDs.add(new DataIdentifier(outputContext.getOutputFunctions()[i].getName(), VariableType.POSTPROCESSING, null, false, outputContext.getOutputFunctions()[i].getDisplayName()));
}
}
}
// get 'state' variables
for (int i = 0; i < dataProcessingOutputInfo.getVariableNames().length; i++) {
if (dataProcessingOutputInfo.getPostProcessDataType(dataProcessingOutputInfo.getVariableNames()[i]).equals(PostProcessDataType.image)) {
DataIdentifier dataIdentifier = new DataIdentifier(dataProcessingOutputInfo.getVariableNames()[i], VariableType.POSTPROCESSING, null, false, dataProcessingOutputInfo.getVariableNames()[i]);
postProcessDataIDs.add(dataIdentifier);
}
}
if (postProcessDataIDs.size() > 0) {
return postProcessDataIDs.toArray(new DataIdentifier[0]);
}
return null;
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return parentPDEDataContext.doDataOperation(dataOperation);
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuMeshData(OutputContext outputContext, VCDataIdentifier vcdataID, VtuVarInfo var, double time) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public VtuVarInfo[] getVtuVarInfos(OutputContext outputContext, VCDataIdentifier vcDataIdentifier) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
}
};
VCDataManager postProcessVCDataManager = new VCDataManager(dataSetControllerProvider);
PDEDataManager postProcessPDEDataManager = new PDEDataManager(((ClientPDEDataContext) parentPDEDataContext).getDataManager().getOutputContext(), postProcessVCDataManager, parentPDEDataContext.getVCDataIdentifier());
PostProcessDataPDEDataContext postProcessDataPDEDataContext = new PostProcessDataPDEDataContext(postProcessPDEDataManager);
return postProcessDataPDEDataContext;
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class RemoteRegistrationService method sendLostPassword.
@Override
public void sendLostPassword(String userid) throws DataAccessException, RemoteProxyException {
// e.g. vcell.serverhost=vcellapi.cam.uchc.edu:8080
String serverHost = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerHost);
String[] parts = serverHost.split(":");
String host = parts[0];
int port = Integer.parseInt(parts[1]);
boolean bIgnoreCertProblems = false;
boolean bIgnoreHostMismatch = false;
VCellApiClient apiClient;
try {
apiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
} catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) {
e.printStackTrace();
throw new RemoteProxyException("failure in send lost password request: " + e.getMessage(), e);
}
try {
apiClient.sendLostPassword(userid);
} catch (Exception e) {
e.printStackTrace();
throw new RemoteProxyException("failed to request lost password: " + e.getMessage(), e);
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class SmoldynFileWriter method writeDataProcessor.
private void writeDataProcessor() throws DataAccessException, IOException, MathException, DivideByZeroException, ExpressionException {
Simulation simulation = simTask.getSimulation();
DataProcessingInstructions dpi = simulation.getDataProcessingInstructions();
if (dpi == null) {
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + DataProcessingInstructions.ROI_TIME_SERIES);
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
} else {
FieldDataIdentifierSpec fdis = dpi.getSampleImageFieldData(simulation.getVersion().getOwner());
if (fdis == null) {
throw new DataAccessException("Can't find sample image in data processing instructions");
}
File userDirectory = outputFile.getParentFile();
String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
DataSetControllerImpl dsci = new DataSetControllerImpl(null, userDirectory.getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
CartesianMesh origMesh = dsci.getMesh(fdis.getExternalDataIdentifier());
SimDataBlock simDataBlock = dsci.getSimDataBlock(null, fdis.getExternalDataIdentifier(), fdis.getFieldFuncArgs().getVariableName(), fdis.getFieldFuncArgs().getTime().evaluateConstant());
VariableType varType = fdis.getFieldFuncArgs().getVariableType();
VariableType dataVarType = simDataBlock.getVariableType();
if (!varType.equals(VariableType.UNKNOWN) && !varType.equals(dataVarType)) {
throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
}
double[] origData = simDataBlock.getData();
String filename = SimulationJob.createSimulationJobID(Simulation.createSimulationID(simulation.getKey()), simTask.getSimulationJob().getJobIndex()) + SimulationData.getDefaultFieldDataFileNameForSimulation(fdis.getFieldFuncArgs());
File fdatFile = new File(userDirectory, filename);
DataSet.writeNew(fdatFile, new String[] { fdis.getFieldFuncArgs().getVariableName() }, new VariableType[] { simDataBlock.getVariableType() }, new ISize(origMesh.getSizeX(), origMesh.getSizeY(), origMesh.getSizeZ()), new double[][] { origData });
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " begin " + dpi.getScriptName());
StringTokenizer st = new StringTokenizer(dpi.getScriptInput(), "\n\r");
while (st.hasMoreTokens()) {
String str = st.nextToken();
if (str.trim().length() > 0) {
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " " + str);
}
}
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " SampleImageFile " + fdis.getFieldFuncArgs().getVariableName() + " " + fdis.getFieldFuncArgs().getTime().infix() + " " + fdatFile);
printWriter.println(SmoldynVCellMapper.SmoldynKeyword.cmd + " " + SmoldynVCellMapper.SmoldynKeyword.B + " " + VCellSmoldynKeyword.vcellDataProcess + " end");
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class SimulationServiceImpl method computeModel.
private SimulationInfo computeModel(BioModel bioModel, SimulationSpec simSpec, ClientTaskStatusSupport statusCallback) {
try {
SimulationContext simContext = bioModel.getSimulationContext(0);
MathMappingCallback callback = new MathMappingCallbackTaskAdapter(statusCallback);
Simulation newsim = simContext.addNewSimulation(SimulationOwner.DEFAULT_SIM_NAME_PREFIX, callback, NetworkGenerationRequirements.AllowTruncatedStandardTimeout);
SimulationInfo simulationInfo = new SimulationInfo();
simulationInfo.setId(Math.abs(new Random().nextInt(1000000)));
// ----------- run simulation(s)
final File localSimDataDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
Simulation simulation = new TempSimulation(newsim, false);
final SimulationServiceContext simServiceContext = new SimulationServiceContext();
simServiceContext.simInfo = simulationInfo;
simServiceContext.simState = SimulationState.running;
simServiceContext.simTask = new SimulationTask(new SimulationJob(simulation, 0, null), 0);
simServiceContext.vcDataIdentifier = simServiceContext.simTask.getSimulationJob().getVCDataIdentifier();
simServiceContext.solver = createQuickRunSolver(localSimDataDir, simServiceContext.simTask);
simServiceContext.localSimDataDir = localSimDataDir;
if (simServiceContext.solver == null) {
throw new RuntimeException("null solver");
}
sims.put(simulationInfo.id, simServiceContext);
simServiceContext.solver.addSolverListener(new SolverListener() {
public void solverStopped(SolverEvent event) {
simServiceContext.simState = SimulationState.failed;
System.err.println("Simulation stopped");
}
public void solverStarting(SolverEvent event) {
simServiceContext.simState = SimulationState.running;
updateStatus(event);
}
public void solverProgress(SolverEvent event) {
simServiceContext.simState = SimulationState.running;
updateStatus(event);
}
public void solverPrinted(SolverEvent event) {
simServiceContext.simState = SimulationState.running;
}
public void solverFinished(SolverEvent event) {
try {
getDataSetController(simServiceContext).getDataSetTimes(simServiceContext.vcDataIdentifier);
simServiceContext.simState = SimulationState.done;
} catch (DataAccessException e) {
simServiceContext.simState = SimulationState.failed;
e.printStackTrace();
}
updateStatus(event);
}
public void solverAborted(SolverEvent event) {
simServiceContext.simState = SimulationState.failed;
System.err.println(event.getSimulationMessage().getDisplayMessage());
}
private void updateStatus(SolverEvent event) {
if (statusCallback == null)
return;
statusCallback.setMessage(event.getSimulationMessage().getDisplayMessage());
statusCallback.setProgress((int) (event.getProgress() * 100));
}
});
simServiceContext.solver.startSolver();
return simServiceContext.simInfo;
} catch (Exception e) {
e.printStackTrace(System.out);
// remember the exceptiopn ... fail the status ... save the error message
return new SimulationInfo().setId(1);
}
}
use of org.vcell.util.DataAccessException in project vcell by virtualcell.
the class TimeInterval method readVCML.
private void readVCML(CommentStringTokenizer tokens) throws DataAccessException {
try {
String token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.TimeInterval)) {
token = tokens.nextToken();
if (!token.equalsIgnoreCase(VCML.BeginBlock)) {
throw new DataAccessException("unexpected token " + token + " expecting " + VCML.BeginBlock);
}
}
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equalsIgnoreCase(VCML.EndBlock)) {
break;
} else if (token.equalsIgnoreCase(VCML.StartingTime)) {
token = tokens.nextToken();
startingTime = Double.valueOf(token);
} else if (token.equalsIgnoreCase(VCML.EndingTime)) {
token = tokens.nextToken();
endingTime = Double.valueOf(token);
} else if (token.equalsIgnoreCase(VCML.TimeStep)) {
token = tokens.nextToken();
timeStep = Double.valueOf(token);
} else if (token.equalsIgnoreCase(VCML.OutputTimeStep)) {
token = tokens.nextToken();
outputTimeStep = Double.valueOf(token);
} else {
throw new DataAccessException("unexpected identifier " + token);
}
}
} catch (Throwable e) {
e.printStackTrace(System.out);
throw new DataAccessException("line #" + (tokens.lineIndex() + 1) + " Exception: " + e.getMessage());
}
}
Aggregations