Search in sources :

Example 71 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class DocumentWindow method updateConnectionStatus.

/**
 * Insert the method's description here.
 * Creation date: (5/10/2004 4:32:17 PM)
 */
public void updateConnectionStatus(ConnectionStatus connStatus) {
    // other updates
    String status = "";
    User user = getWindowManager().getUser();
    boolean isTestUser = (user != null) ? (user.isTestAccount()) : (false);
    switch(connStatus.getStatus()) {
        case ConnectionStatus.NOT_CONNECTED:
            {
                status = "";
                getJProgressBarConnection().setString("NOT CONNECTED");
                getJProgressBarConnection().setValue(0);
                getChange_UserMenuItem().setEnabled(true);
                getUpdate_UserMenuItem().setEnabled(false);
                getReconnectMenuItem().setEnabled(false);
                enableOpenMenuItems(false);
                getSaveMenuItem().setEnabled(false);
                getSave_AsMenuItem().setEnabled(false);
                getSave_AsLocalMenuItem().setEnabled(true);
                getSave_VersionMenuItem().setEnabled(false);
                getJMenuItemRevert().setEnabled(false);
                getJMenuItemCompare().setEnabled(false);
                // getJMenuItemServer().setEnabled(true);
                getTestingFrameworkMenuItem().setVisible(isTestUser);
                getTestingFrameworkMenuItem().setEnabled(false);
                getJMenuItemFieldData().setEnabled(false);
                getPermissionsMenuItem().setEnabled(false);
                checkForReconnecting(connStatus);
                break;
            }
        case ConnectionStatus.CONNECTED:
            {
                status = "Server: " + connStatus.getApihost() + ":" + connStatus.getApiport() + " User: " + connStatus.getUserName();
                getJProgressBarConnection().setString("CONNECTED (" + connStatus.getUserName() + ")");
                getJProgressBarConnection().setValue(100);
                getChange_UserMenuItem().setEnabled(true);
                getUpdate_UserMenuItem().setEnabled(true);
                getReconnectMenuItem().setEnabled(true);
                enableOpenMenuItems(true);
                boolean bVersionedDocument = getWindowManager() != null && getWindowManager().getVCDocument() != null && getWindowManager().getVCDocument().getVersion() != null;
                getSaveMenuItem().setEnabled(bVersionedDocument && !(getWindowManager().getVCDocument().getVersion().getFlag().compareEqual(VersionFlag.Archived) || getWindowManager().getVCDocument().getVersion().getFlag().compareEqual(VersionFlag.Published)));
                getSave_AsMenuItem().setEnabled(true);
                getSave_AsLocalMenuItem().setEnabled(true);
                getSave_VersionMenuItem().setEnabled(bVersionedDocument);
                getJMenuItemRevert().setEnabled(bVersionedDocument);
                getJMenuItemCompare().setEnabled(bVersionedDocument);
                // getJMenuItemServer().setEnabled(true);
                getTestingFrameworkMenuItem().setVisible(isTestUser);
                getTestingFrameworkMenuItem().setEnabled(true);
                getJMenuItemFieldData().setEnabled(true);
                getJMenuItemMIRIAM().setEnabled(true);
                getJMenuItemPreferences().setEnabled(true);
                getTransMAMenuItem().setEnabled(getWindowManager() != null && getWindowManager().getVCDocument() != null && getWindowManager().getVCDocument() instanceof BioModel);
                getViewJobsMenuItem().setEnabled(true);
                // getJMenuImportPathway().setEnabled(getWindowManager().getVCDocument() instanceof BioModel);
                getPermissionsMenuItem().setEnabled(bVersionedDocument && getWindowManager().getVCDocument().getVersion().getOwner().equals(getWindowManager().getUser()));
                break;
            }
        case ConnectionStatus.INITIALIZING:
            {
                status = "Server: " + connStatus.getApihost() + ":" + connStatus.getApiport() + " User: " + connStatus.getUserName();
                getJProgressBarConnection().setString("INITIALIZING...");
                getJProgressBarConnection().setValue(0);
                getChange_UserMenuItem().setEnabled(false);
                getUpdate_UserMenuItem().setEnabled(false);
                getReconnectMenuItem().setEnabled(false);
                enableOpenMenuItems(false);
                getSave_AsLocalMenuItem().setEnabled(true);
                getSaveMenuItem().setEnabled(false);
                getSave_AsMenuItem().setEnabled(false);
                getSave_AsLocalMenuItem().setEnabled(true);
                getSave_VersionMenuItem().setEnabled(false);
                getJMenuItemRevert().setEnabled(false);
                getJMenuItemCompare().setEnabled(false);
                // getJMenuItemServer().setEnabled(false);
                getTestingFrameworkMenuItem().setVisible(isTestUser);
                getTestingFrameworkMenuItem().setEnabled(isTestUser);
                getJMenuItemFieldData().setEnabled(false);
                getJMenuItemMIRIAM().setEnabled(false);
                getJMenuItemPreferences().setEnabled(false);
                getPermissionsMenuItem().setEnabled(false);
                break;
            }
        case ConnectionStatus.DISCONNECTED:
            {
                status = "Server: " + connStatus.getApihost() + ":" + connStatus.getApiport() + " User: " + connStatus.getUserName();
                getJProgressBarConnection().setString("DISCONNECTED");
                getJProgressBarConnection().setValue(0);
                getChange_UserMenuItem().setEnabled(true);
                getUpdate_UserMenuItem().setEnabled(false);
                getReconnectMenuItem().setEnabled(true);
                enableOpenMenuItems(false);
                getSave_AsLocalMenuItem().setEnabled(true);
                getSaveMenuItem().setEnabled(false);
                getSave_AsMenuItem().setEnabled(false);
                getSave_VersionMenuItem().setEnabled(false);
                getJMenuItemRevert().setEnabled(false);
                getJMenuItemCompare().setEnabled(false);
                // getJMenuItemServer().setEnabled(true);
                getTestingFrameworkMenuItem().setVisible(isTestUser);
                getTestingFrameworkMenuItem().setEnabled(false);
                getJMenuItemFieldData().setEnabled(false);
                getJMenuItemMIRIAM().setEnabled(false);
                getJMenuItemPreferences().setEnabled(false);
                getPermissionsMenuItem().setEnabled(false);
                checkForReconnecting(connStatus);
                break;
            }
    }
    getJProgressBarConnection().setToolTipText(status);
}
Also used : User(org.vcell.util.document.User) BioModel(cbit.vcell.biomodel.BioModel)

