Search in sources :

Example 36 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method compareTree.

private void compareTree() throws PropertyVetoException, XmlParseException {
    MathModel mathModel1 = getMathModel1();
    MathModel mathModel2 = getMathModel2();
    if (mathModel1 != null && mathModel2 != null) {
        String math1XML = XmlHelper.mathModelToXML(mathModel1);
        String math2XML = XmlHelper.mathModelToXML(mathModel2);
        boolean ignoreVersion = true;
        XmlTreeDiff diffTree = cbit.vcell.xml.XmlHelper.compareMerge(math1XML, math2XML, DiffConfiguration.COMPARE_DOCS_OTHER, ignoreVersion);
        getTMLPanel().setXmlTreeDiff(diffTree);
    } else {
        DialogUtils.showErrorDialog(MathDebuggerPanel.this, "failed");
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) XmlTreeDiff(cbit.xml.merge.XmlTreeDiff)

Example 37 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method flatten.

private void flatten(MathSymbolTableFactory mathSymbolTableFactory) throws PropertyVetoException, MathException, ExpressionException, MappingException, XmlParseException {
    MathDescription math1 = getMathModel1().getMathDescription();
    MathDescription newMath1 = MathDescription.createCanonicalMathDescription(mathSymbolTableFactory, math1);
    MathModel newMathModel1 = new MathModel(null);
    newMathModel1.setName("Math1");
    newMathModel1.setMathDescription(newMath1);
    setMathModel1(newMathModel1);
    MathDescription math2 = getMathModel2().getMathDescription();
    MathDescription newMath2 = MathDescription.createCanonicalMathDescription(mathSymbolTableFactory, math2);
    MathModel newMathModel2 = new MathModel(null);
    newMathModel2.setName("Math2");
    newMathModel2.setMathDescription(newMath2);
    setMathModel2(newMathModel2);
    compareTree();
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Example 38 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method getMathModel1.

public MathModel getMathModel1() throws PropertyVetoException {
    MathDescription mathDesc = mathDescEditor1.getMathDescription();
    if (mathDesc == null) {
        return null;
    } else {
        MathModel mathModel = new MathModel(null);
        mathModel.setName("MATH 1");
        mathModel.setMathDescription(mathDesc);
        return mathModel;
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Example 39 with MathModel

use of cbit.vcell.mathmodel.MathModel 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());
        }
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathModelInfo(org.vcell.util.document.MathModelInfo) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException)

Example 40 with MathModel

use of cbit.vcell.mathmodel.MathModel 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());
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) XmlParseException(cbit.vcell.xml.XmlParseException) XMLSource(cbit.vcell.xml.XMLSource) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) XmlParseException(cbit.vcell.xml.XmlParseException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

MathModel (cbit.vcell.mathmodel.MathModel)70 BioModel (cbit.vcell.biomodel.BioModel)26 Simulation (cbit.vcell.solver.Simulation)24 DataAccessException (org.vcell.util.DataAccessException)21 Geometry (cbit.vcell.geometry.Geometry)20 MathDescription (cbit.vcell.math.MathDescription)20 SimulationContext (cbit.vcell.mapping.SimulationContext)19 XmlParseException (cbit.vcell.xml.XmlParseException)13 MathModelInfo (org.vcell.util.document.MathModelInfo)12 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)11 UserCancelException (org.vcell.util.UserCancelException)11 VCDocument (org.vcell.util.document.VCDocument)11 XMLSource (cbit.vcell.xml.XMLSource)10 ExpressionException (cbit.vcell.parser.ExpressionException)9 File (java.io.File)9 KeyValue (org.vcell.util.document.KeyValue)8 PropertyVetoException (java.beans.PropertyVetoException)7 IOException (java.io.IOException)7 BigString (org.vcell.util.BigString)7 BioModelInfo (org.vcell.util.document.BioModelInfo)7