Search in sources :

Example 21 with XMLSource

use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.

the class ServerDocumentManager method getBioModelXML.

/**
 * Insert the method's description here.
 * Creation date: (3/29/2004 4:04:16 PM)
 * @return java.lang.String
 * @param vType cbit.sql.VersionableType
 * @param vKey cbit.sql.KeyValue
 */
public String getBioModelXML(QueryHashtable dbc, User user, KeyValue bioModelKey, boolean bRegenerateXML) throws DataAccessException {
    String bioModelXML = null;
    try {
        bioModelXML = dbServer.getDBTopLevel().getBioModelXML(user, bioModelKey, true);
        if (bioModelXML != null) {
            if (bRegenerateXML) {
                try {
                    BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(bioModelXML));
                    return cbit.vcell.xml.XmlHelper.bioModelToXML(bioModel);
                } catch (XmlParseException e) {
                    e.printStackTrace();
                    throw new DataAccessException(e.getMessage(), e);
                }
            } else {
                return bioModelXML;
            }
        }
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    } catch (ObjectNotFoundException e) {
    // 
    // not stored as XML currently, retrieve traditional way.
    // 
    }
    try {
        bioModelXML = getBioModelUnresolved(dbc, user, bioModelKey);
        dbServer.insertVersionableXML(user, VersionableType.BioModelMetaData, bioModelKey, bioModelXML);
        return bioModelXML;
    } catch (java.sql.SQLException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    } catch (cbit.vcell.xml.XmlParseException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) XmlParseException(cbit.vcell.xml.XmlParseException) XMLSource(cbit.vcell.xml.XMLSource) DataAccessException(org.vcell.util.DataAccessException)

Example 22 with XMLSource

use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.

the class VCDatabaseScanner method scanMathModels.

