Search in sources :

Example 51 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class ClientDocumentManager method save.

/**
 * Insert the method's description here.
 * Creation date: (10/28/00 12:08:30 AM)
 */
public Geometry save(Geometry geometry) throws DataAccessException {
    try {
        String geometryXML = null;
        try {
            geometryXML = XmlHelper.geometryToXML(geometry);
        } catch (XmlParseException e) {
            e.printStackTrace(System.out);
            throw new DataAccessException(e.getMessage());
        }
        String savedGeometryXML = sessionManager.getUserMetaDbServer().saveGeometry(new BigString(geometryXML)).toString();
        Geometry savedGeometry = getGeometryFromDatabaseXML(savedGeometryXML);
        KeyValue savedKey = savedGeometry.getVersion().getVersionKey();
        if (xmlHash.get(savedKey) == null) {
            xmlHash.put(savedKey, savedGeometryXML);
        }
        updateGeometryRelatedHashes(savedGeometry);
        return savedGeometry;
    } catch (RemoteProxyException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) KeyValue(org.vcell.util.document.KeyValue) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) BigString(org.vcell.util.BigString) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 52 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class ClientDocumentManager method substituteFieldFuncNames.

public void substituteFieldFuncNames(VCDocument vcDocument, VersionableTypeVersion originalOwner) throws DataAccessException, MathException, ExpressionException {
    Vector<ExternalDataIdentifier> errorCleanupExtDataIDV = new Vector<ExternalDataIdentifier>();
    try {
        if (originalOwner == null || originalOwner.getVersion().getOwner().compareEqual(getUser())) {
            // Substitution for FieldFunc not needed for new doc or if we own doc
            return;
        }
        // Get Objects from Document that might need to have FieldFuncs replaced
        Vector<Object> fieldFunctionContainer_mathDesc_or_simContextV = new Vector<Object>();
        if (vcDocument instanceof MathModel) {
            fieldFunctionContainer_mathDesc_or_simContextV.add(((MathModel) vcDocument).getMathDescription());
        } else if (vcDocument instanceof BioModel) {
            SimulationContext[] simContextArr = ((BioModel) vcDocument).getSimulationContexts();
            for (int i = 0; i < simContextArr.length; i += 1) {
                fieldFunctionContainer_mathDesc_or_simContextV.add(simContextArr[i]);
            }
        }
        // Get original Field names
        Vector<String> origFieldFuncNamesV = new Vector<String>();
        for (int i = 0; i < fieldFunctionContainer_mathDesc_or_simContextV.size(); i += 1) {
            Object fieldFunctionContainer = fieldFunctionContainer_mathDesc_or_simContextV.elementAt(i);
            FieldFunctionArguments[] fieldFuncArgsArr = null;
            if (fieldFunctionContainer instanceof MathDescription) {
                fieldFuncArgsArr = FieldUtilities.getFieldFunctionArguments((MathDescription) fieldFunctionContainer);
            } else if (fieldFunctionContainer instanceof SimulationContext) {
                fieldFuncArgsArr = ((SimulationContext) fieldFunctionContainer).getFieldFunctionArguments();
            }
            for (int j = 0; j < fieldFuncArgsArr.length; j += 1) {
                if (!origFieldFuncNamesV.contains(fieldFuncArgsArr[j].getFieldName())) {
                    origFieldFuncNamesV.add(fieldFuncArgsArr[j].getFieldName());
                }
            }
        }
        if (origFieldFuncNamesV.size() == 0) {
            // No FieldFunctions to substitute
            return;
        }
        FieldDataDBOperationResults copyNamesFieldDataOpResults = fieldDataDBOperation(FieldDataDBOperationSpec.createCopyNoConflictExtDataIDsSpec(getUser(), origFieldFuncNamesV.toArray(new String[0]), originalOwner));
        errorCleanupExtDataIDV.addAll(copyNamesFieldDataOpResults.oldNameNewIDHash.values());
        // Copy Field Data on Data Server FileSystem
        for (String fieldname : origFieldFuncNamesV) {
            KeyValue sourceSimDataKey = copyNamesFieldDataOpResults.oldNameOldExtDataIDKeyHash.get(fieldname);
            if (sourceSimDataKey == null) {
                throw new DataAccessException("Couldn't find original data key for FieldFunc " + fieldname);
            }
            ExternalDataIdentifier newExtDataID = copyNamesFieldDataOpResults.oldNameNewIDHash.get(fieldname);
            getSessionManager().fieldDataFileOperation(FieldDataFileOperationSpec.createCopySimFieldDataFileOperationSpec(newExtDataID, sourceSimDataKey, originalOwner.getVersion().getOwner(), FieldDataFileOperationSpec.JOBINDEX_DEFAULT, getUser()));
        }
        // Finally substitute new Field names
        for (int i = 0; i < fieldFunctionContainer_mathDesc_or_simContextV.size(); i += 1) {
            Object fieldFunctionContainer = fieldFunctionContainer_mathDesc_or_simContextV.elementAt(i);
            if (fieldFunctionContainer instanceof MathDescription) {
                MathDescription mathDesc = (MathDescription) fieldFunctionContainer;
                FieldUtilities.substituteFieldFuncNames(mathDesc, copyNamesFieldDataOpResults.oldNameNewIDHash);
            } else if (fieldFunctionContainer instanceof SimulationContext) {
                SimulationContext simContext = (SimulationContext) fieldFunctionContainer;
                simContext.substituteFieldFuncNames(copyNamesFieldDataOpResults.oldNameNewIDHash);
            }
        }
        fireFieldDataDB(new FieldDataDBEvent(this));
    } catch (Exception e) {
        e.printStackTrace();
        // Cleanup
        for (int i = 0; i < errorCleanupExtDataIDV.size(); i += 1) {
            try {
                fieldDataDBOperation(FieldDataDBOperationSpec.createDeleteExtDataIDSpec(errorCleanupExtDataIDV.elementAt(i)));
            } catch (Exception e2) {
            // ignore, we tried to cleanup
            }
            try {
                fieldDataFileOperation(FieldDataFileOperationSpec.createDeleteFieldDataFileOperationSpec(errorCleanupExtDataIDV.elementAt(i)));
            } catch (Exception e1) {
            // ignore, we tried to cleanup
            }
        }
        throw new RuntimeException("Error copying Field Data \n" + e.getMessage());
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) KeyValue(org.vcell.util.document.KeyValue) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) MathDescription(cbit.vcell.math.MathDescription) BigString(org.vcell.util.BigString) SimulationContext(cbit.vcell.mapping.SimulationContext) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) BioModel(cbit.vcell.biomodel.BioModel) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FieldDataDBOperationResults(cbit.vcell.field.FieldDataDBOperationResults) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Example 53 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class RasterExporter method exportPDEData.

