use of cbit.vcell.xml.XmlReader in project vcell by virtualcell.
the class VFrapXmlHelper method VFRAPToBioModel.
public static BioModel VFRAPToBioModel(Hashtable<String, Object> hashTable, XMLSource xmlSource, DocumentManager documentManager, final TopLevelWindowManager requester) throws XmlParseException, IOException, DataAccessException, MathException, DivideByZeroException, ExpressionException, ImageException, UtilCancelException {
Component requesterComponent = requester.getComponent();
File vFrapFile = xmlSource.getXmlFile();
// ---
// ex ccc8.vfrap
String vFrapFileNameExtended = vFrapFile.getName();
{
// we want to make sure to reload these strings from the hash later on
String initialFieldDataName = vFrapFileNameExtended.substring(0, vFrapFileNameExtended.indexOf(".vfrap"));
// we'll save here the "special" vFrap images (prebleach_avg, ...)
String mixedFieldDataName = initialFieldDataName + "Mx";
hashTable.put("mixedFieldDataName", mixedFieldDataName);
hashTable.put("initialFieldDataName", initialFieldDataName);
}
if (vFrapFileNameExtended.indexOf(".vfrap") < 0) {
throw new RuntimeException("File extension must be .vfrap");
}
// VFrapXmlHelper vFrapXmlHelper = new VFrapXmlHelper();
checkNameAvailability(hashTable, true, documentManager, requesterComponent);
System.out.println("Loading " + vFrapFileNameExtended + " ...");
String xmlString = XmlUtil.getXMLString(vFrapFile.getAbsolutePath());
MicroscopyXmlReader xmlReader = new MicroscopyXmlReader(true);
Element vFrapRoot = XmlUtil.stringToXML(xmlString, null).getRootElement();
// ----- read the biomodel from Virtual FRAP xml file ----------
BioModel bioModel = null;
XmlReader vcellXMLReader = new XmlReader(true);
Element bioModelElement = vFrapRoot.getChild(XMLTags.BioModelTag);
if (bioModelElement == null) {
throw new RuntimeException("Unable to load biomodel.");
}
String docSoftwareVersion = vFrapRoot.getAttributeValue(XMLTags.SoftwareVersionAttrTag);
bioModel = vcellXMLReader.getBioModel(bioModelElement, (docSoftwareVersion == null ? null : VCellSoftwareVersion.fromString(docSoftwareVersion)));
// ------ locate the special images within the vFrap files and load them in memory
if (!LoadVFrapSpecialImages(hashTable, vFrapRoot)) {
// just return the biomodel if image loading fails for some reason
return bioModel;
}
// ------- save the special images in the database as field data ------------
ExternalDataIdentifier vfrapMisc = SaveVFrapSpecialImagesAsFieldData(hashTable, documentManager);
// ------- create and save data symbols for the vFrap "special" images -----------
CreateSaveVFrapDataSymbols(hashTable, bioModel, vfrapMisc);
// -------- replace vFrap default names in field function arguments with data symbol names -----
ReplaceVFrapNamesWithSymbolNames(bioModel);
return bioModel;
}
use of cbit.vcell.xml.XmlReader in project vcell by virtualcell.
the class GlobalModelParameterTable method setModelParameters.
public void setModelParameters(Connection con, Model model) throws SQLException, DataAccessException {
String sql = " SELECT " + GlobalModelParameterTable.table.xmlFragment.getQualifiedColName() + " FROM " + GlobalModelParameterTable.table.getTableName() + " WHERE " + GlobalModelParameterTable.table.modelRef.getQualifiedColName() + " = " + model.getVersion().getVersionKey() + " ORDER BY " + GlobalModelParameterTable.table.id.getUnqualifiedColName();
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
StringBuffer modelParameeterXMLSB = new StringBuffer();
while (rset.next()) {
String modelParameeterXMLS = rset.getString(GlobalModelParameterTable.table.xmlFragment.toString());
if (!rset.wasNull()) {
modelParameeterXMLS = org.vcell.util.TokenMangler.getSQLRestoredString(modelParameeterXMLS);
modelParameeterXMLSB.append(modelParameeterXMLS);
}
}
if (modelParameeterXMLSB.length() > 0) {
XmlReader xmlReader = new XmlReader(true);
Element modelParameeterXMLElement = XmlUtil.stringToXML(modelParameeterXMLSB.toString(), null).getRootElement();
try {
Model.ModelParameter[] modelParameterArr = xmlReader.getModelParams(modelParameeterXMLElement, model);
model.setModelParameters(modelParameterArr);
} catch (Exception e) {
throw new DataAccessException("error reading ModelParameters for model " + model.getName(), e);
}
}
} finally {
// Release resources include resultset
stmt.close();
}
}
use of cbit.vcell.xml.XmlReader in project vcell by virtualcell.
the class ApplicationMathTable method convertOutputFunctionXMLToFuncList.
private ArrayList<AnnotatedFunction> convertOutputFunctionXMLToFuncList(String outputFunctionsXML) throws XmlParseException {
Element outputFunctionElement = XmlUtil.stringToXML(outputFunctionsXML, null).getRootElement();
ArrayList<AnnotatedFunction> outputFunctionList = (new XmlReader(false)).getOutputFunctions(outputFunctionElement);
return outputFunctionList;
}
Aggregations