Search in sources :

Example 26 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo 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 27 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class DatabaseWindowManager method compareAnotherEdition.

/**
 * Comment
 */
public void compareAnotherEdition() {
    // 
    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 Dates of the versions as a String, to be displayed as a list
    // 
    String[] versionDatesList = new String[documentVersionsList.length];
    for (int i = 0; i < documentVersionsList.length; i++) {
        versionDatesList[i] = documentVersionsList[i].getVersion().getDate().toString();
    }
    // 
    // Get the user's choice of document version from the list box, use it to get the documentInfo for the
    // corresponding version
    // 
    String newVersionChoice = (String) PopupGenerator.showListDialog(this, versionDatesList, "Please select edition");
    if (newVersionChoice == null) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : Second document not selected!");
        return;
    }
    int versionIndex = -1;
    for (int i = 0; i < versionDatesList.length; i++) {
        if (versionDatesList[i].equals(newVersionChoice)) {
            versionIndex = i;
        }
    }
    if (versionIndex == -1) {
        PopupGenerator.showErrorDialog(this, "Error Comparing documents : No such Version Exists " + newVersionChoice);
        return;
    }
    VCDocumentInfo anotherDocumentInfo = documentVersionsList[versionIndex];
    // Check if both document types are of the same kind. If not, throw an error.
    if (((thisDocumentInfo instanceof BioModelInfo) && !(anotherDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(anotherDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(anotherDocumentInfo 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(anotherDocumentInfo, 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 28 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo 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 29 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo 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)

Example 30 with GeometryInfo

use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.

the class ClientRequestManager method compareWithOther.

/**
 * Processes the model comparison request. Creation date: (6/9/2004 1:07:09 PM)
 *
 * @param vcDocument cbit.vcell.document.VCDocument
 */
public XmlTreeDiff compareWithOther(final VCDocumentInfo docInfo1, final VCDocumentInfo docInfo2) {
    VCDocument document1, document2;
    try {
        // get the VCDocument versions from documentManager
        if (docInfo1 instanceof BioModelInfo && docInfo2 instanceof BioModelInfo) {
            document1 = getDocumentManager().getBioModel((BioModelInfo) docInfo1);
            document2 = getDocumentManager().getBioModel((BioModelInfo) docInfo2);
        } else if (docInfo1 instanceof MathModelInfo && docInfo2 instanceof MathModelInfo) {
            document1 = getDocumentManager().getMathModel((MathModelInfo) docInfo1);
            document2 = getDocumentManager().getMathModel((MathModelInfo) docInfo2);
        } else if (docInfo1 instanceof GeometryInfo && docInfo2 instanceof GeometryInfo) {
            document1 = getDocumentManager().getGeometry((GeometryInfo) docInfo1);
            document2 = getDocumentManager().getGeometry((GeometryInfo) docInfo2);
        } else {
            throw new IllegalArgumentException("The two documents are invalid or of different types.");
        }
        return compareDocuments(document1, document2, DiffConfiguration.COMPARE_DOCS_OTHER);
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
}
Also used : VCDocument(org.vcell.util.document.VCDocument) BioModelInfo(org.vcell.util.document.BioModelInfo) GeometryInfo(cbit.vcell.geometry.GeometryInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) ProgrammingException(org.vcell.util.ProgrammingException) MatrixException(cbit.vcell.matrix.MatrixException) GeometryException(cbit.vcell.geometry.GeometryException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) UtilCancelException(org.vcell.util.UtilCancelException) ModelException(cbit.vcell.model.ModelException) DataFormatException(java.util.zip.DataFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) UserCancelException(org.vcell.util.UserCancelException)

Aggregations

GeometryInfo (cbit.vcell.geometry.GeometryInfo)47 BioModelInfo (org.vcell.util.document.BioModelInfo)27 MathModelInfo (org.vcell.util.document.MathModelInfo)27 DataAccessException (org.vcell.util.DataAccessException)19 VCDocumentInfo (org.vcell.util.document.VCDocumentInfo)11 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)8 Hashtable (java.util.Hashtable)8 Geometry (cbit.vcell.geometry.Geometry)7 VCImageInfo (cbit.image.VCImageInfo)6 BioModel (cbit.vcell.biomodel.BioModel)6 User (org.vcell.util.document.User)6 VersionInfo (org.vcell.util.document.VersionInfo)6 CSGObject (cbit.vcell.geometry.CSGObject)5 SimulationContext (cbit.vcell.mapping.SimulationContext)5 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)5 Vector (java.util.Vector)5 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)5 ImageException (cbit.image.ImageException)4 DocumentManager (cbit.vcell.clientdb.DocumentManager)4 GeometryException (cbit.vcell.geometry.GeometryException)4