private NrrdInfo[] exportPDEData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, VCDataIdentifier vcdID, VariableSpecs variableSpecs, TimeSpecs timeSpecs2, GeometrySpecs geometrySpecs, RasterSpecs rasterSpecs, FileDataContainerManager fileDataContainerManager) throws RemoteException, DataAccessException, IOException {
    CartesianMesh mesh = dataServerImpl.getMesh(user, vcdID);
    DataProcessingOutputInfo dataProcessingOutputInfo = null;
    // check if any of export variables are PostProcess and if so try to get PostProcessOutputInfo
    exportServiceImpl.fireExportProgress(jobID, vcdID, "Check PostProcess", 0.0);
    DataIdentifier[] dataIdentifiers = dataServerImpl.getDataIdentifiers(outputContext, user, vcdID);
    for (int i = 0; i < dataIdentifiers.length; i++) {
        for (int j = 0; j < variableSpecs.getVariableNames().length; j++) {
            if (variableSpecs.getVariableNames()[j].equals(dataIdentifiers[i].getName()) && VariableType.POSTPROCESSING.equals(dataIdentifiers[i].getVariableType())) {
                try {
                    // we need PostProcessOutputInfo
                    exportServiceImpl.fireExportProgress(jobID, vcdID, "Read PostProcess", 0.0);
                    dataProcessingOutputInfo = (DataProcessingOutputInfo) dataServerImpl.doDataOperation(user, new DataOperation.DataProcessingOutputInfoOP(vcdID, false, outputContext));
                    break;
                } catch (Exception e) {
                    throw new DataAccessException("Export variable '" + variableSpecs.getVariableNames()[j] + "' is PostProcessing type.  Error reading PostProcessing data: " + e.getClass().getName() + " " + e.getMessage());
                }
            }
        }
    }
    long lastUpdateTime = 0;
    switch(rasterSpecs.getFormat()) {
        case NRRD_SINGLE:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            NrrdInfo nrrdInfo = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                            }
                            nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            return new NrrdInfo[] { nrrdInfo };
                        }
                    case GEOMETRY_SLICE:
                        {
                            NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createSingleFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, rasterSpecs, timeSpecs2);
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-snglslice", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                            }
                            sliceNrrdInfo = NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            return new NrrdInfo[] { sliceNrrdInfo };
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        case NRRD_BY_TIME:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            NRRDHelper nrrdHelper = NRRDHelper.getSizeCheckedNrrdHelper(variableSpecs, mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timefull", jobID, vcdID, progressIndex, progressEnd);
                                progressIndex++;
                                NrrdInfo nrrdInfo = nrrdHelper.createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
                                nrrdinfoV.add(nrrdInfo);
                                for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                                NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    case GEOMETRY_SLICE:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-timeslice", jobID, vcdID, progressIndex, progressEnd);
                                progressIndex++;
                                NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createTimeFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs, timeSpecs2.getAllTimes()[j], rasterSpecs);
                                nrrdinfoV.add(sliceNrrdInfo);
                                for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                                NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        case NRRD_BY_VARIABLE:
            {
                switch(geometrySpecs.getModeID()) {
                    case GEOMETRY_FULL:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                NRRDHelper nrrdhelHelper = new NRRDHelper(variableSpecs.getVariableNames()[i], mesh.getISize(), mesh.getExtent(), dataProcessingOutputInfo);
                                NrrdInfo nrrdInfo = nrrdhelHelper.createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
                                nrrdinfoV.add(nrrdInfo);
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    NRRDHelper.appendDoubleData(nrrdInfo, fileDataContainerManager, data, variableSpecs.getVariableNames()[i]);
                                }
                                nrrdInfo = NrrdWriter.writeNRRD(nrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    case GEOMETRY_SLICE:
                        {
                            Vector<NrrdInfo> nrrdinfoV = new Vector<NrrdInfo>();
                            int progressIndex = 1;
                            int progressEnd = variableSpecs.getVariableNames().length * (timeSpecs2.getEndTimeIndex() - timeSpecs2.getBeginTimeIndex() + 1);
                            for (int i = 0; i < variableSpecs.getVariableNames().length; i++) {
                                NrrdInfo sliceNrrdInfo = createSliceNrrdHelper(mesh, dataProcessingOutputInfo, vcdID, variableSpecs, timeSpecs2, geometrySpecs, rasterSpecs, fileDataContainerManager).createVariableFullNrrdInfo(fileDataContainerManager, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2, rasterSpecs);
                                nrrdinfoV.add(sliceNrrdInfo);
                                for (int j = timeSpecs2.getBeginTimeIndex(); j <= timeSpecs2.getEndTimeIndex(); j++) {
                                    lastUpdateTime = fireThrottledProgress(exportServiceImpl, lastUpdateTime, "NRRD-varsfull", jobID, vcdID, progressIndex, progressEnd);
                                    progressIndex++;
                                    double[] data = dataServerImpl.getSimDataBlock(outputContext, user, vcdID, variableSpecs.getVariableNames()[i], timeSpecs2.getAllTimes()[j]).getData();
                                    appendSlice(variableSpecs.getVariableNames()[i], data, sliceNrrdInfo, mesh, geometrySpecs, fileDataContainerManager);
                                }
                                NrrdWriter.writeNRRD(sliceNrrdInfo, fileDataContainerManager);
                            }
                            if (nrrdinfoV.size() > 0) {
                                NrrdInfo[] nrrdinfoArr = new NrrdInfo[nrrdinfoV.size()];
                                nrrdinfoV.copyInto(nrrdinfoArr);
                                return nrrdinfoArr;
                            }
                            return null;
                        }
                    default:
                        {
                            throw new DataAccessException("NRRD export from slice not yet supported");
                        }
                }
            }
        default:
            {
                throw new DataAccessException("Multiple NRRD file export not yet supported");
            }
    }
}
Also used : DataOperation(cbit.vcell.simdata.DataOperation) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataIdentifier(cbit.vcell.simdata.DataIdentifier) NrrdInfo(cbit.vcell.export.nrrd.NrrdInfo) Point(java.awt.Point) RemoteException(java.rmi.RemoteException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MathException(cbit.vcell.math.MathException) CartesianMesh(cbit.vcell.solvers.CartesianMesh) DataProcessingOutputInfo(cbit.vcell.simdata.DataOperationResults.DataProcessingOutputInfo) Vector(java.util.Vector) DataAccessException(org.vcell.util.DataAccessException)

Example 54 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class FVSolverStandalone method writeVCGAndResampleFieldData.

protected void writeVCGAndResampleFieldData() throws SolverException {
    fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_PROC_GEOM);
    try {
        // write subdomains file
        SubdomainInfo.write(new File(getSaveDirectory(), baseName + SimDataConstants.SUBDOMAINS_FILE_SUFFIX), simTask.getSimulation().getMathDescription());
        PrintWriter pw = new PrintWriter(new FileWriter(new File(getSaveDirectory(), baseName + SimDataConstants.VCG_FILE_EXTENSION)));
        GeometryFileWriter.write(pw, getResampledGeometry());
        pw.close();
        FieldDataIdentifierSpec[] argFieldDataIDSpecs = simTask.getSimulationJob().getFieldDataIdentifierSpecs();
        if (argFieldDataIDSpecs != null && argFieldDataIDSpecs.length > 0) {
            fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_RESAMPLE_FD);
            FieldFunctionArguments psfFieldFunc = null;
            Variable var = simTask.getSimulationJob().getSimulationSymbolTable().getVariable(Simulation.PSF_FUNCTION_NAME);
            if (var != null) {
                FieldFunctionArguments[] ffas = FieldUtilities.getFieldFunctionArguments(var.getExpression());
                if (ffas == null || ffas.length == 0) {
                    throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
                } else {
                    Expression newexp;
                    try {
                        newexp = new Expression(ffas[0].infix());
                        if (!var.getExpression().compareEqual(newexp)) {
                            throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
                        }
                        psfFieldFunc = ffas[0];
                    } catch (ExpressionException e) {
                        e.printStackTrace();
                        throw new DataAccessException(e.getMessage());
                    }
                }
            }
            boolean[] bResample = new boolean[argFieldDataIDSpecs.length];
            Arrays.fill(bResample, true);
            for (int i = 0; i < argFieldDataIDSpecs.length; i++) {
                argFieldDataIDSpecs[i].getFieldFuncArgs().getTime().bindExpression(simTask.getSimulationJob().getSimulationSymbolTable());
                if (argFieldDataIDSpecs[i].getFieldFuncArgs().equals(psfFieldFunc)) {
                    bResample[i] = false;
                }
            }
            int numMembraneElements = getResampledGeometry().getGeometrySurfaceDescription().getSurfaceCollection().getTotalPolygonCount();
            CartesianMesh simpleMesh = CartesianMesh.createSimpleCartesianMesh(getResampledGeometry().getOrigin(), getResampledGeometry().getExtent(), simTask.getSimulation().getMeshSpecification().getSamplingSize(), getResampledGeometry().getGeometrySurfaceDescription().getRegionImage());
            String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
            DataSetControllerImpl dsci = new DataSetControllerImpl(null, getSaveDirectory().getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
            dsci.writeFieldFunctionData(null, argFieldDataIDSpecs, bResample, simpleMesh, simResampleInfoProvider, numMembraneElements, HESM_OVERWRITE_AND_CONTINUE);
        }
    } catch (Exception e) {
        throw new SolverException(e.getMessage());
    }
}
Also used : Variable(cbit.vcell.math.Variable) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) FileWriter(java.io.FileWriter) ExpressionException(cbit.vcell.parser.ExpressionException) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) Expression(cbit.vcell.parser.Expression) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) SolverException(cbit.vcell.solver.SolverException) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException) PrintWriter(java.io.PrintWriter)

