use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class ROIMultiPaintManager method createFD.
private void createFD(boolean isFromSimulation, String fieldName, String annotation, Extent extent, Origin origin, String[] varNames, double[] times, ISize isize) throws Exception {
FieldDataFileOperationSpec fdos = null;
try {
// temp-------
FieldDataDBOperationSpec listExtDataIDSpec = FieldDataDBOperationSpec.createGetExtDataIDsSpec(documentManager.getUser());
FieldDataDBOperationResults fdDBOperation = documentManager.fieldDataDBOperation(listExtDataIDSpec);
for (int i = 0; i < fdDBOperation.extDataIDArr.length; i++) {
if (fdDBOperation.extDataIDArr[i].getName().equals("fd")) {
FieldDataDBOperationSpec createDeleteExtDataIDSpec = FieldDataDBOperationSpec.createDeleteExtDataIDSpec(fdDBOperation.extDataIDArr[i]);
documentManager.fieldDataDBOperation(createDeleteExtDataIDSpec);
break;
}
}
//
// -----------
FieldDataDBOperationSpec newExtDataIDSpec = FieldDataDBOperationSpec.createSaveNewExtDataIDSpec(documentManager.getUser(), fieldName, annotation);
FieldDataDBOperationResults fieldDataDBOperation = documentManager.fieldDataDBOperation(newExtDataIDSpec);
fdos = new FieldDataFileOperationSpec();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
fdos.owner = documentManager.getUser();
fdos.isize = isize;
fdos.shortSpecData = new short[1][1][fdos.isize.getXYZ()];
UShortImage[] allImages = initImageDataSetChannels[0].getAllImages();
for (int i = 0; i < allImages.length; i++) {
allImages[i].getPixels();
System.arraycopy(allImages[i].getPixels(), 0, fdos.shortSpecData[0][0], i * allImages[i].getPixels().length, allImages[i].getPixels().length);
}
fdos.specEDI = fieldDataDBOperation.extDataID;
fdos.annotation = annotation;
if (!isFromSimulation) {
fdos.extent = extent;
fdos.origin = origin;
fdos.varNames = varNames;
fdos.times = times;
//
// Subvolumes and Regions NOT implemented now
//
fdos.cartesianMesh = CartesianMesh.createSimpleCartesianMesh(fdos.origin, fdos.extent, fdos.isize, new RegionImage(new // empty regions
VCImageUncompressed(// empty regions
null, // empty regions
new byte[fdos.isize.getXYZ()], fdos.extent, fdos.isize.getX(), fdos.isize.getY(), fdos.isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
}
// Add to Server Disk
documentManager.fieldDataFileOperation(fdos);
// //Update FieldData window
// Window[] windows = Window.getWindows();
// for(int i=0;i<windows.length;i++) {
// if(windows[i] instanceof FieldDataWindow) {
// ((FieldDataWindow)windows[i]).getFieldDataWindowManger().fieldDataDBEvent(new FieldDataDBEvent(ROIMultiPaintManager.this));
// break;
// }
// }
} catch (Exception e) {
try {
// try to cleanup new ExtDataID
if (fdos != null && fdos.specEDI != null) {
documentManager.fieldDataDBOperation(FieldDataDBOperationSpec.createDeleteExtDataIDSpec(fdos.specEDI));
}
} catch (Exception e2) {
e2.printStackTrace();
}
throw e;
}
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class DataSymbolsPanel method addVFrapOriginalImages.
private void addVFrapOriginalImages() {
// add dataset (normal images) from vFrap
AsynchClientTask[] taskArray = new AsynchClientTask[5];
// select the desired vfrap file
taskArray[0] = ChooseVFrapFile();
taskArray[1] = new AsynchClientTask("Import objects", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
File vFrapFile = (File) hashTable.get("vFrapFile");
Component requesterComponent = DataSymbolsPanel.this;
DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
if (documentManager == null) {
throw new RuntimeException("Not connected to server.");
}
// ex ccc8.vfrap
String vFrapFileNameExtended = vFrapFile.getName();
{
// we want to make sure to reload these strings from the hash later on
String initialFieldDataName = vFrapFileNameExtended.substring(0, vFrapFileNameExtended.indexOf(".vfrap"));
// we'll save here the "special" vFrap images (prebleach_avg, ...)
String mixedFieldDataName = initialFieldDataName + "Mx";
hashTable.put("initialFieldDataName", initialFieldDataName);
hashTable.put("mixedFieldDataName", mixedFieldDataName);
}
if (vFrapFileNameExtended.indexOf(".vfrap") <= -1) {
throw new RuntimeException("File extension must be .vfrap");
}
// normal images
checkNameAvailability(hashTable, false, documentManager, requesterComponent);
// ----- read needed info from Virtual FRAP xml file
System.out.println("Loading " + vFrapFileNameExtended + " ...");
String xmlString = XmlUtil.getXMLString(vFrapFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
Element vFrapRoot = XmlUtil.stringToXML(xmlString, null).getRootElement();
// loading frap images
AnnotatedImageDataset annotatedImages = xmlReader.getAnnotatedImageDataset(vFrapRoot, null);
hashTable.put("annotatedImages", annotatedImages);
// loading ROIs for display purposes only (see next task)
ROI[] rois = xmlReader.getPrimaryROIs(XmlUtil.stringToXML(xmlString, null).getRootElement(), null);
LoadVFrapDisplayRoi(hashTable, annotatedImages, rois);
// Calendar cal = Calendar.getInstance();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_hhmmss");
// DocumentWindow documentWindow = (DocumentWindow)BeanUtils.findTypeParentOfComponent(DataSymbolsPanel.this, DocumentWindow.class);
// DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
// VFrapXmlHelper vFrapXmlHelper = new VFrapXmlHelper();
// if(vFrapXmlHelper.isAlreadyImported(vFrapFileName, documentManager)) {
// throw new RuntimeException("FieldData name already in use.");
// }
// // bioModel.setName(vFrapFileName + "-" + sdf.format(cal.getTime()));
// bioModel.setName(vFrapFileName);
// BioModel feedbackModel = documentManager.save(bioModel, null);
// BioModelChildSummary childSummary = BioModelChildSummary.fromDatabaseSerialization(xmlString);
// BioModelInfo biomodelInfo = new BioModelInfo(feedbackModel.getVersion(), feedbackModel.getVersion().getVersionKey(), childSummary );
// documentWindow.getTopLevelWindowManager().getRequestManager().openDocument(biomodelInfo, documentWindow.getTopLevelWindowManager(), true);
}
};
// show the images from the vfrap file in an OverlayEditorPanelJAI dialog
taskArray[2] = new AsynchClientTask("Display images", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
if (initialFieldDataName.equals("")) {
JOptionPane.showMessageDialog(DataSymbolsPanel.this, "Field Data name " + initialFieldDataName + " already in use.");
// prevents the rest of tasks below from running
throw UserCancelException.CANCEL_GENERIC;
}
AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset) hashTable.get("annotatedImages");
BufferedImage[] displayROI = (BufferedImage[]) hashTable.get("displayROI");
if (annotatedImages == null || displayROI == null) {
return;
}
// display the images
OverlayEditorPanelJAI overlayPanel = new OverlayEditorPanelJAI();
overlayPanel.setAllowAddROI(false);
ImageDataset imageDataset = annotatedImages.getImageDataset();
overlayPanel.setImages(imageDataset, 1, 0, new OverlayEditorPanelJAI.AllPixelValuesRange(1, 200));
overlayPanel.setAllROICompositeImage(displayROI, OverlayEditorPanelJAI.FRAP_DATA_INIT_PROPERTY);
int choice = DialogUtils.showComponentOKCancelDialog(DataSymbolsPanel.this, overlayPanel, "vFrap Field Data");
if (choice != JOptionPane.OK_OPTION) {
throw UserCancelException.CANCEL_GENERIC;
}
}
};
// save the timepoints from memory to the database as field data
taskArray[3] = new AsynchClientTask("Saving time series data", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
AnnotatedImageDataset annotatedImages = (AnnotatedImageDataset) hashTable.get("annotatedImages");
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(DataSymbolsPanel.this, DocumentWindow.class);
DocumentManager dm = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
if (dm == null) {
throw new RuntimeException("Not connected to server.");
}
User owner = null;
Version version = simulationContext.getVersion();
if (version == null) {
// new document, so the owner is the user
owner = dm.getUser();
} else {
owner = simulationContext.getVersion().getOwner();
}
// mesh
ImageDataset imageDataset = annotatedImages.getImageDataset();
Extent extent = imageDataset.getExtent();
ISize isize = imageDataset.getISize();
Origin origin = new Origin(0, 0, 0);
CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
// save field data
int NumTimePoints = imageDataset.getImageTimeStamps().length;
int NumChannels = 1;
double[][][] pixData = new double[NumTimePoints][NumChannels][];
for (int i = 0; i < NumTimePoints; i++) {
// images according to zIndex at specific time points(tIndex)
short[] originalData = imageDataset.getPixelsZ(0, i);
double[] doubleData = new double[originalData.length];
for (int j = 0; j < originalData.length; j++) {
doubleData[j] = 0x0000ffff & originalData[j];
}
pixData[i][NumChannels - 1] = doubleData;
}
FieldDataFileOperationSpec timeSeriesFieldDataOpSpec = new FieldDataFileOperationSpec();
timeSeriesFieldDataOpSpec.opType = FieldDataFileOperationSpec.FDOS_ADD;
timeSeriesFieldDataOpSpec.cartesianMesh = cartesianMesh;
timeSeriesFieldDataOpSpec.doubleSpecData = pixData;
timeSeriesFieldDataOpSpec.specEDI = null;
timeSeriesFieldDataOpSpec.varNames = new String[] { SimulationContext.FLUOR_DATA_NAME };
timeSeriesFieldDataOpSpec.owner = owner;
timeSeriesFieldDataOpSpec.times = imageDataset.getImageTimeStamps();
timeSeriesFieldDataOpSpec.variableTypes = new VariableType[] { VariableType.VOLUME };
timeSeriesFieldDataOpSpec.origin = origin;
timeSeriesFieldDataOpSpec.extent = extent;
timeSeriesFieldDataOpSpec.isize = isize;
// realignment for the case when first timepoint is not zero
if (timeSeriesFieldDataOpSpec.times[0] != 0) {
double shift = timeSeriesFieldDataOpSpec.times[0];
for (int i = 0; i < NumTimePoints; i++) {
timeSeriesFieldDataOpSpec.times[i] -= shift;
}
}
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyMMMdd_hhmmss");
String formattedDate = sdf.format(cal.getTime());
hashTable.put("formattedDate", formattedDate);
// ExternalDataIdentifier timeSeriesEDI = dm.saveFieldData(timeSeriesFieldDataOpSpec,
// initialFieldDataName + "_" + formattedDate);
ExternalDataIdentifier timeSeriesEDI = dm.saveFieldData(timeSeriesFieldDataOpSpec, initialFieldDataName);
hashTable.put("imageDataset", imageDataset);
hashTable.put("timeSeriesEDI", timeSeriesEDI);
}
};
// create the data symbols for the images saved above and display them in the tree/table
taskArray[4] = new AsynchClientTask("Display Data Symbols", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// --- create the data symbols associated with the time series
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
ImageDataset imageDataset = (ImageDataset) hashTable.get("imageDataset");
ExternalDataIdentifier timeSeriesEDI = (ExternalDataIdentifier) hashTable.get("timeSeriesEDI");
for (double time : imageDataset.getImageTimeStamps()) {
// String fluorName = TokenMangler.fixTokenStrict("fluor_"+time+"_");
// while (simulationContext.getDataContext().getDataSymbol(fluorName)!=null){
// fluorName = TokenMangler.getNextEnumeratedToken(fluorName);
// }
// max time interval we can display is about 11 days
DecimalFormat df = new DecimalFormat("###000.00");
// String fluorName = "fluor_" + df.format(time) + "_" + formattedDate;
String fluorName = "fluor_" + df.format(time).substring(0, df.format(time).indexOf(".")) + "s" + df.format(time).substring(1 + df.format(time).indexOf(".")) + "_" + initialFieldDataName;
// FieldFunctionArguments fluorFFArgs = new FieldFunctionArguments(timeSeriesEDI.getName(), fluorName, new Expression(time), VariableType.VOLUME);
DataSymbol fluorDataSymbol = new FieldDataSymbol(fluorName, DataSymbolType.VFRAP_TIMEPOINT, simulationContext.getDataContext(), simulationContext.getModel().getUnitSystem().getInstance_TBD(), timeSeriesEDI, SimulationContext.FLUOR_DATA_NAME, VariableType.VOLUME.getTypeName(), time);
simulationContext.getDataContext().addDataSymbol(fluorDataSymbol);
}
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, taskArray, false, true, null);
// String name = null;
// try {
// getNewDataSymbolPanel().setSymbolName("");
// getNewDataSymbolPanel().setSymbolExpression("vcField(dataset1,var1,0.0,Volume)");
// int newSettings = org.vcell.util.gui.DialogUtils.showComponentOKCancelDialog(this, getNewDataSymbolPanel(), "New DataSymbol");
// if (newSettings == JOptionPane.OK_OPTION) {
// name = getNewDataSymbolPanel().getSymbolName();
// String expression = getNewDataSymbolPanel().getSymbolExpression();
// Expression exp = new Expression(expression);
// FunctionInvocation[] functionInvocations = exp.getFunctionInvocations(null);
// // DataSymbol ds = new FieldDataSymbol(DataSymbolType.GENERIC_SYMBOL, name, "",
// // simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD,
// // new FieldFunctionArguments(functionInvocations[0]));
// DataSymbol ds = new FieldDataSymbol(name, DataSymbolType.GENERIC_SYMBOL,
// simulationContext.getDataContext(), VCUnitDefinition.UNIT_TBD);
// simulationContext.getDataContext().addDataSymbol(ds);
// }
// } catch (java.lang.Throwable ivjExc) {
// DialogUtils.showErrorDialog(this, "Data symbol " + name + " already exists");
// }
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class PointSpreadFunctionManagement method importPointSpreadFunction.
public void importPointSpreadFunction() {
AsynchClientTask[] taskArray = new AsynchClientTask[3];
// select the desired PSF file
taskArray[0] = new AsynchClientTask("Select a file", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
ChoosePSFFile(hashTable);
}
};
// create and save the field data object
taskArray[1] = new AsynchClientTask("Import objects", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
Component requesterComponent = parentWindow;
DocumentWindow documentWindow = (DocumentWindow) BeanUtils.findTypeParentOfComponent(requesterComponent, DocumentWindow.class);
DocumentManager documentManager = documentWindow.getTopLevelWindowManager().getRequestManager().getDocumentManager();
if (documentManager == null) {
throw new RuntimeException("Not connected to server.");
}
// the following line of code may modify initialFieldDataName
// normal file name
checkNameAvailability(hashTable, false, documentManager, requesterComponent);
File filePSF = (File) hashTable.get("filePSF");
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
ImageDataset imageDataset = ImageDatasetReaderService.getInstance().getImageDatasetReader().readImageDataset(filePSF.getAbsolutePath(), null);
Extent extent = imageDataset.getExtent();
ISize isize = imageDataset.getISize();
Origin origin = new Origin(0, 0, 0);
CartesianMesh cartesianMesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, isize, new RegionImage(new VCImageUncompressed(null, new byte[isize.getXYZ()], extent, isize.getX(), isize.getY(), isize.getZ()), 0, null, null, RegionImage.NO_SMOOTHING));
// save field data
int NumTimePoints = imageDataset.getImageTimeStamps().length;
int NumChannels = 1;
double[][][] pixData = new double[NumTimePoints][NumChannels][];
for (int i = 0; i < NumTimePoints; i++) {
// images according to zIndex at specific time points(tIndex)
short[] originalData = imageDataset.getPixelsZ(0, i);
double[] doubleData = new double[originalData.length];
for (int j = 0; j < originalData.length; j++) {
doubleData[j] = 0x0000ffff & originalData[j];
}
pixData[i][NumChannels - 1] = doubleData;
}
FieldDataFileOperationSpec fdos = new FieldDataFileOperationSpec();
// try {
// fdos = ClientRequestManager.createFDOSFromImageFile(filePSF, false, null);
// } catch (DataFormatException ex) {
// throw new Exception("Cannot read image " + filePSF.getAbsolutePath()+"\n"+ex.getMessage());
// }
fdos.owner = documentManager.getUser();
fdos.opType = FieldDataFileOperationSpec.FDOS_ADD;
fdos.cartesianMesh = cartesianMesh;
fdos.doubleSpecData = pixData;
fdos.specEDI = null;
fdos.varNames = new String[] { SimulationContext.FLUOR_DATA_NAME };
fdos.times = imageDataset.getImageTimeStamps();
fdos.variableTypes = new VariableType[] { VariableType.VOLUME };
fdos.origin = origin;
fdos.extent = extent;
fdos.isize = isize;
ExternalDataIdentifier pSFImageEDI = documentManager.saveFieldData(fdos, initialFieldDataName);
hashTable.put("pSFImageEDI", pSFImageEDI);
}
};
// create a data symbol for the PSF image saved above as field data
taskArray[2] = new AsynchClientTask("Display Data Symbols", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
// --- create the data symbols associated with the time series
String initialFieldDataName = (String) hashTable.get("initialFieldDataName");
ExternalDataIdentifier pSFImageEDI = (ExternalDataIdentifier) hashTable.get("pSFImageEDI");
String fluorName = "psf_" + initialFieldDataName;
DataSymbol fluorDataSymbol = new FieldDataSymbol(fluorName, DataSymbolType.POINT_SPREAD_FUNCTION, simulationContext.getDataContext(), simulationContext.getModel().getUnitSystem().getInstance_TBD(), pSFImageEDI, SimulationContext.FLUOR_DATA_NAME, VariableType.VOLUME.getTypeName(), 0D);
simulationContext.getDataContext().addDataSymbol(fluorDataSymbol);
}
};
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(parentWindow, hash, taskArray, false, true, null);
}
use of cbit.vcell.field.io.FieldDataFileOperationSpec 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 cbit.vcell.field.io.FieldDataFileOperationSpec in project vcell by virtualcell.
the class FieldDataGUIPanel method jButtonFDDelete_ActionPerformed.
private void jButtonFDDelete_ActionPerformed(java.awt.event.ActionEvent actionEvent) {
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
TreePath selPath = getJTree1().getSelectionPath();
final DefaultMutableTreeNode mainNode = (DefaultMutableTreeNode) selPath.getLastPathComponent();
final FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
if (!fieldDataMainList.externalDataIdentifier.getOwner().equals(clientRequestManager.getDocumentManager().getUser())) {
DialogUtils.showErrorDialog(this, "Delete failed: User " + clientRequestManager.getDocumentManager().getUser().getName() + "does not own FieldData '" + fieldDataMainList.externalDataIdentifier.getName() + "'");
}
if (PopupGenerator.showComponentOKCancelDialog(this, new JLabel("Delete " + fieldDataMainList.externalDataIdentifier.getName() + "?"), "Confirm Delete") != JOptionPane.OK_OPTION) {
return;
}
AsynchClientTask CheckRemoveFromDBTask = new AsynchClientTask("Check Field Data references in DB", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
if (fieldDataWindowManager.findReferencingModels(fieldDataMainList.externalDataIdentifier, false)) {
throw new Exception("Cannot delete Field Data '" + fieldDataMainList.externalDataIdentifier.getName() + "' because it is referenced in a Model(s) or Function(s) file.");
}
}
};
AsynchClientTask RemoveNodeTreeTask = new AsynchClientTask("Remove FieldData tree node", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
((DefaultTreeModel) getJTree1().getModel()).removeNodeFromParent(mainNode);
if (((DefaultMutableTreeNode) getJTree1().getModel().getRoot()).getChildCount() == 0) {
updateJTree(clientRequestManager);
}
}
};
AsynchClientTask RemoveFromDiskAndDBTask = new AsynchClientTask("Remove Field Data from Disk and DB", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
// Remove from Disk
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
FieldDataFileOperationSpec fdos = FieldDataFileOperationSpec.createDeleteFieldDataFileOperationSpec(fieldDataMainList.externalDataIdentifier);
clientRequestManager.getDocumentManager().fieldDataFileOperation(fdos);
// Remove from DB
fieldDataWindowManager.deleteExternalDataIdentifier(fieldDataMainList.externalDataIdentifier);
}
};
//
// Execute Field Data Info - JTree tasks
//
AsynchClientTask[] tasks = new AsynchClientTask[] { CheckRemoveFromDBTask, RemoveFromDiskAndDBTask, RemoveNodeTreeTask };
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, tasks, false);
}
Aggregations