Search in sources :

Example 36 with DataAccessException

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

the class ClientDocumentManager method addUserToGroup.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 5:43:44 PM)
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
public GeometryInfo addUserToGroup(GeometryInfo geometryInfo, String userToAdd) throws DataAccessException {
    try {
        // 
        // publish from database
        // 
        GeometryInfo newGeometryInfo = (GeometryInfo) addUserToGroup0(geometryInfo, VersionableType.Geometry, geoInfoHash, userToAdd);
        // //
        // // delete Geometry from cache
        // //
        // xmlHash.remove(geometryInfo.getVersion().getVersionKey());
        // //
        // // delete any MathModelMetaData's that use this GeometryInfo from cache
        // //
        // MathModelInfo referencedMathModelInfos[] = getMathModelReferences(geometryInfo);
        // for (int i = 0; i < referencedMathModelInfos.length; i++){
        // xmlHash.remove(referencedMathModelInfos[i].getVersion().getVersionKey());
        // }
        // //
        // // delete any BioModelMetaData's that use this GeometryInfo from cache
        // //
        // BioModelInfo referencedBioModelInfos[] = getBioModelReferences(geometryInfo);
        // for (int i = 0; i < referencedBioModelInfos.length; i++){
        // xmlHash.remove(referencedBioModelInfos[i].getVersion().getVersionKey());
        // }
        fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, geometryInfo, newGeometryInfo));
        return newGeometryInfo;
    } catch (RemoteProxyException e) {
        handleRemoteProxyException(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : GeometryInfo(cbit.vcell.geometry.GeometryInfo) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 37 with DataAccessException

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

the class ClientDocumentManager method initAllDatabaseInfos.

/**
 * Insert the method's description here.
 * Creation date: (9/25/2003 7:45:19 AM)
 * @return cbit.vcell.modeldb.VCInfoContainer
 */
public synchronized void initAllDatabaseInfos() throws DataAccessException {
    clear();
    VCInfoContainer vcInfoContainer = null;
    try {
        System.out.println("ClientDocumentManager.initAllDatabaseInfos()");
        long time1 = System.currentTimeMillis();
        // 
        // gets BioModelMetaDatas, MathModelMetaDatas, all VersionInfos, and ResultSetInfos
        // 
        vcInfoContainer = sessionManager.getUserMetaDbServer().getVCInfoContainer();
        PerformanceMonitorEvent pme = new PerformanceMonitorEvent(this, getUser(), new PerformanceData("ClientDocumentManager.initAllDatabaseInfos()", MessageEvent.LOGON_STAT, new PerformanceDataEntry[] { new PerformanceDataEntry("remote call duration", Double.toString(((double) System.currentTimeMillis() - time1) / 1000.0)) }));
    } catch (RemoteProxyException e) {
        handleRemoteProxyException(e);
        throw new DataAccessException("RemoteProxyException: " + e.getMessage());
    }
    // 
    // BioModelInfos
    // 
    {
        bioModelInfoHash.clear();
        BioModelInfo[] bioModelInfos = vcInfoContainer.getBioModelInfos();
        if (bioModelInfos != null) {
            for (int i = 0; i < bioModelInfos.length; i++) {
                bioModelInfoHash.put(bioModelInfos[i].getVersion().getVersionKey(), bioModelInfos[i]);
            }
        }
    }
    // 
    // Geometries
    // 
    {
        geoInfoHash.clear();
        GeometryInfo[] geometryInfos = vcInfoContainer.getGeometryInfos();
        if (geometryInfos != null) {
            for (int i = 0; i < geometryInfos.length; i++) {
                geoInfoHash.put(geometryInfos[i].getVersion().getVersionKey(), geometryInfos[i]);
            }
        }
    }
    // 
    // MathModelInfos
    // 
    {
        mathModelInfoHash.clear();
        MathModelInfo[] mathModelInfos = vcInfoContainer.getMathModelInfos();
        if (mathModelInfos != null) {
            for (int i = 0; i < mathModelInfos.length; i++) {
                mathModelInfoHash.put(mathModelInfos[i].getVersion().getVersionKey(), mathModelInfos[i]);
            }
        }
    }
    // 
    // VCImageInfos
    // 
    {
        imgInfoHash.clear();
        VCImageInfo[] vcImageInfos = vcInfoContainer.getVCImageInfos();
        if (vcImageInfos != null) {
            for (int i = 0; i < vcImageInfos.length; i++) {
                imgInfoHash.put(vcImageInfos[i].getVersion().getVersionKey(), vcImageInfos[i]);
            }
        }
    }
    fireDatabaseRefresh(new DatabaseEvent(this, DatabaseEvent.REFRESH, null, null));
}
Also used : VCInfoContainer(org.vcell.util.document.VCInfoContainer) PerformanceData(cbit.rmi.event.PerformanceData) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent) PerformanceDataEntry(cbit.rmi.event.PerformanceDataEntry) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 38 with DataAccessException

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

the class ASCIIExporter method exportParticleData.

/**
 * Insert the method's description here.
 * Creation date: (1/12/00 5:00:28 PM)
 * @return cbit.vcell.export.server.ExportOutput[]
 * @param dsc cbit.vcell.server.DataSetController
 * @param timeSpecs cbit.vcell.export.server.TimeSpecs
 * @throws IOException
 */
private List<ExportOutput> exportParticleData(OutputContext outputContext, long jobID, User user, DataServerImpl dataServerImpl, ExportSpecs exportSpecs, ASCIISpecs asciiSpecs, FileDataContainerManager fileDataContainerManager) throws DataAccessException, IOException {
    VCDataIdentifier vcdID = exportSpecs.getVCDataIdentifier();
    TimeSpecs timeSpecs = exportSpecs.getTimeSpecs();
    String simID = vcdID.getID();
    String dataType = ".csv";
    // in switched format, how many rows for each particle
    final int N_PARTICLE_PIECES = 1;
    // get parameters
    boolean switchRowsColumns = asciiSpecs.getSwitchRowsColumns();
    double[] allTimes = timeSpecs.getAllTimes();
    int beginIndex = timeSpecs.getBeginTimeIndex();
    int endIndex = timeSpecs.getEndTimeIndex();
    ParticleDataBlock particleDataBlk = dataServerImpl.getParticleDataBlock(user, vcdID, allTimes[beginIndex]);
    VariableSpecs vs = exportSpecs.getVariableSpecs();
    VCAssert.assertValid(vs);
    String[] vnames = vs.getVariableNames();
    if (vnames.length == 0) {
        throw new IllegalArgumentException("No variables selected");
    }
    // need array for SimulationDescription, later
    final String[] currentVariableName = new String[1];
    ArrayList<ExportOutput> rval = new ArrayList<>(vnames.length);
    Set<String> species = particleDataBlk.getSpecies();
    ParticleProgress particleProgress = null;
    for (String vcellName : vnames) {
        String smoldynSpecies = null;
        for (int i = 0; smoldynSpecies == null && i < SMOLDYN_KEYWORDS_USED.length; i++) {
            SmoldynKeyword kw = SMOLDYN_KEYWORDS_USED[i];
            String smoldynName = SmoldynVCellMapper.vcellToSmoldyn(vcellName, kw);
            if (species.contains(smoldynName)) {
                smoldynSpecies = smoldynName;
            }
        }
        if (smoldynSpecies == null) {
            throw new DataAccessException("Unable to find match for variable name " + vcellName + " in " + StringUtils.join(species, ", "));
        }
        List<Coordinate> particles = particleDataBlk.getCoordinates(smoldynSpecies);
        int numberOfParticles = particles.size();
        int numberOfTimes = endIndex - beginIndex + 1;
        if (particleProgress != null) {
            particleProgress.nextName();
        } else {
            particleProgress = new ParticleProgress(jobID, vcdID, vnames.length, numberOfTimes, numberOfParticles);
        }
        // now make csv formatted data
        StringBuilder header = new StringBuilder();
        StringBuilder[] dataLines = null;
        final int NUMBER_HEADING_LINES = SwitchedRowsHeading.DATA.ordinal();
        if (switchRowsColumns) {
            dataLines = stringBuilderArray(numberOfParticles * N_PARTICLE_PIECES + NUMBER_HEADING_LINES);
            dataLines[SwitchedRowsHeading.TIME.ordinal()].append("Time,");
            final String particleLine = "Particle" + StringUtils.repeat(",x,y,z", numberOfTimes);
            dataLines[SwitchedRowsHeading.PARTICLE.ordinal()].append(particleLine);
            dataLines[SwitchedRowsHeading.XYZ.ordinal()].append("#,");
            // "first data line"
            final int FDL = SwitchedRowsHeading.DATA.ordinal();
            for (int i = 0; i < numberOfParticles; i++) {
                dataLines[FDL + N_PARTICLE_PIECES * i].append(i);
                dataLines[FDL + N_PARTICLE_PIECES * i].append(',');
            }
        } else {
            dataLines = stringBuilderArray(numberOfTimes);
        }
        currentVariableName[0] = vcellName;
        SimulationDescription simulationDescription = new SimulationDescription(outputContext, user, dataServerImpl, vcdID, false, currentVariableName);
        header.append(simulationDescription.getHeader(dataType));
        if (switchRowsColumns) {
        // implemented using first few data lines
        } else {
            header.append(",Time\n");
            header.append("Particle #,,");
            for (int k = 0; k < numberOfParticles; k++) {
                header.append(k + StringUtils.repeat(',', N_PARTICLE_PIECES));
            }
            header.append("\n,,");
            for (int k = 0; k < numberOfParticles; k++) {
                header.append("x,y,z,");
            }
        }
        final char COMMA = ',';
        int nextTimeIndex = particleProgress.nextTimeIndex(0, false);
        for (int i = beginIndex; i <= endIndex; i++) {
            particleDataBlk = dataServerImpl.getParticleDataBlock(user, vcdID, allTimes[i]);
            particles = particleDataBlk.getCoordinates(smoldynSpecies);
            if (i >= nextTimeIndex) {
                nextTimeIndex = particleProgress.nextTimeIndex(i, true);
            }
            if (switchRowsColumns) {
                // "first data line"
                final int FDL = SwitchedRowsHeading.DATA.ordinal();
                StringBuilder timeSb = dataLines[SwitchedRowsHeading.TIME.ordinal()];
                timeSb.append(allTimes[i]);
                timeSb.append(",,,");
                for (int j = 0; j < numberOfParticles; j++) {
                    StringBuilder sb = dataLines[FDL + N_PARTICLE_PIECES * j];
                    Coordinate coordinate = particles.get(j);
                    sb.append(coordinate.getX());
                    sb.append(COMMA);
                    sb.append(coordinate.getY());
                    sb.append(COMMA);
                    sb.append(coordinate.getZ());
                    sb.append(COMMA);
                }
            } else {
                StringBuilder particleSb = dataLines[i - beginIndex];
                particleSb.append(COMMA);
                particleSb.append(allTimes[i]);
                particleSb.append(COMMA);
                for (int j = 0; j < numberOfParticles; j++) {
                    Coordinate coordinate = particles.get(j);
                    particleSb.append(coordinate.getX());
                    particleSb.append(COMMA);
                    particleSb.append(coordinate.getY());
                    particleSb.append(COMMA);
                    particleSb.append(coordinate.getZ());
                }
            }
        }
        particleProgress.endOfTimes();
        final String dataID = vcellName + "_Particles";
        ExportOutput exportOutputCSV = new ExportOutput(true, dataType, simID, dataID, fileDataContainerManager);
        fileDataContainerManager.append(exportOutputCSV.getFileDataContainerID(), header.toString());
        int nextDataIndex = particleProgress.nextDataIndex(0, false);
        StringBuilder all = new StringBuilder();
        for (int i = 0; i < dataLines.length; i++) {
            final char NEWLINE = '\n';
            all.append(dataLines[i]);
            // kill reference to allow garbage collection
            dataLines[i] = null;
            all.append(NEWLINE);
            if (i >= nextDataIndex) {
                nextDataIndex = particleProgress.nextDataIndex(i, true);
            }
        }
        fileDataContainerManager.append(exportOutputCSV.getFileDataContainerID(), all.toString());
        rval.add(exportOutputCSV);
    }
    return rval;
}
Also used : ArrayList(java.util.ArrayList) SmoldynKeyword(org.vcell.solver.smoldyn.SmoldynVCellMapper.SmoldynKeyword) SinglePoint(cbit.vcell.geometry.SinglePoint) Coordinate(org.vcell.util.Coordinate) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DataAccessException(org.vcell.util.DataAccessException) ParticleDataBlock(cbit.vcell.simdata.ParticleDataBlock)

Example 39 with DataAccessException

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

the class VCellProxyHandler method getTimePoints.

@Override
public List<Double> getTimePoints(SimulationDataSetRef simulationDataSetRef) throws ThriftDataAccessException {
    try {
        VtkManager vtkManager = vcellClientDataService.getVtkManager(simulationDataSetRef);
        ArrayList<Double> timesList = new ArrayList<Double>();
        if (vtkManager != null) {
            double[] timesArray = vtkManager.getDataSetTimes();
            for (int i = 0; i < timesArray.length; i++) {
                timesList.add(new Double(timesArray[i]));
            }
            return timesList;
        }
        return null;
    } catch (FileNotFoundException | DataAccessException e) {
        e.printStackTrace();
        throw new ThriftDataAccessException(e.getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) VtkManager(cbit.vcell.simdata.VtkManager) DataAccessException(org.vcell.util.DataAccessException)

Example 40 with DataAccessException

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

the class ClientDocumentManager method removeUserFromGroup.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 5:43:44 PM)
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
public BioModelInfo removeUserFromGroup(BioModelInfo bioModelInfo, String userToRemove) throws DataAccessException {
    try {
        // 
        // publish from database
        // 
        BioModelInfo newBioModelInfo = (BioModelInfo) removeUserFromGroup0(bioModelInfo, VersionableType.BioModelMetaData, bioModelInfoHash, userToRemove);
        // 
        // delete BioModelMetaData from cache
        // 
        xmlHash.remove(bioModelInfo.getVersion().getVersionKey());
        fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, bioModelInfo, newBioModelInfo));
        return newBioModelInfo;
    } catch (RemoteProxyException e) {
        handleRemoteProxyException(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : BioModelInfo(org.vcell.util.document.BioModelInfo) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

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