use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.
the class FieldDataGUIPanel method getJButtonCreateGeom.
/**
* This method initializes jButtonCopyInfo
*
* @return javax.swing.JButton
*/
private JButton getJButtonCreateGeom() {
if (jButtonCreateGeom == null) {
jButtonCreateGeom = new JButton();
jButtonCreateGeom.setEnabled(false);
jButtonCreateGeom.setText("Create Geom");
jButtonCreateGeom.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode) selPath.getLastPathComponent();
if (lastPathComponent.getUserObject() instanceof FieldDataVarList) {
DataIdentifier dataIdentifier = ((FieldDataVarList) lastPathComponent.getUserObject()).dataIdentifier;
TreePath ppPath = selPath.getParentPath().getParentPath();
javax.swing.tree.DefaultMutableTreeNode ppLastPathComp = (javax.swing.tree.DefaultMutableTreeNode) ppPath.getLastPathComponent();
if (ppLastPathComp.getUserObject() instanceof FieldDataMainList) {
ExternalDataIdentifier extDataID = ((FieldDataMainList) ppLastPathComp.getUserObject()).externalDataIdentifier;
final OpenModelInfoHolder openModelInfoHolder = FieldDataWindowManager.selectOpenModelsFromDesktop(FieldDataGUIPanel.this, fieldDataWindowManager.getRequestManager(), false, "Select BioModel or MathModel to receive new geometry", false);
if (openModelInfoHolder == null) {
DialogUtils.showErrorDialog(FieldDataGUIPanel.this, "Before proceeding, please open a Biomodel application or Mathmodel you wish to apply a new Field Data Geometry to");
return;
}
AsynchClientTask applyGeomTask = new AsynchClientTask("apply geometry", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Geometry newGeom = (Geometry) hashTable.get("doc");
final String OK_OPTION = "Ok";
if (openModelInfoHolder instanceof FDSimMathModelInfo) {
Version version = ((FDSimMathModelInfo) openModelInfoHolder).getMathModelVersion();
String modelName = (version == null ? "NoName" : version.getName());
if (newGeom.getName() == null) {
newGeom.setName(modelName + "_" + BeanUtils.generateDateTimeString());
}
String message = "Confirm Setting new FieldData derived geometry on MathModel '" + modelName + "'";
if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
((FDSimMathModelInfo) openModelInfoHolder).getMathDescription().setGeometry(newGeom);
}
} else if (openModelInfoHolder instanceof FDSimBioModelInfo) {
Version version = ((FDSimBioModelInfo) openModelInfoHolder).getBioModelVersion();
String modelName = (version == null ? "NoName" : version.getName());
String simContextName = ((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().getName();
if (newGeom.getName() == null) {
newGeom.setName(modelName + "_" + simContextName + "_" + BeanUtils.generateDateTimeString());
}
String message = "Confirm Setting new FieldData derived geometry on BioModel '" + modelName + "' , Application '" + simContextName + "'";
if (DialogUtils.showWarningDialog(FieldDataGUIPanel.this, message, new String[] { OK_OPTION, "Cancel" }, OK_OPTION).equals(OK_OPTION)) {
((FDSimBioModelInfo) openModelInfoHolder).getSimulationContext().setGeometry(newGeom);
}
}
}
};
VCDocument.GeomFromFieldDataCreationInfo geomFromFieldDataCreationInfo = new VCDocument.GeomFromFieldDataCreationInfo(extDataID, dataIdentifier.getName());
AsynchClientTask[] createGeomTask = clientRequestManager.createNewGeometryTasks(fieldDataWindowManager, geomFromFieldDataCreationInfo, new AsynchClientTask[] { applyGeomTask }, "Apply Geometry");
Hashtable<String, Object> hash = new Hashtable<String, Object>();
hash.put(ClientRequestManager.GUI_PARENT, fieldDataWindowManager.getComponent());
ClientTaskDispatcher.dispatch(FieldDataGUIPanel.this, hash, createGeomTask, false, false, null, true);
}
}
} catch (UserCancelException e1) {
// ignore
} catch (Exception e1) {
e1.printStackTrace();
DialogUtils.showErrorDialog(FieldDataGUIPanel.this, e1.getMessage());
}
// jButtonFDCopyRef_ActionPerformed(e);
// fieldDataWindowManager.newDocument(VCDocument.GEOMETRY_DOC, option);
// copyMethod(COPY_CRNL);
// // javax.swing.tree.TreePath selPath = getJTree1().getSelectionPath();
// // if(selPath != null){
// // javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
// // copyMethod(lastPathComponent, copyMode);
// // }
// // String copyString = "";
// // javax.swing.tree.DefaultMutableTreeNode lastPathComponent = (javax.swing.tree.DefaultMutableTreeNode)selPath.getLastPathComponent();
// // if(lastPathComponent.equals(getJTree1().getModel().getRoot())){
// // int childCount = lastPathComponent.getChildCount();
// // for(int i=0;i<childCount;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+=
// // ((FieldDataMainList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).externalDataIdentifier.getName();
// // }
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataOriginList){
// // Origin origin = ((FieldDataOriginList)lastPathComponent.getUserObject()).origin;
// // copyString = origin.getX()+","+origin.getY()+","+origin.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataExtentList){
// // Extent extent = ((FieldDataExtentList)lastPathComponent.getUserObject()).extent;
// // copyString = extent.getX()+","+extent.getY()+","+extent.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataISizeList){
// // ISize isize = ((FieldDataISizeList)lastPathComponent.getUserObject()).isize;
// // copyString = isize.getX()+","+isize.getY()+","+isize.getZ();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataTimeList){
// // double[] times = ((FieldDataTimeList)lastPathComponent.getUserObject()).times;
// // for(int i=0;i<times.length;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+= times[i]+"";
// // }
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataMainList){
// // ExternalDataIdentifier extDataID =
// // ((FieldDataMainList)lastPathComponent.getUserObject()).externalDataIdentifier;
// // copyString = extDataID.getName();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataVarList){
// // DataIdentifier dataIdentifier =
// // ((FieldDataVarList)lastPathComponent.getUserObject()).dataIdentifier;
// // copyString = dataIdentifier.getName();
// // }else if(lastPathComponent.getUserObject() instanceof FieldDataVarMainList){
// // int childCount = lastPathComponent.getChildCount();
// // for(int i=0;i<childCount;i+= 1){
// // if(i != 0){
// // copyString+="\n";
// // }
// // copyString+=
// // ((FieldDataVarList)((DefaultMutableTreeNode)lastPathComponent.getChildAt(i)).getUserObject()).dataIdentifier.getName();
// // }
// // }
// // if(copyString.length() > 0 ){
// // VCellTransferable.sendToClipboard(copyString);
// // }
// // }
}
});
}
return jButtonCreateGeom;
}
use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.
the class FieldDataGUIPanel method refreshMainNode.
private void refreshMainNode(final DefaultMutableTreeNode mainNode) {
final boolean isMainExpanded = getJTree1().isExpanded(new TreePath(mainNode.getPath()));
final boolean isVarExpanded = getJTree1().isExpanded(new TreePath(((DefaultMutableTreeNode) mainNode.getLastChild()).getPath()));
// Remove all children from Main node in a Tree safe way
DefaultMutableTreeNode root = (DefaultMutableTreeNode) getJTree1().getModel().getRoot();
int mainNodeIndex = ((DefaultTreeModel) getJTree1().getModel()).getIndexOfChild(root, mainNode);
((DefaultTreeModel) getJTree1().getModel()).removeNodeFromParent(mainNode);
mainNode.removeAllChildren();
final DefaultMutableTreeNode varNode = new DefaultMutableTreeNode(new FieldDataVarMainList());
mainNode.add(varNode);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(mainNode, root, mainNodeIndex);
//
// Create thread-safe tasks to get Field Data Info and update JTree
//
final String FDOR_INFO = "FDOR_INFO";
final RequestManager clientRequestManager = fieldDataWindowManager.getLocalRequestManager();
AsynchClientTask FieldDataInfoTask = new AsynchClientTask("Gather Field Data info", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) throws Exception {
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final FieldDataFileOperationResults fieldDataFileOperationResults = clientRequestManager.getDocumentManager().fieldDataFileOperation(FieldDataFileOperationSpec.createInfoFieldDataFileOperationSpec(fieldDataMainList.externalDataIdentifier.getKey(), clientRequestManager.getDocumentManager().getUser(), FieldDataFileOperationSpec.JOBINDEX_DEFAULT));
hash.put(FDOR_INFO, fieldDataFileOperationResults);
}
};
AsynchClientTask FieldDataInfoTreeUpdate = new AsynchClientTask("Update Field Data GUI", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {
public void run(Hashtable<String, Object> hash) {
try {
FieldDataFileOperationResults fieldDataFileOperationResults = (FieldDataFileOperationResults) hash.get(FDOR_INFO);
Arrays.sort(fieldDataFileOperationResults.dataIdentifierArr, new Comparator<DataIdentifier>() {
public int compare(DataIdentifier o1, DataIdentifier o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
FieldDataMainList fieldDataMainList = (FieldDataMainList) mainNode.getUserObject();
final DefaultMutableTreeNode isizeNode = new DefaultMutableTreeNode(new FieldDataISizeList(fieldDataFileOperationResults.iSize));
final DefaultMutableTreeNode originNode = new DefaultMutableTreeNode(new FieldDataOriginList(fieldDataFileOperationResults.origin));
final DefaultMutableTreeNode extentNode = new DefaultMutableTreeNode(new FieldDataExtentList(fieldDataFileOperationResults.extent));
final DefaultMutableTreeNode timeNode = new DefaultMutableTreeNode(new FieldDataTimeList(fieldDataFileOperationResults.times));
final DefaultMutableTreeNode idNode = new DefaultMutableTreeNode(new FieldDataIDList(fieldDataMainList.externalDataIdentifier.getKey()));
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(isizeNode, mainNode, 0);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(originNode, mainNode, 1);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(extentNode, mainNode, 2);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(timeNode, mainNode, 3);
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(idNode, mainNode, 4);
for (int i = 0; i < fieldDataFileOperationResults.dataIdentifierArr.length; i += 1) {
((DefaultTreeModel) getJTree1().getModel()).insertNodeInto(new DefaultMutableTreeNode(new FieldDataVarList(fieldDataFileOperationResults.dataIdentifierArr[i])), varNode, varNode.getChildCount());
}
if (isMainExpanded) {
getJTree1().expandPath(new TreePath(mainNode.getPath()));
}
if (isVarExpanded) {
getJTree1().expandPath(new TreePath(varNode.getPath()));
}
} catch (Throwable e) {
hash.put(ClientTaskDispatcher.TASK_ABORTED_BY_ERROR, e);
}
}
};
//
// Execute Field Data Info - JTree tasks
//
AsynchClientTask[] tasks = new AsynchClientTask[] { FieldDataInfoTask, FieldDataInfoTreeUpdate };
Hashtable<String, Object> hash = new Hashtable<String, Object>();
ClientTaskDispatcher.dispatch(this, hash, tasks, false);
}
use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.
the class DisplayTimeSeriesOp method getDataSetControllerProvider.
private DataSetControllerProvider getDataSetControllerProvider(final ImageTimeSeries<? extends Image> imageTimeSeries, final PDEDataViewer pdeDataViewer) throws ImageException, IOException {
ISize size = imageTimeSeries.getISize();
int dimension = (size.getZ() > 0) ? (3) : (2);
Extent extent = imageTimeSeries.getExtent();
Origin origin = imageTimeSeries.getAllImages()[0].getOrigin();
// don't care ... no surfaces
double filterCutoffFrequency = 0.5;
VCImage vcImage = new VCImageUncompressed(null, new byte[size.getXYZ()], extent, size.getX(), size.getY(), size.getZ());
RegionImage regionImage = new RegionImage(vcImage, dimension, extent, origin, filterCutoffFrequency);
final CartesianMesh mesh = CartesianMesh.createSimpleCartesianMesh(origin, extent, size, regionImage);
final DataIdentifier dataIdentifier = new DataIdentifier("var", VariableType.VOLUME, new Domain("domain"), false, "var");
final DataSetController dataSetController = new DataSetController() {
@Override
public ExportEvent makeRemoteFile(OutputContext outputContext, ExportSpecs exportSpecs) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public TimeSeriesJobResults getTimeSeriesValues(OutputContext outputContext, VCDataIdentifier vcdataID, TimeSeriesJobSpec timeSeriesJobSpec) throws RemoteProxyException, DataAccessException {
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_START, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
if (!timeSeriesJobSpec.isCalcSpaceStats() && !timeSeriesJobSpec.isCalcTimeStats()) {
int[][] indices = timeSeriesJobSpec.getIndices();
double[] timeStamps = imageTimeSeries.getImageTimeStamps();
// [var][dataindex+1][timeindex]
double[][][] dataValues = new double[1][indices[0].length + 1][timeStamps.length];
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
// index 0 is time
dataValues[0][0][timeIndex] = timeStamps[timeIndex];
}
for (int timeIndex = 0; timeIndex < timeStamps.length; timeIndex++) {
float[] pixelValues = imageTimeSeries.getAllImages()[timeIndex].getFloatPixels();
for (int samplePointIndex = 0; samplePointIndex < indices[0].length; samplePointIndex++) {
int pixelIndex = indices[0][samplePointIndex];
dataValues[0][samplePointIndex + 1][timeIndex] = pixelValues[pixelIndex];
}
}
TSJobResultsNoStats timeSeriesJobResults = new TSJobResultsNoStats(new String[] { "var" }, indices, timeStamps, dataValues);
pdeDataViewer.dataJobMessage(new DataJobEvent(timeSeriesJobSpec.getVcDataJobID(), MessageEvent.DATA_COMPLETE, vcdataID.getDataKey(), vcdataID.getID(), new Double(0)));
return timeSeriesJobResults;
}
return null;
}
@Override
public SimDataBlock getSimDataBlock(OutputContext outputContext, VCDataIdentifier vcdataID, String varName, double time) throws RemoteProxyException, DataAccessException {
double timePoint = time;
double[] timePoints = getDataSetTimes(vcdataID);
int index = -1;
for (int i = 0; i < timePoints.length; i++) {
if (timePoint == timePoints[i]) {
index = i;
break;
}
}
double[] data = imageTimeSeries.getAllImages()[index].getDoublePixels();
PDEDataInfo pdeDataInfo = new PDEDataInfo(null, null, varName, time, 0);
VariableType varType = VariableType.VOLUME;
return new SimDataBlock(pdeDataInfo, data, varType);
}
@Override
public boolean getParticleDataExists(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return false;
}
@Override
public ParticleDataBlock getParticleDataBlock(VCDataIdentifier vcdataID, double time) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public ODESimData getODEData(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return null;
}
@Override
public CartesianMesh getMesh(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return mesh;
}
@Override
public PlotData getLineScan(OutputContext outputContext, VCDataIdentifier vcdataID, String variable, double time, SpatialSelection spatialSelection) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public AnnotatedFunction[] getFunctions(OutputContext outputContext, VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
return new AnnotatedFunction[0];
}
@Override
public double[] getDataSetTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return imageTimeSeries.getImageTimeStamps();
}
@Override
public DataSetTimeSeries getDataSetTimeSeries(VCDataIdentifier vcdataID, String[] variableNames) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataSetMetadata getDataSetMetadata(VCDataIdentifier vcdataID) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataIdentifier[] getDataIdentifiers(OutputContext outputContext, VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
return new DataIdentifier[] { dataIdentifier };
}
@Override
public FieldDataFileOperationResults fieldDataFileOperation(FieldDataFileOperationSpec fieldDataFileOperationSpec) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public DataOperationResults doDataOperation(DataOperation dataOperation) throws DataAccessException, RemoteProxyException {
throw new RuntimeException("not yet implemented");
}
@Override
public VtuFileContainer getEmptyVtuMeshFiles(VCDataIdentifier vcdataID, int timeIndex) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@Override
public double[] getVtuTimes(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
throw new RuntimeException("not yet implemented");
}
@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) throws DataAccessException, RemoteProxyException {
// TODO Auto-generated method stub
return null;
}
@Override
public NFSimMolecularConfigurations getNFSimMolecularConfigurations(VCDataIdentifier vcdataID) throws RemoteProxyException, DataAccessException {
// TODO Auto-generated method stub
return null;
}
};
DataSetControllerProvider dataSetControllerProvider = new DataSetControllerProvider() {
@Override
public DataSetController getDataSetController() throws DataAccessException {
return dataSetController;
}
};
return dataSetControllerProvider;
}
use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.
the class TestMissingSimData method checkDataExists.
// private static void runSimsNew(String connectURL,String dbSchemaUser, String dbPassword) throws Exception{
//
// // VCellBootstrap vCellBootstrap = getVCellBootstrap("rmi-beta.cam.uchc.edu", 40105, "VCellBootstrapServer", 12, false);
// // VCellBootstrap vCellBootstrap = getVCellBootstrap("rmi-alpha.cam.uchc.edu", 40106, "VCellBootstrapServer", 12, false);
// VCellBootstrap vCellBootstrap = getVCellBootstrap("rmi-alpha.cam.uchc.edu", 40111, "VCellBootstrapServer", 12, false);//Test2
//
// if(true){
// Hashtable<KeyValue, UserLoginInfo> keyUserLoginInfo = doQuery(connectURL, dbSchemaUser, dbPassword);
// Enumeration<KeyValue> keys = keyUserLoginInfo.keys();
// while(keys.hasMoreElements()){
// KeyValue simKey = keys.nextElement();
// UserLoginInfo userLoginInfo = keyUserLoginInfo.get(simKey);
// VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simKey, userLoginInfo.getUser());
// acquireThread(vcSimulationIdentifier, vCellBootstrap, userLoginInfo, connectURL, dbSchemaUser, dbPassword);
// }
// return;
// }
//
//
// String itemSelectSQL = " select vc_userinfo.userid,vc_userinfo.id userkey,vc_userinfo.digestpw,missingdata.simjobsimref,vc_softwareversion.softwareversion ";
//
// String sqlPart =
// " from missingdata,vc_simulation,vc_userinfo,vc_softwareversion "+
// " where "+
// " (vc_simulation.id in (select simref from vc_biomodelsim)) and " +
// // " (vc_simulation.id in (select simref from vc_mathmodelsim)) and " +
// " vc_userinfo.userid='fgao5' and "+
// " vc_userinfo.id = vc_simulation.ownerref and "+
// " missingdata.simjobsimref = vc_simulation.id and "+
// // " missingdata.dataexists not like 'readable%' and "+
// " (missingdata.dataexists = 'false') "+
// " and missingdata.notes is not null and " +
// " (missingdata.notes like '%Compiled_solvers_no_longer%' or missingdata.notes like '%Connection_refused%')" +
// // " and missingdata.simjobsimref = 34080002 " +
// // " or missingdata.dataexists like 'error - %') "+
// // " and (missingdata.notes is null ) "+
// // " or missingdata.notes not like 'reran OK%')" +
// " and vc_simulation.parentsimref is null and "+
// " (softwareversion is null or regexp_substr(softwareversion,'^((release)|(rel)|(alpha)|(beta))_version_([[:digit:]]+\\.?)+_build_([[:digit:]]+\\.?)+',1,1,'i') is not null) and "+
// " vc_softwareversion.versionableref (+) = vc_simulation.id " +
// // " and rownum = 1 ";
// // " and vc_simulation.id=39116536"
// " order by vc_userinfo.userid";
//
// // (mdt.dataexists = 'false' or mdt.dataexists like 'error - %') and
// // (mdt.notes is null or mdt.notes not like 'reran OK%') and
//
// //Create hash of sims and userlogininfo
// Hashtable<KeyValue, UserLoginInfo> simToUserLoginInfoHash = new Hashtable<>();
// Statement updateStatement = con.createStatement();
// Statement queryStatement = con.createStatement();
// //Get Count
// ResultSet rset = queryStatement.executeQuery("select count(*) "+sqlPart);
// rset.next();
// int totalCount = rset.getInt(1);
// rset.close();
// //Get sims
// rset = queryStatement.executeQuery(itemSelectSQL+sqlPart);
// UserLoginInfo userLoginInfo = null;
// VCellConnection vcellConnection = null;
// int currentCount = 1;
// while(rset.next()){
// KeyValue simJobSimRef = new KeyValue(rset.getString("simjobsimref"));
// try{
// String softwareVersion = rset.getString("softwareversion");
// String userid = rset.getString("userid");
// System.out.println("-----");
// System.out.println("-----running "+currentCount+" of "+totalCount+" user="+userid+" simjobsimref="+simJobSimRef);
// currentCount+= 1;
// System.out.println("-----");
//
// if(!rset.wasNull() && softwareVersion != null){
// StringTokenizer st = new StringTokenizer(softwareVersion, "_");
// st.nextToken();//site name
// st.nextToken();//'Version' literal string
// String majorVersion = st.nextToken();//major version number
// if(majorVersion.equals("5.4")){
// throw new Exception("Alpha-5.4 sims are not being re-run using Beta-5.3 code");
// }
// }
//
// if(userid.toLowerCase().equals("vcelltestaccount")
// // || userid.toLowerCase().equals("anu")
// // || userid.toLowerCase().equals("fgao")
// // || userid.toLowerCase().equals("liye")
// // || userid.toLowerCase().equals("schaff")
// // || userid.toLowerCase().equals("ignovak")
// // || userid.toLowerCase().equals("jditlev")
// // || userid.toLowerCase().equals("sensation")
// ){
// continue;
// }
// String userkey = rset.getString("userkey");
// if(userLoginInfo == null || !userLoginInfo.getUserName().equals(userid)){
// userLoginInfo = new UserLoginInfo(userid,DigestedPassword.createAlreadyDigested(rset.getString("digestpw")));
// userLoginInfo.setUser(new User(userid, new KeyValue(userkey)));
// vcellConnection = null;
// }
// VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simJobSimRef, userLoginInfo.getUser());
//
//
// //
// //
// //
// if(true){
// acquireThread(vcSimulationIdentifier, vCellBootstrap, userLoginInfo, connectURL, dbSchemaUser, dbPassword);
// continue;
// }
//
// try{
// if(vcellConnection != null){
// vcellConnection.getMessageEvents();
// }
// }catch(Exception e){
// e.printStackTrace();
// //assume disconnected
// vcellConnection = null;
// }
// if(vcellConnection == null){
// vcellConnection = vCellBootstrap.getVCellConnection(userLoginInfo);
// vcellConnection.getMessageEvents();
// }
//
// SimulationStatusPersistent initSimulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
//
// System.out.println("initial status="+initSimulationStatus);
// // if(!initSimulationStatus.isCompleted() || !initSimulationStatus.getHasData()){
// // continue;
// // }
//
//
// BigString simXML = vcellConnection.getUserMetaDbServer().getSimulationXML(simJobSimRef);
// Simulation sim = XmlHelper.XMLToSim(simXML.toString());
// // SolverDescription solverDescription = sim.getSolverTaskDescription().getSolverDescription();
// // if(solverDescription.equals(SolverDescription.StochGibson) || solverDescription.equals(SolverDescription.FiniteVolume)){
// // //These 2 solvers give too much trouble so skip
// // System.out.println("--skipping solver");
// //// notCompletedSimIDs.add(simIDAndJobID.simID.toString());
// // return;
// // }
//
//
// // if(!sim.isSpatial()){
// // continue;
// // }
// // if(sim.getSolverTaskDescription().isSerialParameterScan()/* || sim.getSolverTaskDescription().getExpectedNumTimePoints() > 20*/){
// // continue;
// // }
//
// int scanCount = sim.getScanCount();
// // if(true){return;}
// SimulationStatusPersistent simulationStatus = null;
// SimulationInfo simulationInfo = sim.getSimulationInfo();
// if(!simulationInfo.getAuthoritativeVCSimulationIdentifier().getSimulationKey().equals(vcSimulationIdentifier.getSimulationKey())){
// throw new Exception("Unexpected authoritative and sim id are not the same");
// }
// vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, scanCount);
// long startTime = System.currentTimeMillis();
// while(simulationStatus == null || simulationStatus.isStopped() || simulationStatus.isCompleted() || simulationStatus.isFailed()){
// Thread.sleep(2000);
// simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
// if(simulationStatus.isFailed() && !initSimulationStatus.isFailed()){
// break;
// }
// MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
// if((System.currentTimeMillis()-startTime) > 30000){
// throw new Exception("-----Sim finished too fast or took too long to start, status= "+simulationStatus);
// }
// System.out.println(simulationStatus);
// }
// SimulationStatusPersistent lastSimStatus = simulationStatus;
// while(!simulationStatus.isStopped() && !simulationStatus.isCompleted() && !simulationStatus.isFailed()){
// for(int i = 0;i<3;i++){
// MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
// Thread.sleep(1000);
// }
// simulationStatus = vcellConnection.getUserMetaDbServer().getSimulationStatus(vcSimulationIdentifier.getSimulationKey());
// if(!simulationStatus.toString().equals(lastSimStatus.toString())){
// lastSimStatus = simulationStatus;
// System.out.println("running status="+simulationStatus);
// }
// // MessageEvent[] messageEvents = vcellConnection.getMessageEvents();
// // for (int i = 0; messageEvents != null && i < messageEvents.length; i++) {
// // System.out.println(messageEvents[i]);
// // }
// }
//
// if(!lastSimStatus.isCompleted()){
// throw new Exception("Unexpected run status: "+lastSimStatus.toString());
// }
//
//
// String updatestr = "update missingdata set notes='"+DB_NOTES_SIM_RUNOK_CODE+"' where simjobsimref="+simJobSimRef;
// System.out.println(updatestr);
// updateStatement.executeUpdate(updatestr);
// con.commit();
// }catch(Exception e){
// e.printStackTrace();
// String errString = TokenMangler.fixTokenStrict(DB_NOTES_SIM_ERROR_CODE+e.getClass().getSimpleName()+" "+e.getMessage());
// if(errString.length() > 256){
// errString = errString.substring(0, 256);
// }
// String updatestr = "update missingdata set notes='"+errString+"' where simjobsimref="+simJobSimRef;
// System.out.println(updatestr);
// updateStatement.executeUpdate(updatestr);
// con.commit();
// }
// }
//
// }
private static void checkDataExists(Connection con, boolean bExistOnly) throws SQLException {
AmplistorCredential amplistorCredential = AmplistorUtilsTest.getAmplistorCredential();
Statement queryStatement = con.createStatement();
Statement updateStatement = con.createStatement();
// Hashtable<KeyValue, Exception> errorHash = new Hashtable<>();
String sql = "select missingdata.*,parentsimref " + " from missingdata,vc_simulation,vc_userinfo" + " where vc_simulation.id = missingdata.simjobsimref and" + " vc_simulation.parentsimref is null and " + " vc_simulation.ownerref=vc_userinfo.id and " + " missingdata.notes is not null and " + " (missingdata.notes like '%exceeded_maximum%' " + " or missingdata.notes ='recheck dataexists' )" + // " vc_userinfo.userid='schaff' "+
" order by missingdata.userid";
ResultSet rset = queryStatement.executeQuery(sql);
while (rset.next()) {
// if(!rset.getString("dataexists").equals("tbd")){
// continue;
// }
KeyValue simJobSimRef = null;
KeyValue parentsimref = null;
User user = null;
try {
simJobSimRef = new KeyValue(rset.getString("simjobsimref"));
parentsimref = (rset.getString("parentsimref") == null ? null : new KeyValue(rset.getString("parentsimref")));
user = new User(rset.getString("userid"), new KeyValue(rset.getString("userinfoid")));
int jobIndex = rset.getInt("jobindex");
File primaryDataDir = new File("\\\\cfs02\\ifs\\raid\\vcell\\users\\" + user.getName());
String updatestr = null;
File filePathNamePrime = new File(primaryDataDir, SimulationData.createCanonicalSimLogFileName(simJobSimRef, 0, false));
if (filePathNamePrime.exists()) {
updatestr = "fileNewPrime";
} else if (new File(primaryDataDir, SimulationData.createCanonicalSimLogFileName(simJobSimRef, 0, true)).exists()) {
updatestr = "fileOldPrime";
} else if (parentsimref != null && new File(primaryDataDir, SimulationData.createCanonicalSimLogFileName(parentsimref, 0, false)).exists()) {
updatestr = "fileNewParent";
} else if (parentsimref != null && new File(primaryDataDir, SimulationData.createCanonicalSimLogFileName(parentsimref, 0, true)).exists()) {
updatestr = "fileOldParent";
} else if (AmplistorUtils.bFileExists(new URL(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + user.getName() + "/" + filePathNamePrime.getName()), amplistorCredential)) {
updatestr = "ampliNewPrime";
} else if (AmplistorUtils.bFileExists(new URL(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + user.getName() + "/" + SimulationData.createCanonicalSimLogFileName(simJobSimRef, 0, true)), amplistorCredential)) {
updatestr = "ampliOldPrime";
} else if (parentsimref != null && AmplistorUtils.bFileExists(new URL(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + user.getName() + "/" + SimulationData.createCanonicalSimLogFileName(parentsimref, 0, false)), amplistorCredential)) {
updatestr = "ampliNewParent";
} else if (parentsimref != null && AmplistorUtils.bFileExists(new URL(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + user.getName() + "/" + SimulationData.createCanonicalSimLogFileName(parentsimref, 0, true)), amplistorCredential)) {
updatestr = "ampliOldParent";
} else {
updatestr = "false";
}
if (bExistOnly || updatestr.equals("false")) {
updateStatement.executeUpdate("update missingdata set dataexists='" + updatestr + "' where simjobsimref=" + simJobSimRef.toString());
con.commit();
continue;
}
// Log file exists, now check if the data can really be read
VCSimulationIdentifier vcSimulationIdentifier = new VCSimulationIdentifier(simJobSimRef, user);
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(vcSimulationIdentifier, jobIndex);
// Try to read log,times and simdata to see if this data is well formed
SimDataAmplistorInfo simDataAmplistorInfo = AmplistorUtils.getSimDataAmplistorInfoFromPropertyLoader();
SimulationData simData = new SimulationData(vcSimulationDataIdentifier, primaryDataDir, null, simDataAmplistorInfo);
double[] dataTimes = simData.getDataTimes();
DataIdentifier[] dataIdentifiers = simData.getVarAndFunctionDataIdentifiers(null);
DataIdentifier readDataIdentifier = null;
for (DataIdentifier dataIdentifier : dataIdentifiers) {
if (!dataIdentifier.isFunction()) {
if (simData.getIsODEData()) {
ODEDataBlock odeDataBlock = simData.getODEDataBlock();
odeDataBlock.getODESimData().getRow(dataTimes.length - 1);
} else {
simData.getSimDataBlock(null, dataIdentifier.getName(), dataTimes[dataTimes.length - 1]);
}
readDataIdentifier = dataIdentifier;
break;
}
}
System.out.println(BeanUtils.forceStringSize("user= " + user.getName(), 20, " ", false) + " simref= " + BeanUtils.forceStringSize(simJobSimRef.toString(), 14, " ", false) + " numTimes= " + BeanUtils.forceStringSize(dataTimes.length + "", 8, " ", true) + " readDataID= " + BeanUtils.forceStringSize(readDataIdentifier.getName() + "", 20, " ", true));
updatestr = "update missingdata set dataexists='readable' where simjobsimref=" + simJobSimRef.toString();
// String updatestr = "update missingdata set dataexists='true' where"+
// " userinfoid="+user.getID().toString()+
// " and simjobsimref="+simJobSimRef.toString()+
// " and maxtaskid="+rset.getString("maxtaskid")+
// " and jobindex="+jobIndex;
// updateStatement.executeUpdate(updatestr);
// con.commit();
} catch (Exception e) {
if (simJobSimRef == null) {
e.printStackTrace();
// throw new SQLException("Error querying",e);
} else {
String errString = e.getClass().getSimpleName() + " " + e.getMessage();
if (errString.length() > 512) {
errString = errString.substring(0, 512);
}
String updatestr = "update missingdata set dataexists='error - " + TokenMangler.fixTokenStrict(errString) + "' where simjobsimref=" + simJobSimRef.toString();
// updateStatement.executeUpdate(updatestr);
// con.commit();
System.out.println(BeanUtils.forceStringSize("user= " + (user == null ? "unavailable" : user.getName()), 20, " ", false) + " simref= " + BeanUtils.forceStringSize(simJobSimRef.toString(), 14, " ", false) + " parentsimref= " + BeanUtils.forceStringSize((parentsimref == null ? "NULL" : parentsimref.toString()), 14, " ", false) + " failed= " + e.getMessage());
// errorHash.put(simJobSimRef,e);
}
}
}
rset.close();
// return errorHash;
}
use of cbit.vcell.simdata.DataIdentifier in project vcell by virtualcell.
the class KymographPanel method main.
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(java.lang.String[] args) {
try {
final int numTP = 27;
final int numDP = 100;
double[][] timeSeries = new double[numDP + 1][numTP];
double[] accumArr = new double[numDP];
timeSeries[0] = new double[numTP];
for (int i = 0; i < numTP; i += 1) {
timeSeries[0][i] = i + 10;
}
java.util.Random rand = new java.util.Random();
for (int i = 0; i < numDP; i += 1) {
accumArr[i] = (i == 0 ? 0 : accumArr[i - 1] + rand.nextDouble() * 10);
for (int j = 0; j < numTP; j += 1) {
// timeSeries[i+1][j] = rand.nextDouble()*10000;
timeSeries[i + 1][j] = j * numTP + i;
}
if (args.length > 0 && args[0].equals("allNAN")) {
java.util.Arrays.fill(timeSeries[i + 1], Double.NaN);
}
}
timeSeries[1][0] = Double.NaN;
timeSeries[1][1] = Double.NaN;
timeSeries[2][0] = Double.NaN;
timeSeries[2][1] = Double.NaN;
javax.swing.JFrame frame = new javax.swing.JFrame();
KymographPanel aKymograph;
aKymograph = new KymographPanel(null, "Kymograph", null);
frame.setContentPane(aKymograph);
frame.setSize(aKymograph.getSize());
frame.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
java.awt.Insets insets = frame.getInsets();
frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
frame.setVisible(true);
aKymograph.initStandAloneTimeSeries(timeSeries, accumArr, new DataIdentifier("Test", VariableType.VOLUME, new Variable.Domain("test"), false, "test"));
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
Aggregations