use of org.vcell.util.document.VCellSoftwareVersion in project vcell by virtualcell.
the class XmlHelper method XMLToBioModel.
static BioModel XMLToBioModel(XMLSource xmlSource, boolean printkeys, ModelUnitSystem forcedModelUnitSystem) throws XmlParseException {
// long l0 = System.currentTimeMillis();
BioModel bioModel = null;
if (xmlSource == null) {
throw new XmlParseException("Invalid xml for Biomodel.");
}
Document xmlDoc = xmlSource.getXmlDoc();
// NOTES:
// * The root element can be <Biomodel> (old-style vcml) OR <vcml> (new-style vcml)
// * With the old-style vcml, the namespace was " "
// * With the new-style vcml, there is an intermediate stage where the namespace for <vcml> root
// was set to "http://sourceforge.net/projects/VCell/version0.4" for some models and
// "http://sourceforge.net/projects/vcell/vcml" for some models; and the namespace for child element
// <biomdel>, etc. was " "
// * The final new-style vcml has (should have) the namespace "http://sourceforge.net/projects/vcell/vcml"
// for <vcml> and all children elements.
// The code below attempts to take care of this situation.
Element root = xmlDoc.getRootElement();
Namespace ns = null;
if (root.getName().equals(XMLTags.VcmlRootNodeTag)) {
// NEW WAY - with xml string containing xml declaration, vcml element, namespace, etc ...
ns = root.getNamespace();
Element bioRoot = root.getChild(XMLTags.BioModelTag, ns);
if (bioRoot == null) {
bioRoot = root.getChild(XMLTags.BioModelTag);
// bioRoot was null, so obtained the <Biomodel> element with namespace " ";
// Re-set the namespace so that the correct XMLReader constructor is invoked.
ns = null;
}
root = bioRoot;
}
// else - root is assumed to be old-style vcml with <Biomodel> as root.
// common for both new way (with xml declaration, vcml element, etc) and existing way (biomodel is root)
// If namespace is null, xml is the old-style xml with biomodel as root, so invoke XMLReader without namespace argument.
XmlReader reader = null;
VCellSoftwareVersion vCellSoftwareVersion = null;
if (ns == null) {
reader = new XmlReader(printkeys);
} else {
reader = new XmlReader(printkeys, ns);
vCellSoftwareVersion = VCellSoftwareVersion.fromString(root.getAttributeValue(XMLTags.SoftwareVersionAttrTag, ns));
}
if (forcedModelUnitSystem != null) {
reader.setForcedModelUnitSystem(forcedModelUnitSystem);
}
bioModel = reader.getBioModel(root, vCellSoftwareVersion);
// long l1 = System.currentTimeMillis();
bioModel.refreshDependencies();
return bioModel;
}
use of org.vcell.util.document.VCellSoftwareVersion in project vcell by virtualcell.
the class VisitorAdapter method filterBioModel.
/**
* return true if major version >= {@link #minimumModelVersion()}
* @param bioModelInfo not null
*/
public boolean filterBioModel(BioModelInfo bioModelInfo) {
VCellSoftwareVersion sv = bioModelInfo.getSoftwareVersion();
final boolean recentEnough = (sv.getMajorVersion() >= minimumModelVersion());
if (!recentEnough && lg.isEnabledFor(level)) {
lg.log(level, "skipping old (v" + sv.getMajorVersion() + ")" + bioModelInfo.toString());
}
return recentEnough;
}
use of org.vcell.util.document.VCellSoftwareVersion in project vcell by virtualcell.
the class ModelDbDriver method getDiagramsFromModel.
/**
* getModels method comment.
*/
private cbit.vcell.model.Diagram[] getDiagramsFromModel(QueryHashtable dbc, Connection con, KeyValue modelKey, StructureTopology structureTopology, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException {
// log.print("ModelDbDriver.getDiagramsFromModel(modelKey=" + modelKey + ")");
String sql;
switch(dbSyntax) {
case ORACLE:
{
sql = " SELECT *" + " FROM " + diagramTable.getTableName() + "," + SoftwareVersionTable.table.getTableName() + " WHERE " + diagramTable.modelRef + " = " + modelKey + " AND " + diagramTable.modelRef + " = " + SoftwareVersionTable.table.versionableRef.getUnqualifiedColName() + "(+)" + " ORDER BY " + diagramTable.id.getQualifiedColName();
break;
}
case POSTGRES:
{
sql = " SELECT *" + " FROM " + diagramTable.getTableName() + " LEFT OUTER JOIN " + SoftwareVersionTable.table.getTableName() + " ON " + diagramTable.modelRef + " = " + SoftwareVersionTable.table.versionableRef.getUnqualifiedColName() + " WHERE " + diagramTable.modelRef + " = " + modelKey + // " AND " + diagramTable.modelRef + " = " + SoftwareVersionTable.table.versionableRef.getUnqualifiedColName() +"(+)" +
" ORDER BY " + diagramTable.id.getQualifiedColName();
break;
}
default:
{
throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
}
}
Statement stmt = con.createStatement();
Vector<Diagram> diagramList = new Vector<Diagram>();
String softwareVersion = null;
try {
ResultSet rset = stmt.executeQuery(sql);
//
while (rset.next()) {
Diagram diagram = getDiagram(dbc, con, rset, structureTopology);
diagramList.addElement(diagram);
softwareVersion = rset.getString(SoftwareVersionTable.table.softwareVersion.getUnqualifiedColName());
if (rset.wasNull()) {
softwareVersion = null;
}
}
} finally {
// Release resources include resultset
stmt.close();
}
//
// put results in an array
//
Diagram[] diagramArray = new Diagram[diagramList.size()];
diagramList.copyInto(diagramArray);
VCellSoftwareVersion vCellSoftwareVersion = VCellSoftwareVersion.fromString(softwareVersion);
XmlReader.reorderDiagramsInPlace_UponRead(vCellSoftwareVersion, diagramArray, structureTopology);
// //----------------------------------------
return diagramArray;
}
Aggregations