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