Search in sources :

Example 41 with MathModelInfo

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

the class ClientDocumentManager method setGroupPublic.

/**
 * Insert the method's description here.
 * Creation date: (11/28/00 5:43:44 PM)
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
public MathModelInfo setGroupPublic(MathModelInfo mathModelInfo) throws DataAccessException {
    try {
        // 
        // publish from database
        // 
        MathModelInfo newMathModelInfo = (MathModelInfo) setGroupPublic0(mathModelInfo, VersionableType.MathModelMetaData, mathModelInfoHash);
        // 
        // delete MathModelMetaData from cache
        // 
        xmlHash.remove(mathModelInfo.getVersion().getVersionKey());
        fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, mathModelInfo, newMathModelInfo));
        return newMathModelInfo;
    } catch (RemoteProxyException e) {
        handleRemoteProxyException(e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : MathModelInfo(org.vcell.util.document.MathModelInfo) DataAccessException(org.vcell.util.DataAccessException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)

Example 42 with MathModelInfo

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

the class ClientDocumentManager method getMathModelInfo.

/**
 * Insert the method's description here.
 * Creation date: (11/14/00 2:50:07 PM)
 * @return cbit.sql.Versionable
 * @param vType cbit.sql.VersionableType
 * @param key cbit.sql.KeyValue
 */
public synchronized MathModelInfo getMathModelInfo(KeyValue key) throws DataAccessException {
    if (key == null) {
        System.out.println("<<<NULL>>>> ClientDocumentManager.getMathModelInfo(" + key + ")");
        return null;
    }
    // 
    // first look in local cache for the Info object
    // 
    // 
    // first look in local cache for the Info object
    // 
    MathModelInfo mathModelInfo = (MathModelInfo) mathModelInfoHash.get(key);
    if (mathModelInfo != null) {
        // System.out.println("<<<IN CACHE>>> ClientDocumentManager.getMathModelInfo("+key+")");
        return mathModelInfo;
    }
    // 
    // else refresh cache
    // 
    reloadMathModelInfos();
    // bMathModelInfosDirty = false;
    // 
    // now look in cache again (should be in there unless it was deleted from database).
    // 
    mathModelInfo = (MathModelInfo) mathModelInfoHash.get(key);
    if (mathModelInfo != null) {
        return mathModelInfo;
    }
    System.out.println("MathModelInfo(" + key + ") not found");
    return null;
}
Also used : MathModelInfo(org.vcell.util.document.MathModelInfo)

Example 43 with MathModelInfo

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

the class DatabaseWindowManager method comparePreviousEdition.

/**
 * Comment
 */
public void comparePreviousEdition() {
    // 
    if (getPanelSelection() == null) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : No first document selected");
        return;
    }
    VCDocumentInfo thisDocumentInfo = getPanelSelection();
    // 
    // Get the previous version of the documentInfo
    // 
    VCDocumentInfo[] documentVersionsList = null;
    try {
        documentVersionsList = getDocumentVersionDates(thisDocumentInfo);
    } catch (DataAccessException e) {
        PopupGenerator.showErrorDialog(this, "Error accessing second document!");
    }
    if (documentVersionsList == null || documentVersionsList.length == 0) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : Not Enough Versions to Compare!");
        return;
    }
    // 
    // Obtaining the previous version of the current biomodel. Set the previousBioModelInfo to
    // the first version in the bioModelVersionList. Then compare all the versions in the list
    // with the previousBioModelInfo to see if any of them are before previousBioModelInfo
    // datewise. If so, update previousBioModelInfo. The biomodelinfo stored in previousBioModelInfo
    // when it comes out of the loop is the previous version of the biomodel.
    // 
    VCDocumentInfo previousDocumentInfo = documentVersionsList[0];
    boolean bPrevious = false;
    for (int i = 0; i < documentVersionsList.length; i++) {
        if (documentVersionsList[i].getVersion().getDate().before(thisDocumentInfo.getVersion().getDate())) {
            bPrevious = true;
            previousDocumentInfo = documentVersionsList[i];
        } else {
            break;
        }
    }
    if (previousDocumentInfo.equals(documentVersionsList[0]) && !bPrevious) {
        PopupGenerator.showErrorDialog(this, "Current Version is the oldest! Choose another Version or Model to compare!");
        return;
    }
    // Check if both document types are of the same kind. If not, throw an error.
    if (((thisDocumentInfo instanceof BioModelInfo) && !(previousDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(previousDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(previousDocumentInfo instanceof GeometryInfo))) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : The two documents are not of the same type!");
        return;
    }
    // Now that we have both the document versions to be compared, do the comparison and display the result
    compareWithOther(previousDocumentInfo, thisDocumentInfo);
}
Also used : VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) DataAccessException(org.vcell.util.DataAccessException)