Example 72 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class DocumentWindow method showTransMADialog.

public void showTransMADialog() {
    String disclaimer = "Transforming reactions to stochastic capable cannot be undone. You may want to make a copy of the model.\nAlso some existing applications may need to be recreated in order to maintain consistency.\nLast but not least, stochastic transfomation may not be mathematically equivalent to the orignal model. \nDo you wish to proceed?";
    JTextArea ta = new JTextArea(disclaimer);
    ta.setEditable(false);
    int userChoice = PopupGenerator.showComponentOKCancelDialog(this, ta, "Model Transformation Warning");
    if (userChoice != JOptionPane.OK_OPTION) {
        return;
    }
    BioModel biomodel = null;
    if (getWindowManager().getVCDocument() instanceof BioModel) {
        biomodel = (BioModel) getWindowManager().getVCDocument();
    }
    TransformMassActionPanel transMAPanel = new TransformMassActionPanel();
    transMAPanel.setModel(biomodel.getModel());
    int choice = DialogUtils.showComponentOKCancelDialog(this, transMAPanel, "Transform to Stochastic Capable Model");
    if (choice == JOptionPane.OK_OPTION) {
        try {
            transMAPanel.saveTransformedReactions();
        } catch (Exception e) {
            PopupGenerator.showWarningDialog(getTopLevelWindowManager(), null, new UserMessage(e.getMessage(), new String[] { "Ok" }, "Ok"), null);
        }
    }
}
Also used : JTextArea(javax.swing.JTextArea) TransformMassActionPanel(cbit.vcell.model.gui.TransformMassActionPanel) BioModel(cbit.vcell.biomodel.BioModel) UserMessage(cbit.vcell.client.UserMessage) UtilCancelException(org.vcell.util.UtilCancelException)

