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;
}
}
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");
}
}
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();
}
}
}
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);
}
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;
}
Aggregations