Search in sources :

Example 56 with MathModelInfo

use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.

the class DeleteOldDocument method run.

/**
 * Insert the method's description here.
 * Creation date: (5/31/2004 6:04:14 PM)
 * @param hashTable java.util.Hashtable
 * @param clientWorker cbit.vcell.desktop.controls.ClientWorker
 */
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    DocumentWindowManager dwm = (DocumentWindowManager) fetch(hashTable, DOCUMENT_WINDOW_MANAGER);
    VCDocument currentDocument = dwm.getVCDocument();
    DocumentManager documentManager = (DocumentManager) fetch(hashTable, DOCUMENT_MANAGER);
    switch(currentDocument.getDocumentType()) {
        case BIOMODEL_DOC:
            {
                // make the info
                BioModel oldBioModel = (BioModel) currentDocument;
                BioModelInfo oldBioModelInfo = documentManager.getBioModelInfo(oldBioModel.getVersion().getVersionKey());
                // delete document
                documentManager.delete(oldBioModelInfo);
                break;
            }
        case MATHMODEL_DOC:
            {
                // make the info
                MathModel oldMathModel = (MathModel) currentDocument;
                MathModelInfo oldMathModelInfo = documentManager.getMathModelInfo(oldMathModel.getVersion().getVersionKey());
                // delete document
                documentManager.delete(oldMathModelInfo);
                break;
            }
        case GEOMETRY_DOC:
            {
                // make the info
                Geometry oldGeometry = (Geometry) currentDocument;
                GeometryInfo oldGeometryInfo = documentManager.getGeometryInfo(oldGeometry.getVersion().getVersionKey());
                // delete document
                documentManager.delete(oldGeometryInfo);
                break;
            }
        default:
            break;
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) MathModel(cbit.vcell.mathmodel.MathModel) VCDocument(org.vcell.util.document.VCDocument) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) BioModel(cbit.vcell.biomodel.BioModel) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 57 with MathModelInfo

use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.

the class DocumentToExport method run.

/**
 * Insert the method's description here. Creation date: (5/31/2004 6:04:14
 * PM)
 *
 * @param hashTable
 *            java.util.Hashtable
 * @param clientWorker
 *            cbit.vcell.desktop.controls.ClientWorker
 */
@Override
public void run(Hashtable<String, Object> hashTable) throws java.lang.Exception {
    TopLevelWindowManager topLevelWindowManager = extractRequired(hashTable, TopLevelWindowManager.class, "topLevelWindowManager");
    VCDocument doc = null;
    if (topLevelWindowManager instanceof DocumentWindowManager) {
        doc = ((DocumentWindowManager) topLevelWindowManager).getVCDocument();
    } else if (topLevelWindowManager instanceof DatabaseWindowManager) {
        DocumentManager documentManager = extractRequired(hashTable, DocumentManager.class, CommonTask.DOCUMENT_MANAGER.name);
        VCDocumentInfo documentInfo = ((DatabaseWindowManager) topLevelWindowManager).getPanelSelection();
        if (documentInfo instanceof BioModelInfo) {
            BioModelInfo bmi = (BioModelInfo) documentInfo;
            doc = documentManager.getBioModel(bmi);
        } else if (documentInfo instanceof MathModelInfo) {
            MathModelInfo mmi = (MathModelInfo) documentInfo;
            doc = documentManager.getMathModel(mmi);
        } else if (documentInfo instanceof GeometryInfo) {
            GeometryInfo gmi = (GeometryInfo) documentInfo;
            doc = documentManager.getGeometry(gmi);
        }
        if (doc == null) {
            throw new IllegalStateException("export called on DatabaseWindowManager with selection " + documentInfo);
        }
    }
    if (doc != null) {
        hashTable.put(EXPORT_DOCUMENT, doc);
    } else {
        throw new UnsupportedOperationException("TopLevelWindowManager subclass " + topLevelWindowManager.getClass().getName() + " does not support exporting to document");
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) TopLevelWindowManager(cbit.vcell.client.TopLevelWindowManager) DocumentWindowManager(cbit.vcell.client.DocumentWindowManager) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) DocumentManager(cbit.vcell.clientdb.DocumentManager) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) DatabaseWindowManager(cbit.vcell.client.DatabaseWindowManager)

Example 58 with MathModelInfo

use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.

the class MathModelDbTreeModel method databaseInsert.

/**
 * @param event cbit.vcell.clientdb.DatabaseEvent
 */
public void databaseInsert(DatabaseEvent databaseEvent) {
    if (databaseEvent.getNewVersionInfo() instanceof MathModelInfo) {
        try {
            MathModelInfo insertedMathModelInfo = (MathModelInfo) databaseEvent.getNewVersionInfo();
            // 
            // get parent of updated version
            // 
            // model1                           (VCDocumentInfoNode)
            // Fri Sept 2, 2001 12:00:00     (MathModelInfo)
            // Fri Sept 1, 2001 10:00:00     (MathModelInfo)
            // 
            // 
            BioModelNode newVersionNode = createVersionSubTree(insertedMathModelInfo);
            // 
            // find owner node (if it is displayed)
            // 
            User owner = insertedMathModelInfo.getVersion().getOwner();
            BioModelNode ownerRoot = ((BioModelNode) getRoot()).findNodeByUserObject(owner);
            BioModelNode parentNode = null;
            if (ownerRoot != null) {
                parentNode = ownerRoot.findNodeByUserObject(new VCDocumentInfoNode(insertedMathModelInfo));
            }
            if (parentNode == null) {
                // 
                // fresh insert
                // Have to create parent node, for all versions of this mathModel,
                // and stick it in the correct order in the tree.
                // 
                parentNode = new BioModelNode(new VCDocumentInfoNode(insertedMathModelInfo), true);
                parentNode.insert(newVersionNode, 0);
                // 
                if (ownerRoot != null) {
                    // !!!!!!!!!!!!!! new insert on top (index=0) .... should do insertion sort !!!!
                    ownerRoot.insert(parentNode, 0);
                    insertNodeInto(parentNode, ownerRoot, 0);
                }
            } else {
                // 
                // already versions there (just add child in the correct position within parent)
                // 
                // !!!!!!!!!! right now ignore order !!!!!!!!!!
                parentNode.insert(newVersionNode, 0);
                insertNodeInto(newVersionNode, parentNode, 0);
            }
        } catch (DataAccessException e) {
            e.printStackTrace(System.out);
            System.out.println("exception responding to databaseInsert(), refreshing whole tree");
            refreshTree();
        }
    }
}
Also used : User(org.vcell.util.document.User) VCDocumentInfoNode(cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode) MathModelInfo(org.vcell.util.document.MathModelInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 59 with MathModelInfo

use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.

the class MathModelDbTreeModel method createBaseTree.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 1:06:51 PM)
 * @return cbit.vcell.desktop.BioModelNode
 * @param docManager cbit.vcell.clientdb.DocumentManager
 */