Example 73 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class ReactionCartoonTool method detailsDeleteSpecies.

private static DeleteSpeciesInfo detailsDeleteSpecies(Component requester, SpeciesContext[] speciesContextArr, ReactionStep[] toBeDeletedReactStepArr, ReactionCartoon rxCartoon) throws Exception, UserCancelException {
    if (speciesContextArr == null || speciesContextArr.length == 0) {
        return null;
    }
    // Warn user that there may be some BioModel components that reference speciesContext to be removed
    // Get ReactionParticipant list
    Collection<Shape> rxPartColl = rxCartoon.getShapes();
    HashMap<SpeciesContext, HashSet<ReactionParticipant>> rxPartHashMap = new HashMap<SpeciesContext, HashSet<ReactionParticipant>>();
    for (Shape objShape : rxPartColl) {
        if (objShape instanceof ReactionParticipantShape) {
            ReactionParticipant objReactionParticipant = ((ReactionParticipantShape) objShape).getReactionParticipant();
            if (Arrays.asList(speciesContextArr).contains(objReactionParticipant.getSpeciesContext())) {
                if (!rxPartHashMap.containsKey(objReactionParticipant.getSpeciesContext())) {
                    rxPartHashMap.put(objReactionParticipant.getSpeciesContext(), new HashSet<ReactionParticipant>());
                }
                if (!rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).contains(objReactionParticipant)) {
                    rxPartHashMap.get(objReactionParticipant.getSpeciesContext()).add(objReactionParticipant);
                }
            }
        }
    }
    int reactionParticipantCount = 0;
    for (HashSet<ReactionParticipant> objReactPart : rxPartHashMap.values()) {
        reactionParticipantCount += objReactPart.size();
    }
    // find bioModel and get SymbolTable references to SpeciesContext
    BioModelEditor bioModelEditor = (BioModelEditor) BeanUtils.findTypeParentOfComponent(requester, BioModelEditor.class);
    if (bioModelEditor == null) {
        throw new Exception("Error deleting Speciescontext, Can't find BiomodelEditor");
    }
    BioModel bioModel = bioModelEditor.getBioModelWindowManager().getVCDocument();
    HashMap<SpeciesContext, HashSet<SymbolTableEntry>> referencingSymbolsHashMap = new HashMap<SpeciesContext, HashSet<SymbolTableEntry>>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        List<SymbolTableEntry> referencingSymbolsList = bioModel.findReferences(speciesContextArr[i]);
        if (referencingSymbolsList != null && referencingSymbolsList.size() > 0) {
            if (!referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                referencingSymbolsHashMap.put(speciesContextArr[i], new HashSet<SymbolTableEntry>());
            }
            referencingSymbolsHashMap.get(speciesContextArr[i]).addAll(referencingSymbolsList);
        }
    }
    int referencingSymbolsCount = 0;
    for (HashSet<SymbolTableEntry> objSimTableEntry : referencingSymbolsHashMap.values()) {
        referencingSymbolsCount += objSimTableEntry.size();
    }
    // Warn user about delete
    HashMap<SpeciesContext, Boolean> bUnresolvableHashMap = new HashMap<SpeciesContext, Boolean>();
    for (int i = 0; i < speciesContextArr.length; i++) {
        bUnresolvableHashMap.put(speciesContextArr[i], Boolean.FALSE);
    }
    String[][] rowData = null;
    if (rxPartHashMap.size() == 0 && referencingSymbolsHashMap.size() == 0) {
        rowData = new String[speciesContextArr.length][4];
        for (int i = 0; i < speciesContextArr.length; i++) {
            rowData[i][0] = speciesContextArr[i].getName();
            rowData[i][1] = "";
            rowData[i][2] = "";
            rowData[i][3] = "";
        }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    } else {
        // find SpeciesContext that had no reference warnings
        Vector<SpeciesContext> speciesContextNoReferences = new Vector<SpeciesContext>();
        for (int i = 0; i < speciesContextArr.length; i++) {
            if (!rxPartHashMap.containsKey(speciesContextArr[i]) && !referencingSymbolsHashMap.containsKey(speciesContextArr[i])) {
                speciesContextNoReferences.add(speciesContextArr[i]);
            }
        }
        rowData = new String[reactionParticipantCount + referencingSymbolsCount + speciesContextNoReferences.size()][4];
        int count = 0;
        for (SpeciesContext objSpeciesContext : speciesContextNoReferences) {
            rowData[count][0] = objSpeciesContext.getName();
            rowData[count][1] = "";
            rowData[count][2] = "";
            rowData[count][3] = "";
            count++;
        }
        for (SpeciesContext objSpeciesContext : rxPartHashMap.keySet()) {
            Iterator<ReactionParticipant> iterRxPart = rxPartHashMap.get(objSpeciesContext).iterator();
            while (iterRxPart.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                rowData[count][2] = "Reaction Diagram stoichiometry '" + iterRxPart.next().getReactionStep().getName() + "'";
                rowData[count][3] = "";
                count++;
            }
        }
        for (SpeciesContext objSpeciesContext : referencingSymbolsHashMap.keySet()) {
            Iterator<SymbolTableEntry> iterSymbolTableEntry = referencingSymbolsHashMap.get(objSpeciesContext).iterator();
            while (iterSymbolTableEntry.hasNext()) {
                rowData[count][0] = objSpeciesContext.getName();
                rowData[count][1] = "";
                SymbolTableEntry objSymbolTableEntry = iterSymbolTableEntry.next();
                boolean bKineticsParameter = objSymbolTableEntry instanceof KineticsParameter;
                if (bKineticsParameter) {
                    KineticsParameter kp = (KineticsParameter) objSymbolTableEntry;
                    boolean isOK = kp.isRegenerated();
                    for (int i = 0; toBeDeletedReactStepArr != null && i < toBeDeletedReactStepArr.length; i++) {
                        if (toBeDeletedReactStepArr[i] == kp.getKinetics().getReactionStep()) {
                            // OK to delete this Speciescontext if were deleting the reaction that contained the reference
                            isOK = true;
                        }
                    }
                    rowData[count][1] = (isOK ? "" : RXSPECIES_ERROR);
                    bUnresolvableHashMap.put(objSpeciesContext, bUnresolvableHashMap.get(objSpeciesContext) || !isOK);
                }
                boolean bReaction = objSymbolTableEntry.getNameScope() instanceof ReactionNameScope;
                rowData[count][2] = (bReaction ? "Reaction" : objSymbolTableEntry.getNameScope().getClass().getName()) + "( " + objSymbolTableEntry.getNameScope().getName() + " )";
                rowData[count][3] = (bKineticsParameter ? "Parameter" : objSymbolTableEntry.getClass().getName()) + "( " + objSymbolTableEntry.getName() + " )";
                count++;
            }
        }
        // for (SymbolTableEntry referencingSTE : referencingSymbols) {
        // System.out.println("REFERENCE   "+referencingSTE.getClass().getName()+"("+referencingSTE.getName()+") nameScope "+referencingSTE.getNameScope().getClass().getName()+"("+referencingSTE.getNameScope().getName()+")");
        // }
        Arrays.sort(rowData, new Comparator<String[]>() {

            @Override
            public int compare(String[] o1, String[] o2) {
                return o1[0].compareToIgnoreCase(o2[0]);
            }
        });
    }
    if (rowData == null || rowData.length == 0) {
        return null;
    }
    return new DeleteSpeciesInfo(rxPartHashMap, bUnresolvableHashMap, rowData);
}
Also used : SpeciesContextShape(cbit.vcell.graph.SpeciesContextShape) RubberBandRectShape(cbit.gui.graph.RubberBandRectShape) ProductShape(cbit.vcell.graph.ProductShape) ContainerShape(cbit.gui.graph.ContainerShape) CatalystShape(cbit.vcell.graph.CatalystShape) FluxReactionShape(cbit.vcell.graph.FluxReactionShape) ContainerContainerShape(cbit.vcell.graph.ContainerContainerShape) ReactantShape(cbit.vcell.graph.ReactantShape) ElipseShape(cbit.gui.graph.ElipseShape) SimpleReactionShape(cbit.vcell.graph.SimpleReactionShape) ReactionStepShape(cbit.vcell.graph.ReactionStepShape) ReactionContainerShape(cbit.vcell.graph.ReactionContainerShape) Shape(cbit.gui.graph.Shape) RuleParticipantSignatureDiagramShape(cbit.vcell.graph.RuleParticipantSignatureDiagramShape) ReactionRuleDiagramShape(cbit.vcell.graph.ReactionRuleDiagramShape) RubberBandEdgeShape(cbit.gui.graph.RubberBandEdgeShape) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) SpeciesContext(cbit.vcell.model.SpeciesContext) ReactionParticipantShape(cbit.vcell.graph.ReactionParticipantShape) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) BioModelEditor(cbit.vcell.client.desktop.biomodel.BioModelEditor) Vector(java.util.Vector) ReactionNameScope(cbit.vcell.model.ReactionStep.ReactionNameScope) HashSet(java.util.HashSet) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) UtilCancelException(org.vcell.util.UtilCancelException) ExpressionException(cbit.vcell.parser.ExpressionException) UserCancelException(org.vcell.util.UserCancelException) BioModel(cbit.vcell.biomodel.BioModel) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Example 74 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class MathVerifier method testDocumentLoad.