Example 44 with MathModelInfo

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

the class DatabaseWindowManager method getDocumentVersionDates.

/**
 * Insert the method's description here.
 * Creation date: (10/3/2002 10:34:00 AM)
 */
private VCDocumentInfo[] getDocumentVersionDates(VCDocumentInfo thisDocumentInfo) throws DataAccessException {
    // 
    if (thisDocumentInfo == null) {
        return new VCDocumentInfo[0];
    }
    VCDocumentInfo[] vcDocumentInfos = null;
    if (thisDocumentInfo instanceof BioModelInfo) {
        vcDocumentInfos = getRequestManager().getDocumentManager().getBioModelInfos();
    } else if (thisDocumentInfo instanceof MathModelInfo) {
        vcDocumentInfos = getRequestManager().getDocumentManager().getMathModelInfos();
    } else if (thisDocumentInfo instanceof GeometryInfo) {
        vcDocumentInfos = getRequestManager().getDocumentManager().getGeometryInfos();
    }
    // 
    // From the list of biomodels in the workspace, get list of biomodels with the same branch ID.
    // This is the list of different versions of the same biomodel.
    // 
    Vector<VCDocumentInfo> documentBranchList = new Vector<VCDocumentInfo>();
    for (int i = 0; i < vcDocumentInfos.length; i++) {
        VCDocumentInfo vcDocumentInfo = vcDocumentInfos[i];
        if (vcDocumentInfo.getVersion().getBranchID().equals(thisDocumentInfo.getVersion().getBranchID())) {
            documentBranchList.add(vcDocumentInfo);
        }
    }
    if (documentBranchList.size() == 0) {
        PopupGenerator.showErrorDialog(this, "Error comparing BioModels : No Versions of document ");
        return new VCDocumentInfo[0];
    }
    VCDocumentInfo[] vcDocumentInfosInBranch = new VCDocumentInfo[documentBranchList.size()];
    documentBranchList.copyInto(vcDocumentInfosInBranch);
    // 
    // From the versions list, remove the currently selected version and return the remaining list of
    // versions for the biomodel
    // 
    VCDocumentInfo[] revisedDocInfosInBranch = new VCDocumentInfo[vcDocumentInfosInBranch.length - 1];
    int j = 0;
    for (int i = 0; i < vcDocumentInfosInBranch.length; i++) {
        if (!thisDocumentInfo.getVersion().getDate().equals(vcDocumentInfosInBranch[i].getVersion().getDate())) {
            revisedDocInfosInBranch[j] = vcDocumentInfosInBranch[i];
            j++;
        }
    }
    return revisedDocInfosInBranch;
}
Also used : VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) Vector(java.util.Vector)

Example 45 with MathModelInfo

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

the class DatabaseWindowManager method findModelsUsingSelectedGeometry.

/**
 * Insert the method's description here.
 * Creation date: (11/6/2005 9:15:25 AM)
 */
