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.");
}
}
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();
}
}
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();
}
}
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();
}
}
}
Aggregations