private void testDocumentLoad(boolean bUpdateDatabase, User user, VCDocumentInfo documentInfo, VCDocument vcDocumentFromDBCache) {
    KeyValue versionKey = documentInfo.getVersion().getVersionKey();
    // try{
    // String vcDocumentXMLFromDBCacheRoundtrip = null;
    // Compare self same
    Exception bSameCachedAndNotCachedXMLExc = null;
    Exception bSameCachedAndNotCachedObjExc = null;
    Exception bSameSelfXMLCachedRoundtripExc = null;
    Boolean bSameCachedAndNotCachedXML = null;
    Boolean bSameCachedAndNotCachedObj = null;
    Boolean bSameSelfCachedRoundtrip = null;
    // Boolean bSameSelfObjCachedRoundTrip = null;
    long startTime = 0;
    // Long compareXMLTime = null;
    // Long compareObjTime = null;
    // Long loadOriginalXMLTime = null;
    Long loadUnresolvedTime = null;
    if (documentInfo instanceof BioModelInfo) {
        Level existingLogLevel = VCMLComparator.getLogLevel();
        try {
            String xmlRndTrip0 = XmlHelper.bioModelToXML((BioModel) vcDocumentFromDBCache);
            BioModel bioModelRndTrip0 = XmlHelper.XMLToBioModel(new XMLSource(xmlRndTrip0));
            String xmlRndTrip1 = XmlHelper.bioModelToXML((BioModel) bioModelRndTrip0);
            BioModel bioModelRndTrip1 = XmlHelper.XMLToBioModel(new XMLSource(xmlRndTrip1));
            if (Compare.logger != null) {
                Compare.loggingEnabled = true;
                VCMLComparator.setLogLevel(Level.DEBUG);
            }
            bSameSelfCachedRoundtrip = VCMLComparator.compareEquals(xmlRndTrip0, xmlRndTrip1, true);
            System.out.println("----------XML same=" + bSameSelfCachedRoundtrip);
            boolean objectSame = bioModelRndTrip0.compareEqual(bioModelRndTrip1);
            System.out.println("----------Objects same=" + objectSame);
            bSameSelfCachedRoundtrip = bSameSelfCachedRoundtrip && objectSame;
        } catch (Exception e) {
            bSameSelfCachedRoundtrip = null;
            lg.error(e.getMessage(), e);
            bSameSelfXMLCachedRoundtripExc = e;
        } finally {
            Compare.loggingEnabled = false;
            VCMLComparator.setLogLevel(existingLogLevel);
        }
        String fromDBBioModelUnresolvedXML = null;
        try {
            startTime = System.currentTimeMillis();
            fromDBBioModelUnresolvedXML = dbServerImpl.getServerDocumentManager().getBioModelUnresolved(new QueryHashtable(), user, versionKey);
            BioModel vcDocumentFromDBNotCached = XmlHelper.XMLToBioModel(new XMLSource(fromDBBioModelUnresolvedXML));
            loadUnresolvedTime = System.currentTimeMillis() - startTime;
            bSameCachedAndNotCachedObj = vcDocumentFromDBCache.compareEqual(vcDocumentFromDBNotCached);
        } catch (Exception e) {
            lg.error(e.getMessage(), e);
            bSameCachedAndNotCachedObjExc = e;
        }
        if (fromDBBioModelUnresolvedXML != null) {
            try {
                String vcDocumentXMLFromDBCacheRegenerate = XmlHelper.bioModelToXML((BioModel) vcDocumentFromDBCache);
                bSameCachedAndNotCachedXML = VCMLComparator.compareEquals(vcDocumentXMLFromDBCacheRegenerate, fromDBBioModelUnresolvedXML, true);
            } catch (Exception e) {
                lg.error(e.getMessage(), e);
                bSameCachedAndNotCachedXMLExc = e;
            }
        }
    } else {
        Level existingLogLevel = VCMLComparator.getLogLevel();
        try {
            String xmlRndTrip0 = XmlHelper.mathModelToXML((MathModel) vcDocumentFromDBCache);
            MathModel mathModelRndTrip0 = XmlHelper.XMLToMathModel(new XMLSource(xmlRndTrip0));
            String xmlRndTrip1 = XmlHelper.mathModelToXML((MathModel) mathModelRndTrip0);
            MathModel mathModelRndTrip1 = XmlHelper.XMLToMathModel(new XMLSource(xmlRndTrip1));
            if (Compare.logger != null) {
                Compare.loggingEnabled = true;
                VCMLComparator.setLogLevel(Level.DEBUG);
            }
            bSameSelfCachedRoundtrip = VCMLComparator.compareEquals(xmlRndTrip0, xmlRndTrip1, true);
            bSameSelfCachedRoundtrip = bSameSelfCachedRoundtrip && mathModelRndTrip0.compareEqual(mathModelRndTrip1);
        } catch (Exception e) {
            bSameSelfCachedRoundtrip = null;
            lg.error(e.getMessage(), e);
            bSameSelfXMLCachedRoundtripExc = e;
        } finally {
            Compare.loggingEnabled = false;
            VCMLComparator.setLogLevel(existingLogLevel);
        }
        String fromDBMathModelUnresolvedXML = null;
        try {
            startTime = System.currentTimeMillis();
            MathModel vcDocumentFromDBNotCached = dbServerImpl.getServerDocumentManager().getMathModelUnresolved(new QueryHashtable(), user, versionKey);
            loadUnresolvedTime = System.currentTimeMillis() - startTime;
            fromDBMathModelUnresolvedXML = XmlHelper.mathModelToXML(vcDocumentFromDBNotCached);
            bSameCachedAndNotCachedObj = vcDocumentFromDBCache.compareEqual(vcDocumentFromDBNotCached);
        } catch (Exception e) {
            lg.error(e.getMessage(), e);
            bSameCachedAndNotCachedObjExc = e;
        }
        if (fromDBMathModelUnresolvedXML != null) {
            try {
                String vcDocumentXMLFromDBCacheRegenerate = XmlHelper.mathModelToXML((MathModel) vcDocumentFromDBCache);
                bSameCachedAndNotCachedXML = VCMLComparator.compareEquals(vcDocumentXMLFromDBCacheRegenerate, fromDBMathModelUnresolvedXML, true);
            } catch (Exception e) {
                lg.error(e.getMessage(), e);
                bSameCachedAndNotCachedXMLExc = e;
            }
        }
    }
    if (bUpdateDatabase) {
        updateLoadModelsStatTable_CompareTest(versionKey, null, /*loadOriginalXMLTime*/
        loadUnresolvedTime, bSameCachedAndNotCachedXML, bSameCachedAndNotCachedObj, bSameSelfCachedRoundtrip, bSameCachedAndNotCachedXMLExc, bSameCachedAndNotCachedObjExc, bSameSelfXMLCachedRoundtripExc);
    } else {
        System.out.println("loadOriginalXMLTime=" + null + /*loadOriginalXMLTime*/
        " loadUnresolvedTime=" + loadUnresolvedTime);
        System.out.println("bSameCachedAndNotCachedXML=" + bSameCachedAndNotCachedXML + " bSameCachedAndNotCachedObj=" + bSameCachedAndNotCachedObj + " bSameSelfXMLCachedRoundtrip=" + bSameSelfCachedRoundtrip);
        System.out.println("bSameCachedAndNotCachedXMLExc=" + bSameCachedAndNotCachedXMLExc + "\nbSameCachedAndNotCachedObjExc=" + bSameCachedAndNotCachedObjExc + "\nbSameSelfXMLCachedRoundtripExc=" + bSameSelfXMLCachedRoundtripExc);
        System.out.println();
    }
}
Also used : QueryHashtable(cbit.sql.QueryHashtable) MathModel(cbit.vcell.mathmodel.MathModel) KeyValue(org.vcell.util.document.KeyValue) BioModelInfo(org.vcell.util.document.BioModelInfo) BigString(org.vcell.util.BigString) PropertyVetoException(java.beans.PropertyVetoException) MatrixException(cbit.vcell.matrix.MatrixException) ModelException(cbit.vcell.model.ModelException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException) BioModel(cbit.vcell.biomodel.BioModel) Level(org.apache.log4j.Level) XMLSource(cbit.vcell.xml.XMLSource)

