use of cbit.vcell.xml.XmlParseException 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.XmlParseException in project vcell by virtualcell.
the class ClientDocumentManager method isChanged.
/**
* Insert the method's description here.
* Creation date: (10/28/00 12:08:30 AM)
*/
public boolean isChanged(MathModel mathModel, String mathModelXML) throws DataAccessException {
if (mathModel.getVersion() == null) {
//
return true;
} else {
//
if (!mathModel.getVersion().getName().equals(mathModel.getName())) {
return true;
}
//
if (!mathModel.getVersion().getAnnot().equals(mathModel.getDescription())) {
return true;
}
//
// check for same number of simulations as saved version
//
MathModelInfo savedMathModelInfo = getMathModelInfo(mathModel.getVersion().getVersionKey());
if (savedMathModelInfo == null) {
//
// if savedMathModelInfo is null, then the record was deleted
// while it was loaded in client (changed is true)
//
System.out.println("MathModel(" + mathModel.getVersion().getVersionKey() + ") must have been deleted, therefore isChanged() is true");
return true;
}
// MathModelMetaData savedMathModelMetaData = getMathModelMetaData(savedMathModelInfo);
// if (savedMathModelMetaData.getNumSimulations() != mathModel.getNumSimulations()){
// return true;
// }
//
// compare saved and this bioModel
//
XMLHolder<MathModel> savedMathModelXML = getMathModelXML(mathModel.getVersion().getVersionKey());
if (savedMathModelXML == null) {
// must have been deleted
return true;
}
try {
if (mathModelXML == null) {
mathModelXML = XmlHelper.mathModelToXML(mathModel);
}
return !VCMLComparator.compareEquals(savedMathModelXML.getXmlString(), mathModelXML, true);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
}
}
use of cbit.vcell.xml.XmlParseException 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.XmlParseException in project vcell by virtualcell.
the class ClientDocumentManager method saveAsNew.
/**
* Insert the method's description here.
* Creation date: (1/19/01 11:27:52 AM)
*/
public BioModel saveAsNew(BioModel bioModel, java.lang.String newName, String[] independentSims) throws DataAccessException {
try {
String bioModelXML = null;
try {
bioModel.getVCMetaData().cleanupMetadata();
bioModelXML = XmlHelper.bioModelToXML(bioModel);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
String savedBioModelXML = sessionManager.getUserMetaDbServer().saveBioModelAs(new BigString(bioModelXML), newName, independentSims).toString();
BioModel savedBioModel = getBioModelFromDatabaseXML(new XMLHolder<BioModel>(savedBioModelXML));
KeyValue savedKey = savedBioModel.getVersion().getVersionKey();
if (xmlHash.get(savedKey) == null) {
xmlHash.put(savedKey, savedBioModelXML);
}
BioModelInfo savedBioModelInfo = new BioModelInfo(savedBioModel.getVersion(), savedBioModel.getModel().getKey(), savedBioModel.createBioModelChildSummary(), VCellSoftwareVersion.fromSystemProperty());
bioModelInfoHash.put(savedKey, savedBioModelInfo);
SimulationContext[] scArr = savedBioModel.getSimulationContexts();
for (int i = 0; i < scArr.length; i++) {
updateGeometryRelatedHashes(scArr[i].getGeometry());
}
fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, savedBioModelInfo));
return savedBioModel;
} catch (RemoteProxyException e) {
e.printStackTrace(System.out);
throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
}
}
use of cbit.vcell.xml.XmlParseException in project vcell by virtualcell.
the class ClientDocumentManager method save.
/**
* Insert the method's description here.
* Creation date: (10/28/00 12:08:30 AM)
*/
public BioModel save(BioModel bioModel, String[] independentSims) throws DataAccessException {
try {
String bioModelXML = null;
try {
bioModel.getVCMetaData().cleanupMetadata();
bioModelXML = XmlHelper.bioModelToXML(bioModel);
} catch (XmlParseException e) {
e.printStackTrace(System.out);
throw new DataAccessException(e.getMessage());
}
String savedBioModelXML = sessionManager.getUserMetaDbServer().saveBioModel(new BigString(bioModelXML), independentSims).toString();
BioModel savedBioModel = getBioModelFromDatabaseXML(new XMLHolder<BioModel>(savedBioModelXML));
KeyValue savedKey = savedBioModel.getVersion().getVersionKey();
if (xmlHash.get(savedKey) == null) {
xmlHash.put(savedKey, savedBioModelXML);
}
BioModelInfo savedBioModelInfo = new BioModelInfo(savedBioModel.getVersion(), savedBioModel.getModel().getKey(), savedBioModel.createBioModelChildSummary(), VCellSoftwareVersion.fromSystemProperty());
bioModelInfoHash.put(savedKey, savedBioModelInfo);
SimulationContext[] scArr = savedBioModel.getSimulationContexts();
for (int i = 0; i < scArr.length; i++) {
updateGeometryRelatedHashes(scArr[i].getGeometry());
}
// copy some transient info from the old model to the new one
for (SimulationContext newsc : scArr) {
SimulationContext oldsc = bioModel.getSimulationContext(newsc.getName());
newsc.getTaskCallbackProcessor().initialize((oldsc.getTaskCallbackProcessor()));
newsc.setMostRecentlyCreatedOutputSpec(oldsc.getMostRecentlyCreatedOutputSpec());
newsc.setMd5hash(oldsc.getMd5hash());
}
fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, savedBioModelInfo));
return savedBioModel;
} catch (RemoteProxyException e) {
e.printStackTrace(System.out);
throw new DataAccessException(VCellErrorMessages.FAIL_SAVE_MESSAGE + "\n\n" + e.getMessage());
}
}
Aggregations