public void scanMathModels(VCDatabaseVisitor databaseVisitor, PrintStream logFilePrintStream, User[] users, KeyValue singleMathmodelKey, HashSet<KeyValue> includeHash, HashSet<KeyValue> excludeHash, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
    BadMathVisitor badMathVisitor = null;
    if (databaseVisitor instanceof BadMathVisitor) {
        badMathVisitor = (BadMathVisitor) databaseVisitor;
    }
    final boolean isBadMathVisitor = badMathVisitor != null;
    if (users == null) {
        users = getAllUsers();
    }
    try {
        // start visiting models and writing log
        logFilePrintStream.println("Start scanning mathmodels ......");
        logFilePrintStream.println("\n");
        for (int i = 0; i < users.length; i++) {
            User user = users[i];
            MathModelInfo[] mathInfos = dbServerImpl.getMathModelInfos(user, false);
            for (int j = 0; j < mathInfos.length; j++) {
                if (singleMathmodelKey != null && !mathInfos[j].getVersion().getVersionKey().compareEqual(singleMathmodelKey)) {
                    System.out.println("skipping geometry, not the single one that we wanted");
                    continue;
                }
                if (excludeHash != null && excludeHash.contains(mathInfos[j].getVersion().getVersionKey())) {
                    System.out.println("skipping geometry with key '" + mathInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (includeHash != null && !includeHash.contains(mathInfos[j].getVersion().getVersionKey())) {
                    System.out.println("not including geometry with key '" + mathInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (!databaseVisitor.filterMathModel(mathInfos[j])) {
                    continue;
                }
                KeyValue vk = null;
                try {
                    vk = mathInfos[j].getVersion().getVersionKey();
                    BigString mathModelXML = dbServerImpl.getMathModelXML(user, mathInfos[j].getVersion().getVersionKey());
                    MathModel mathModel = cbit.vcell.xml.XmlHelper.XMLToMathModel(new XMLSource(mathModelXML.toString()));
                    mathModel.refreshDependencies();
                    databaseVisitor.visitMathModel(mathModel, logFilePrintStream);
                } catch (Exception e2) {
                    if (isBadMathVisitor) {
                        badMathVisitor.unableToLoad(vk, e2);
                    }
                    lg.error(e2.getMessage(), e2);
                    if (bAbortOnDataAccessException) {
                        throw e2;
                    }
                }
            }
        }
        logFilePrintStream.close();
    } catch (Exception e) {
        System.err.println("error writing to log file.");
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) MathModelInfo(org.vcell.util.document.MathModelInfo) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) RemoteException(java.rmi.RemoteException)

Example 23 with XMLSource

use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.

the class VCDatabaseScanner method scanBioModels.

public void scanBioModels(BioModelVisitor databaseVisitor, Logger logger, User[] users, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
    if (users == null) {
        users = getAllUsers();
    }
    // start visiting models and writing log
    logger.info("Start scanning bio-models......");
    for (int i = 0; i < users.length; i++) {
        User user = users[i];
        BioModelInfo[] bioModelInfos = dbServerImpl.getBioModelInfos(user, false);
        for (int j = 0; j < bioModelInfos.length; j++) {
            BioModelInfo bmi = bioModelInfos[j];
            if (!databaseVisitor.filterBioModel(bmi)) {
                continue;
            }
            try {
                BigString bioModelXML = dbServerImpl.getBioModelXML(user, bioModelInfos[j].getVersion().getVersionKey());
                BioModel bioModel = cbit.vcell.xml.XmlHelper.XMLToBioModel(new XMLSource(bioModelXML.toString()));
                bioModel.refreshDependencies();
                if (logger.isDebugEnabled()) {
                    // + bioModelInfos[j].getVersion().getName() + " -----> ");
                    logger.debug("---- " + (j + 1) + " ----> " + bioModel.getName());
                }
                databaseVisitor.visitBioModel(bioModel);
            } catch (Exception e2) {
                logger.warn("exception biomodel " + bmi.getModelKey(), e2);
                if (bAbortOnDataAccessException) {
                    throw e2;
                }
            }
        }
    }
}
Also used : User(org.vcell.util.document.User) BioModel(cbit.vcell.biomodel.BioModel) BioModelInfo(org.vcell.util.document.BioModelInfo) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) RemoteException(java.rmi.RemoteException)

Example 24 with XMLSource

use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.

the class ClientDocumentManager method getMathModelFromDatabaseXML.

/**
 * Insert the method's description here.
 * Creation date: (9/22/2004 5:22:40 PM)
 * @return cbit.vcell.mathmodel.MathModel
 * @param mathModelXML java.lang.String
 */
private MathModel getMathModelFromDatabaseXML(XMLHolder<MathModel> mathModelXML) throws DataAccessException {
    try {
        MathModel mm = mathModelXML.getDocument();
        if (mm == null) {
            mm = XmlHelper.XMLToMathModel(new XMLSource(mathModelXML.getXmlString()));
        }
        cacheSimulations(mm.getSimulations());
        mm.refreshDependencies();
        try {
            if (mm.getMathDescription().getGeometry().getDimension() > 0 && mm.getMathDescription().getGeometry().getGeometrySurfaceDescription().getGeometricRegions() == null) {
                mm.getMathDescription().getGeometry().getGeometrySurfaceDescription().updateAll();
            }
        } catch (Exception e) {
            e.printStackTrace(System.out);
            throw new DataAccessException("Geometric surface generation error:\n" + e.getMessage());
        }
        return mm;
    } catch (XmlParseException e) {
        e.printStackTrace();
        throw new DataAccessException(e.getClass().getName() + ": " + e.getMessage());
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) XmlParseException(cbit.vcell.xml.XmlParseException) XMLSource(cbit.vcell.xml.XMLSource) 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) DataAccessException(org.vcell.util.DataAccessException)

Example 25 with XMLSource

use of cbit.vcell.xml.XMLSource in project vcell by virtualcell.

the class ClientDocumentManager method getBioModelXML.

/**
 * Insert the method's description here.
 * Creation date: (3/29/2004 4:04:16 PM)
 * @return java.lang.String
 * @param vType cbit.sql.VersionableType
 * @param vKey cbit.sql.KeyValue
 */
private XMLHolder<BioModel> getBioModelXML(KeyValue vKey) throws DataAccessException {
    try {
        String xmlString = (String) xmlHash.get(vKey);
        if (xmlString == null) {
            BigString xmlBS = sessionManager.getUserMetaDbServer().getBioModelXML(vKey);
            xmlString = (xmlBS != null ? xmlBS.toString() : null);
            if (xmlString != null) {
                BioModel bioModel = XmlHelper.XMLToBioModel(new XMLSource(xmlString));
                String newXmlString = XmlHelper.bioModelToXML(bioModel);
                xmlHash.put(vKey, newXmlString);
                return new XMLHolder<BioModel>(newXmlString, bioModel);
            } else {
                throw new RuntimeException("unexpected: UserMetaDbServer.getBioModelXML() returned null");
            }
        } else {
            return new XMLHolder<BioModel>(xmlString);
        }
    } catch (ObjectNotFoundException e) {
        throw new DataAccessException("BioModel (id=" + vKey + ") does not exist. It either " + "has been deleted or its reference is outdated. Please use menu 'Server->Reconnect' to update document references.");
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw FailToLoadDocumentExc.createException(e, vKey, this);
    }
}
Also used : BioModel(cbit.vcell.biomodel.BioModel) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) BigString(org.vcell.util.BigString) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) DataAccessException(org.vcell.util.DataAccessException) 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)

Aggregations

XMLSource (cbit.vcell.xml.XMLSource)50 BioModel (cbit.vcell.biomodel.BioModel)37 XmlParseException (cbit.vcell.xml.XmlParseException)31 DataAccessException (org.vcell.util.DataAccessException)27 SimulationContext (cbit.vcell.mapping.SimulationContext)22 BigString (org.vcell.util.BigString)22 KeyValue (org.vcell.util.document.KeyValue)21 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)19 Simulation (cbit.vcell.solver.Simulation)18 SQLException (java.sql.SQLException)15 User (org.vcell.util.document.User)15 BioModelInfo (org.vcell.util.document.BioModelInfo)13 MathException (cbit.vcell.math.MathException)12 ExpressionException (cbit.vcell.parser.ExpressionException)12 PropertyVetoException (java.beans.PropertyVetoException)12 MappingException (cbit.vcell.mapping.MappingException)11 MathModel (cbit.vcell.mathmodel.MathModel)11 IOException (java.io.IOException)11 MathDescription (cbit.vcell.math.MathDescription)10 File (java.io.File)10