Example 55 with DataAccessException

use of org.vcell.util.DataAccessException in project vcell by virtualcell.

the class FiniteVolumeFileWriter method writeFieldData.

/**
 * # Field Data
 * FIELD_DATA_BEGIN
 * #id, name, varname, time filename
 * 0 _VCell_FieldData_0 FRAP_binding_ALPHA rfB 0.1 \\users\\fgao\\SimID_22489731_0_FRAP_binding_ALPHA_rfB_0_1.fdat
 * FIELD_DATA_END
 * @throws FileNotFoundException
 * @throws ExpressionException
 * @throws DataAccessException
 */
private void writeFieldData() throws FileNotFoundException, ExpressionException, DataAccessException {
    FieldDataIdentifierSpec[] fieldDataIDSpecs = simTask.getSimulationJob().getFieldDataIdentifierSpecs();
    if (fieldDataIDSpecs == null || fieldDataIDSpecs.length == 0) {
        return;
    }
    String secondarySimDataDir = PropertyLoader.getProperty(PropertyLoader.secondarySimDataDirInternalProperty, null);
    DataSetControllerImpl dsci = new DataSetControllerImpl(null, workingDirectory.getParentFile(), secondarySimDataDir == null ? null : new File(secondarySimDataDir));
    printWriter.println("# Field Data");
    printWriter.println("FIELD_DATA_BEGIN");
    printWriter.println("#id, type, new name, name, varname, time, filename");
    FieldFunctionArguments psfFieldFunc = null;
    Variable var = simTask.getSimulationJob().getSimulationSymbolTable().getVariable(Simulation.PSF_FUNCTION_NAME);
    if (var != null) {
        FieldFunctionArguments[] ffas = FieldUtilities.getFieldFunctionArguments(var.getExpression());
        if (ffas == null || ffas.length == 0) {
            throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
        } else {
            Expression newexp = new Expression(ffas[0].infix());
            if (!var.getExpression().compareEqual(newexp)) {
                throw new DataAccessException("Point Spread Function " + Simulation.PSF_FUNCTION_NAME + " can only be a single field function.");
            }
            psfFieldFunc = ffas[0];
        }
    }
    int index = 0;
    HashSet<FieldDataIdentifierSpec> uniqueFieldDataIDSpecs = new HashSet<FieldDataIdentifierSpec>();
    uniqueFieldDataNSet = new HashSet<FieldDataNumerics>();
    for (int i = 0; i < fieldDataIDSpecs.length; i++) {
        if (!uniqueFieldDataIDSpecs.contains(fieldDataIDSpecs[i])) {
            FieldFunctionArguments ffa = fieldDataIDSpecs[i].getFieldFuncArgs();
            File newResampledFieldDataFile = new File(workingDirectory, SimulationData.createCanonicalResampleFileName((VCSimulationDataIdentifier) simTask.getSimulationJob().getVCDataIdentifier(), fieldDataIDSpecs[i].getFieldFuncArgs()));
            uniqueFieldDataIDSpecs.add(fieldDataIDSpecs[i]);
            VariableType varType = fieldDataIDSpecs[i].getFieldFuncArgs().getVariableType();
            SimDataBlock simDataBlock = dsci.getSimDataBlock(null, fieldDataIDSpecs[i].getExternalDataIdentifier(), fieldDataIDSpecs[i].getFieldFuncArgs().getVariableName(), fieldDataIDSpecs[i].getFieldFuncArgs().getTime().evaluateConstant());
            VariableType dataVarType = simDataBlock.getVariableType();
            if (varType.equals(VariableType.UNKNOWN)) {
                varType = dataVarType;
            } else if (!varType.equals(dataVarType)) {
                throw new IllegalArgumentException("field function variable type (" + varType.getTypeName() + ") doesn't match real variable type (" + dataVarType.getTypeName() + ")");
            }
            if (psfFieldFunc != null && psfFieldFunc.equals(ffa)) {
                psfFieldIndex = index;
            }
            String fieldDataID = "_VCell_FieldData_" + index;
            printWriter.println(index + " " + varType.getTypeName() + " " + fieldDataID + " " + ffa.getFieldName() + " " + ffa.getVariableName() + " " + ffa.getTime().infix() + " " + newResampledFieldDataFile);
            uniqueFieldDataNSet.add(new FieldDataNumerics(SimulationData.createCanonicalFieldFunctionSyntax(ffa.getFieldName(), ffa.getVariableName(), ffa.getTime().evaluateConstant(), ffa.getVariableType().getTypeName()), fieldDataID));
            index++;
        }
    }
    if (psfFieldIndex >= 0) {
        printWriter.println("PSF_FIELD_DATA_INDEX " + psfFieldIndex);
    }
    printWriter.println("FIELD_DATA_END");
    printWriter.println();
}
Also used : FilamentVariable(cbit.vcell.math.FilamentVariable) VolVariable(cbit.vcell.math.VolVariable) ReservedVariable(cbit.vcell.math.ReservedVariable) ParameterVariable(cbit.vcell.math.ParameterVariable) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) MembraneRandomVariable(cbit.vcell.math.MembraneRandomVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) MemVariable(cbit.vcell.math.MemVariable) Variable(cbit.vcell.math.Variable) VariableType(cbit.vcell.math.VariableType) FieldFunctionArguments(cbit.vcell.field.FieldFunctionArguments) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SimDataBlock(cbit.vcell.simdata.SimDataBlock) Expression(cbit.vcell.parser.Expression) FieldDataIdentifierSpec(cbit.vcell.field.FieldDataIdentifierSpec) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) File(java.io.File) DataAccessException(org.vcell.util.DataAccessException) HashSet(java.util.HashSet)

Aggregations

DataAccessException (org.vcell.util.DataAccessException)345 KeyValue (org.vcell.util.document.KeyValue)82 XmlParseException (cbit.vcell.xml.XmlParseException)80 ExpressionException (cbit.vcell.parser.ExpressionException)78 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)71 SQLException (java.sql.SQLException)67 IOException (java.io.IOException)60 MathException (cbit.vcell.math.MathException)59 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)46 BigString (org.vcell.util.BigString)45 User (org.vcell.util.document.User)42 FileNotFoundException (java.io.FileNotFoundException)38 ResultSet (java.sql.ResultSet)38 PropertyVetoException (java.beans.PropertyVetoException)37 File (java.io.File)34 PermissionException (org.vcell.util.PermissionException)34 Statement (java.sql.Statement)33 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)32 BioModelInfo (org.vcell.util.document.BioModelInfo)29 Vector (java.util.Vector)26