Example 75 with BioModel

use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.

the class MathVerifier method scan.

/**
 * Insert the method's description here.
 * Creation date: (2/2/01 3:40:29 PM)
 */
public void scan(User[] users, boolean bUpdateDatabase, KeyValue[] bioAndMathModelKeys) throws MathException, MappingException, SQLException, DataAccessException, ModelException, ExpressionException {
    // java.util.Calendar calendar = java.util.GregorianCalendar.getInstance();
    // //	calendar.set(2002,java.util.Calendar.MAY,7+1);
    // calendar.set(2002,java.util.Calendar.JULY,1);
    // final java.util.Date fluxCorrectionOrDisablingBugFixDate = calendar.getTime();
    // //	calendar.set(2001,java.util.Calendar.JUNE,13+1);
    // calendar.set(2002,java.util.Calendar.JANUARY,1);
    // final java.util.Date totalVolumeCorrectionFixDate = calendar.getTime();
    KeyValue[] sortedBioAndMathModelKeys = null;
    if (bioAndMathModelKeys != null) {
        sortedBioAndMathModelKeys = bioAndMathModelKeys.clone();
        Arrays.sort(sortedBioAndMathModelKeys, keyValueCpmparator);
    }
    for (int i = 0; i < users.length; i++) {
        User user = users[i];
        BioModelInfo[] bioModelInfos0 = dbServerImpl.getBioModelInfos(user, false);
        MathModelInfo[] mathModelInfos0 = dbServerImpl.getMathModelInfos(user, false);
        if (lg.isTraceEnabled())
            lg.trace("Testing user '" + user + "'");
        Vector<VCDocumentInfo> userBioAndMathModelInfoV = new Vector<VCDocumentInfo>();
        userBioAndMathModelInfoV.addAll(Arrays.asList(bioModelInfos0));
        userBioAndMathModelInfoV.addAll(Arrays.asList(mathModelInfos0));
        // 
        for (int j = 0; j < userBioAndMathModelInfoV.size(); j++) {
            // 
            // if certain Bio or Math models are requested, then filter all else out
            // 
            VCDocumentInfo documentInfo = userBioAndMathModelInfoV.elementAt(j);
            KeyValue versionKey = documentInfo.getVersion().getVersionKey();
            if (sortedBioAndMathModelKeys != null) {
                int srch = Arrays.binarySearch(sortedBioAndMathModelKeys, versionKey, keyValueCpmparator);
                if (srch < 0) {
                    continue;
                }
            }
            if (!(documentInfo instanceof BioModelInfo)) {
                continue;
            }
            // 
            if (skipHash.contains(versionKey)) {
                System.out.println("skipping " + (documentInfo instanceof BioModelInfo ? "BioModel" : "MathModel") + " with key '" + versionKey + "'");
                continue;
            }
            try {
                // 
                // read in the BioModel and MathModel from the database
                // 
                VCDocument vcDocumentFromDBCache = null;
                BigString vcDocumentXMLFromDBCache = null;
                try {
                    long startTime = System.currentTimeMillis();
                    if (documentInfo instanceof BioModelInfo) {
                        vcDocumentXMLFromDBCache = new BigString(dbServerImpl.getServerDocumentManager().getBioModelXML(new QueryHashtable(), user, versionKey, false));
                        vcDocumentFromDBCache = XmlHelper.XMLToBioModel(new XMLSource(vcDocumentXMLFromDBCache.toString()));
                    } else {
                        vcDocumentXMLFromDBCache = new BigString(dbServerImpl.getServerDocumentManager().getMathModelXML(new QueryHashtable(), user, versionKey, false));
                        vcDocumentFromDBCache = XmlHelper.XMLToMathModel(new XMLSource(vcDocumentXMLFromDBCache.toString()));
                    }
                    if (bUpdateDatabase && testFlag.equals(MathVerifier.MV_LOAD_XML)) {
                        updateLoadModelsStatTable_LoadTest(System.currentTimeMillis() - startTime, versionKey, null);
                    }
                } catch (Exception e) {
                    lg.error(e.getMessage(), e);
                    if (bUpdateDatabase && testFlag.equals(MathVerifier.MV_LOAD_XML)) {
                        updateLoadModelsStatTable_LoadTest(0, versionKey, e);
                    }
                }
                if (testFlag.equals(MathVerifier.MV_LOAD_XML)) {
                    // 
                    if (vcDocumentXMLFromDBCache != null) {
                        testDocumentLoad(bUpdateDatabase, user, documentInfo, vcDocumentFromDBCache);
                    }
                } else if (testFlag.equals(MathVerifier.MV_DEFAULT)) {
                    // 
                    if (vcDocumentFromDBCache instanceof BioModel) {
                        BioModel bioModel = (BioModel) vcDocumentFromDBCache;
                        checkMathForBioModel(vcDocumentXMLFromDBCache, bioModel, user, bUpdateDatabase);
                    }
                }
            } catch (Throwable e) {
                // exception in whole BioModel
                lg.error(e.getMessage(), e);
            // can't update anything in database, since we don't know what simcontexts are involved
            }
        }
    }
}
Also used : QueryHashtable(cbit.sql.QueryHashtable) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) VCDocument(org.vcell.util.document.VCDocument) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) BigString(org.vcell.util.BigString) PropertyVetoException(java.beans.PropertyVetoException) MatrixException(cbit.vcell.matrix.MatrixException) ModelException(cbit.vcell.model.ModelException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) XmlParseException(cbit.vcell.xml.XmlParseException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) BioModel(cbit.vcell.biomodel.BioModel) Vector(java.util.Vector) XMLSource(cbit.vcell.xml.XMLSource)

Aggregations

BioModel (cbit.vcell.biomodel.BioModel)158 SimulationContext (cbit.vcell.mapping.SimulationContext)72 Simulation (cbit.vcell.solver.Simulation)53 XMLSource (cbit.vcell.xml.XMLSource)37 KeyValue (org.vcell.util.document.KeyValue)36 MathModel (cbit.vcell.mathmodel.MathModel)33 DataAccessException (org.vcell.util.DataAccessException)29 XmlParseException (cbit.vcell.xml.XmlParseException)28 File (java.io.File)28 Model (cbit.vcell.model.Model)27 BioModelInfo (org.vcell.util.document.BioModelInfo)25 MathDescription (cbit.vcell.math.MathDescription)24 IOException (java.io.IOException)24 BigString (org.vcell.util.BigString)22 Geometry (cbit.vcell.geometry.Geometry)21 UserCancelException (org.vcell.util.UserCancelException)20 User (org.vcell.util.document.User)20 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)17 VCDocument (org.vcell.util.document.VCDocument)16