Search in sources :

Example 46 with XmlParseException

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

the class VCDatabaseScanner method scanGeometries.

/**
 * Insert the method's description here.
 * Creation date: (2/2/01 3:40:29 PM)
 * @throws DataAccessException
 * @throws XmlParseException
 */
public void scanGeometries(VCDatabaseVisitor databaseVisitor, PrintStream logFilePrintStream, User[] users, KeyValue singleGeometryKey, HashSet<KeyValue> includeHash, HashSet<KeyValue> excludeHash, boolean bAbortOnDataAccessException) throws DataAccessException, XmlParseException {
    if (users == null) {
        users = getAllUsers();
    }
    try {
        // start visiting models and writing log
        logFilePrintStream.println("Start scanning geometries......");
        logFilePrintStream.println("\n");
        for (int i = 0; i < users.length; i++) {
            User user = users[i];
            GeometryInfo[] geoInfos = dbServerImpl.getGeometryInfos(user, false);
            for (int j = 0; j < geoInfos.length; j++) {
                if (singleGeometryKey != null && !geoInfos[j].getVersion().getVersionKey().compareEqual(singleGeometryKey)) {
                    System.out.println("skipping geometry, not the single one that we wanted");
                    continue;
                }
                if (excludeHash != null && excludeHash.contains(geoInfos[j].getVersion().getVersionKey())) {
                    System.out.println("skipping geometry with key '" + geoInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (includeHash != null && !includeHash.contains(geoInfos[j].getVersion().getVersionKey())) {
                    System.out.println("not including geometry with key '" + geoInfos[j].getVersion().getVersionKey() + "'");
                    continue;
                }
                if (!databaseVisitor.filterGeometry(geoInfos[j])) {
                    continue;
                }
                try {
                    BigString geometryXML = dbServerImpl.getGeometryXML(user, geoInfos[j].getVersion().getVersionKey());
                    Geometry geometry = cbit.vcell.xml.XmlHelper.XMLToGeometry(new XMLSource(geometryXML.toString()));
                    geometry.refreshDependencies();
                    databaseVisitor.visitGeometry(geometry, logFilePrintStream);
                } catch (Exception 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 : Geometry(cbit.vcell.geometry.Geometry) User(org.vcell.util.document.User) GeometryInfo(cbit.vcell.geometry.GeometryInfo) 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 47 with XmlParseException

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

the class BatchTester method keyScanBioModels.

/**
 * scan biomodels for further processing, put into database table if criteria met
 * @throws DataAccessException
 * @throws XmlParseException
 */
public void keyScanBioModels(VCMultiBioVisitor databaseVisitor, Writer writer, User[] users, boolean bAbortOnDataAccessException, String statusTableName) throws DataAccessException, XmlParseException {
    assert users != null;
    try {
        PrintWriter printWriter = new PrintWriter(writer);
        // start visiting models and writing log
        printWriter.println("Start scanning bio-models......");
        printWriter.println("\n");
        Object lock = new Object();
        Connection conn = connFactory.getConnection(lock);
        PreparedStatement ps = conn.prepareStatement("insert into " + statusTableName + "(user_id,model_id) values(?,?)");
        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 {
                    KeyValue vk = bmi.getVersion().getVersionKey();
                    ps.setLong(1, convert(user.getID()));
                    ps.setLong(2, convert(vk));
                    ps.execute();
                } catch (Exception e2) {
                    lg.error(e2.getMessage(), e2);
                    printWriter.println("======= " + e2.getMessage());
                    if (bAbortOnDataAccessException) {
                        throw e2;
                    }
                }
            }
        }
        printWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) Connection(java.sql.Connection) BioModelInfo(org.vcell.util.document.BioModelInfo) PreparedStatement(java.sql.PreparedStatement) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PrintWriter(java.io.PrintWriter)

Example 48 with XmlParseException

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

the class BatchTester method keyScanMathModels.

/*
	private int boolAsInt(boolean b) {
		return b ? 1: 0;
	}
	*/
/**
 * scan math models for further processing, put into database table if criteria met
 * @throws DataAccessException
 * @throws XmlParseException
 */
public void keyScanMathModels(BadMathVisitor databaseVisitor, Writer writer, boolean bAbortOnDataAccessException, String statusTableName) throws DataAccessException, XmlParseException {
    try {
        PrintWriter printWriter = new PrintWriter(writer);
        // start visiting models and writing log
        printWriter.println("Start scanning math-models......");
        printWriter.println("\n");
        Object lock = new Object();
        Connection conn = connFactory.getConnection(lock);
        PreparedStatement ps = conn.prepareStatement("insert into " + statusTableName + "(model_id) values(?)");
        MathModelInfo[] mathModelInfos = dbServerImpl.getMathModelInfos(BatchTester.ADMINISTRATOR, true);
        for (int j = 0; j < mathModelInfos.length; j++) {
            MathModelInfo mmi = mathModelInfos[j];
            if (!databaseVisitor.filterMathModel(mmi)) {
                continue;
            }
            try {
                KeyValue vk = mmi.getVersion().getVersionKey();
                ps.setLong(1, convert(vk));
                ps.execute();
            } catch (Exception e2) {
                lg.error(e2.getMessage(), e2);
                printWriter.println("======= " + e2.getMessage());
                if (bAbortOnDataAccessException) {
                    throw e2;
                }
            }
        }
        printWriter.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) MathModelInfo(org.vcell.util.document.MathModelInfo) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) PrintWriter(java.io.PrintWriter)

Example 49 with XmlParseException

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

the class ApplicationMathTable method getOutputFunctions.

private ArrayList<AnnotatedFunction> getOutputFunctions(Connection con, KeyValue mathModelRef, KeyValue simContextRef, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
    Statement stmt = null;
    try {
        stmt = con.createStatement();
        ResultSet rset = stmt.executeQuery("SELECT * FROM " + ApplicationMathTable.table.getTableName() + " WHERE " + (simContextRef != null ? ApplicationMathTable.table.simContextRef.getUnqualifiedColName() + " = " + simContextRef.toString() : "") + (mathModelRef != null ? ApplicationMathTable.table.mathModelRef.getUnqualifiedColName() + " = " + mathModelRef.toString() : ""));
        if (!rset.next()) {
            return null;
        }
        String outputFunctionsXML = DbDriver.varchar2_CLOB_get(rset, ApplicationMathTable.table.outputFuncSmall, ApplicationMathTable.table.outputFuncLarge, dbSyntax);
        rset.close();
        if (outputFunctionsXML == null) {
            return null;
        }
        return convertOutputFunctionXMLToFuncList(outputFunctionsXML);
    } catch (XmlParseException e) {
        throw new DataAccessException(e.getMessage(), e);
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
}
Also used : Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

XmlParseException (cbit.vcell.xml.XmlParseException)49 DataAccessException (org.vcell.util.DataAccessException)35 XMLSource (cbit.vcell.xml.XMLSource)19 BigString (org.vcell.util.BigString)18 BioModel (cbit.vcell.biomodel.BioModel)16 KeyValue (org.vcell.util.document.KeyValue)16 SQLException (java.sql.SQLException)14 ExpressionException (cbit.vcell.parser.ExpressionException)12 IOException (java.io.IOException)12 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 PrintWriter (java.io.PrintWriter)9 User (org.vcell.util.document.User)9 MathException (cbit.vcell.math.MathException)8 MathModel (cbit.vcell.mathmodel.MathModel)8 Element (org.jdom.Element)8 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)8 BioModelInfo (org.vcell.util.document.BioModelInfo)7 PropertyVetoException (java.beans.PropertyVetoException)5 File (java.io.File)5