Search in sources :

Example 21 with XmlParseException

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;
                }
            }
        }
    }
}
Also used : User(org.vcell.util.document.User) BioModel(cbit.vcell.biomodel.BioModel) BioModelInfo(org.vcell.util.document.BioModelInfo) BigString(org.vcell.util.BigString) XMLSource(cbit.vcell.xml.XMLSource) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) RemoteException(java.rmi.RemoteException)

Example 22 with XmlParseException

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

Example 23 with XmlParseException

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

Example 24 with XmlParseException

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());
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) BioModelInfo(org.vcell.util.document.BioModelInfo) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) BigString(org.vcell.util.BigString) BioModel(cbit.vcell.biomodel.BioModel) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 25 with XmlParseException

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());
    }
}
Also used : KeyValue(org.vcell.util.document.KeyValue) BioModelInfo(org.vcell.util.document.BioModelInfo) BigString(org.vcell.util.BigString) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) BigString(org.vcell.util.BigString) BioModel(cbit.vcell.biomodel.BioModel) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Aggregations

XmlParseException (cbit.vcell.xml.XmlParseException)49 DataAccessException (org.vcell.util.DataAccessException)35 XMLSource (cbit.vcell.xml.XMLSource)19 BigString (org.vcell.util.BigString)18 BioModel (cbit.vcell.biomodel.BioModel)16 KeyValue (org.vcell.util.document.KeyValue)16 SQLException (java.sql.SQLException)14 ExpressionException (cbit.vcell.parser.ExpressionException)12 IOException (java.io.IOException)12 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 PrintWriter (java.io.PrintWriter)9 User (org.vcell.util.document.User)9 MathException (cbit.vcell.math.MathException)8 MathModel (cbit.vcell.mathmodel.MathModel)8 Element (org.jdom.Element)8 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)8 BioModelInfo (org.vcell.util.document.BioModelInfo)7 PropertyVetoException (java.beans.PropertyVetoException)5 File (java.io.File)5