public void findModelsUsingSelectedGeometry() {
    AsynchClientTask findModelsTask = new AsynchClientTask("Finding Models...", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCDocumentInfo selectedDocument = getPanelSelection();
            if (!(selectedDocument instanceof GeometryInfo)) {
                PopupGenerator.showErrorDialog(DatabaseWindowManager.this, "DatabaseWindowManager.findModelsUsingSelectedGeometry expected a GeometryInfo\nbut got type=" + selectedDocument.getClass().getName() + " instead");
                return;
            }
            ReferenceQuerySpec rqs = new ReferenceQuerySpec(VersionableType.Geometry, selectedDocument.getVersion().getVersionKey());
            // try{
            ReferenceQueryResult rqr = getRequestManager().getDocumentManager().findReferences(rqs);
            // cbit.vcell.modeldb.VersionableTypeVersion[] children = (rqr.getVersionableFamily().bChildren()?rqr.getVersionableFamily().getUniqueChildren():null);
            VersionableTypeVersion[] dependants = (rqr.getVersionableFamily().bDependants() ? rqr.getVersionableFamily().getUniqueDependants() : null);
            // System.out.println("\n");
            // if(children != null){
            // for(int i=0;i<children.length;i+= 1){
            // if( children[i] != rqr.getVersionableFamily().getTarget()){
            // System.out.println("Children "+children[i]+" key="+children[i].getVersion().getVersionKey()+" date="+children[i].getVersion().getDate());
            // }
            // }
            // }else{
            // System.out.println("No Children");
            // }
            // if(dependants != null){
            // for(int i=0;i<dependants.length;i+= 1){
            // if( dependants[i] != rqr.getVersionableFamily().getTarget()){
            // System.out.println("Dependants "+dependants[i]+" key="+dependants[i].getVersion().getVersionKey()+" date="+dependants[i].getVersion().getDate());
            // }
            // }
            // }else{
            // System.out.println("No Dependants");
            // }
            // System.out.println("\nVersionableRelationships");
            // cbit.vcell.modeldb.VersionableRelationship[] vrArr = rqr.getVersionableFamily().getDependantRelationships();
            // for(int i=0;i<vrArr.length;i+= 1){
            // System.out.println(vrArr[i].from() +" -> "+vrArr[i].to());
            // }
            Hashtable<String, Object> choices = new Hashtable<String, Object>();
            if (dependants != null) {
                // System.out.println("\nMajor Relationships");
                for (int i = 0; i < dependants.length; i += 1) {
                    boolean isBioModel = dependants[i].getVType().equals(VersionableType.BioModelMetaData);
                    boolean isTop = isBioModel || dependants[i].getVType().equals(VersionableType.MathModelMetaData);
                    if (isTop) {
                        VersionableRelationship[] vrArr2 = rqr.getVersionableFamily().getDependantRelationships();
                        for (int j = 0; j < vrArr2.length; j += 1) {
                            if ((vrArr2[j].from() == dependants[i]) && vrArr2[j].to().getVType().equals((isBioModel ? VersionableType.SimulationContext : VersionableType.MathDescription))) {
                                for (int k = 0; k < vrArr2.length; k += 1) {
                                    if ((vrArr2[k].from() == vrArr2[j].to()) && vrArr2[k].to().getVType().equals(VersionableType.Geometry)) {
                                        String s = (isBioModel ? "BioModel" : "MathModel") + "  " + "\"" + dependants[i].getVersion().getName() + "\"  (" + dependants[i].getVersion().getDate() + ")" + (isBioModel ? " (App=\"" + vrArr2[k].from().getVersion().getName() + "\")" : /*+" -> "*/
                                        "");
                                        // +" Geometry="+vrArr2[k].to().getVersion().getName()+" "+vrArr2[k].to().getVersion().getDate();
                                        choices.put(s, dependants[i]);
                                    // System.out.println(s);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (choices.size() > 0) {
                Object[] listObj = choices.keySet().toArray();
                Object o = DialogUtils.showListDialog(getComponent(), listObj, "Models Referencing Geometry (Select To Open) " + selectedDocument.getVersion().getName() + " " + selectedDocument.getVersion().getDate());
                if (o != null) {
                    VersionableTypeVersion v = (VersionableTypeVersion) choices.get(o);
                    // System.out.println(v);
                    if (v.getVType().equals(VersionableType.BioModelMetaData)) {
                        BioModelInfo bmi = getRequestManager().getDocumentManager().getBioModelInfo(v.getVersion().getVersionKey());
                        getRequestManager().openDocument(bmi, DatabaseWindowManager.this, true);
                    } else if (v.getVType().equals(VersionableType.MathModelMetaData)) {
                        MathModelInfo mmi = getRequestManager().getDocumentManager().getMathModelInfo(v.getVersion().getVersionKey());
                        getRequestManager().openDocument(mmi, DatabaseWindowManager.this, true);
                    }
                }
            } else {
                if (dependants == null) {
                    DialogUtils.showInfoDialog(getComponent(), "No Model references found.\n" + (rqr.getVersionableFamily().getTarget().getVersion().getFlag().isArchived() ? "Info: Not Deletable (key=" + rqr.getVersionableFamily().getTarget().getVersion().getVersionKey() + ") because legacy ARCHIVE set" : ""));
                } else {
                    DialogUtils.showInfoDialog(getComponent(), "No current Model references found.\n" + "Geometry has internal database references from\n" + "previously linked Model(s).\n" + "Not Deletable until database is culled (daily).");
                }
            // return;
            }
        // }catch(DataAccessException e){
        // DialogUtils.showErrorDialog(getComponent(), "Error find Geometry Model references\n"+e.getClass().getName()+"\n"+e.getMessage());
        // }
        }
    };
    ClientTaskDispatcher.dispatch(getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { findModelsTask }, false);
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) VersionableTypeVersion(org.vcell.util.document.VersionableTypeVersion) ReferenceQueryResult(org.vcell.util.document.ReferenceQueryResult) Hashtable(java.util.Hashtable) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VCDocumentInfo(org.vcell.util.document.VCDocumentInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) VersionableRelationship(org.vcell.util.document.VersionableRelationship) ReferenceQuerySpec(org.vcell.util.document.ReferenceQuerySpec)

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