use of org.vcell.util.document.VCDocumentInfo 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;
}
use of org.vcell.util.document.VCDocumentInfo 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);
}
use of org.vcell.util.document.VCDocumentInfo 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);
}
use of org.vcell.util.document.VCDocumentInfo in project vcell by virtualcell.
the class DatabaseWindowManager method compareLatestEdition.
/**
* Comment
*/
public void compareLatestEdition() {
//
if (getPanelSelection() == null) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : No first document selected");
return;
}
VCDocumentInfo thisDocumentInfo = getPanelSelection();
//
// Get the latest 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 latest version of the current documentInfo
//
VCDocumentInfo latestDocumentInfo = documentVersionsList[documentVersionsList.length - 1];
for (int i = 0; i < documentVersionsList.length; i++) {
if (documentVersionsList[i].getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
latestDocumentInfo = documentVersionsList[i];
}
}
if (thisDocumentInfo.getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
PopupGenerator.showErrorDialog(this, "Current Version is the latest! 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) && !(latestDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(latestDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(latestDocumentInfo 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(latestDocumentInfo, thisDocumentInfo);
}
use of org.vcell.util.document.VCDocumentInfo in project vcell by virtualcell.
the class TestingFrameworkWindowManager method loadModel.
/**
* Insert the method's description here.
* Creation date: (4/9/2003 1:31:08 PM)
* @return cbit.vcell.numericstestingframework.TestSuiteInfo
*/
public void loadModel(VCDocumentInfo vcDocumentInfo) throws DataAccessException {
VCDocumentInfo vcDocInfo = null;
if (vcDocumentInfo instanceof MathModelInfo) {
vcDocInfo = getRequestManager().getDocumentManager().getMathModelInfo(vcDocumentInfo.getVersion().getVersionKey());
} else if (vcDocumentInfo instanceof BioModelInfo) {
vcDocInfo = getRequestManager().getDocumentManager().getBioModelInfo(vcDocumentInfo.getVersion().getVersionKey());
}
getRequestManager().openDocument(vcDocInfo, this, true);
}
Aggregations