protected void createBaseTree() throws DataAccessException {
    VCDocumentDbTreeModel.initBaseTree(rootNode, new BioModelNode[] { myModelsNode, sharedModelsNode, publicModelsNode, educationModelsNode }, "Math Models", sharedModelsNode, SHARED_MATH_MODELS);
    MathModelInfo[] mathModelInfos = getDocumentManager().getMathModelInfos();
    User loginUser = getDocumentManager().getUser();
    TreeMap<String, BioModelNode> treeMap = null;
    try {
        treeMap = VCDocumentDbTreeModel.initOwners(mathModelInfos, loginUser, this, this.getClass().getMethod("createOwnerSubTree", new Class[] { User.class, MathModelInfo[].class }));
    } catch (Exception e) {
        e.printStackTrace();
        treeMap = new TreeMap<String, BioModelNode>();
        treeMap.put(loginUser.getName(), new BioModelNode("Error:" + e.getMessage()));
    }
    initFinalTree(this, treeMap, loginUser);
}
Also used : User(org.vcell.util.document.User) MathModelInfo(org.vcell.util.document.MathModelInfo) TreeMap(java.util.TreeMap) DataAccessException(org.vcell.util.DataAccessException)

Example 60 with MathModelInfo

use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.

the class MathModelDbTreePanel method getMathModelVersionDates.

/**
 * Insert the method's description here.
 * Creation date: (10/7/2002 3:06:29 PM)
 */
private MathModelInfo[] getMathModelVersionDates(MathModelInfo thisMathModelInfo) throws DataAccessException {
    // 
    // Get list of MathModelInfos in workspace
    // 
    MathModelInfo[] mathModelInfos = getDocumentManager().getMathModelInfos();
    // 
    // From the list of mathmodels in the workspace, get list of mathmodels with the same branch ID.
    // This is the list of different versions of the same mathmodel.
    // 
    Vector<MathModelInfo> mathModelBranchList = new Vector<MathModelInfo>();
    for (int i = 0; i < mathModelInfos.length; i++) {
        MathModelInfo mathModelInfo = mathModelInfos[i];
        if (mathModelInfo.getVersion().getBranchID().equals(thisMathModelInfo.getVersion().getBranchID())) {
            mathModelBranchList.add(mathModelInfo);
        }
    }
    if (mathModelBranchList.size() == 0) {
        JOptionPane.showMessageDialog(this, "No Versions in Mathmodel", "Error comparing MathModels", JOptionPane.ERROR_MESSAGE);
        throw new NullPointerException("No Versions in Mathmodel!");
    }
    MathModelInfo[] mathModelInfosInBranch = new MathModelInfo[mathModelBranchList.size()];
    mathModelBranchList.copyInto(mathModelInfosInBranch);
    // 
    // From the versions list, remove the currently selected version and return the remaining list of
    // versions for the mathmodel
    // 
    MathModelInfo[] revisedMMInfosInBranch = new MathModelInfo[mathModelInfosInBranch.length - 1];
    int j = 0;
    for (int i = 0; i < mathModelInfosInBranch.length; i++) {
        if (!thisMathModelInfo.getVersion().getDate().equals(mathModelInfosInBranch[i].getVersion().getDate())) {
            revisedMMInfosInBranch[j] = mathModelInfosInBranch[i];
            j++;
        }
    }
    return revisedMMInfosInBranch;
}
Also used : MathModelInfo(org.vcell.util.document.MathModelInfo) Vector(java.util.Vector)

Aggregations

MathModelInfo (org.vcell.util.document.MathModelInfo)67 BioModelInfo (org.vcell.util.document.BioModelInfo)37 DataAccessException (org.vcell.util.DataAccessException)32 GeometryInfo (cbit.vcell.geometry.GeometryInfo)22 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)14 MathModel (cbit.vcell.mathmodel.MathModel)12 Vector (java.util.Vector)11 BioModel (cbit.vcell.biomodel.BioModel)10 KeyValue (org.vcell.util.document.KeyValue)10 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)8 Hashtable (java.util.Hashtable)8 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)8 User (org.vcell.util.document.User)8 Simulation (cbit.vcell.solver.Simulation)7 UserCancelException (org.vcell.util.UserCancelException)7 Geometry (cbit.vcell.geometry.Geometry)6 SimulationContext (cbit.vcell.mapping.SimulationContext)6 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)6 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)6 SimulationInfo (cbit.vcell.solver.SimulationInfo)6