use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.
the class MathModelDbTreeModel method createOwnerSubTree.
/**
* 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
*/
public BioModelNode createOwnerSubTree(User owner, MathModelInfo[] mathModelInfos) throws DataAccessException {
//
// for each user
//
BioModelNode rootNode = new BioModelNode(owner, true);
for (int i = 0; i < mathModelInfos.length; i++) {
MathModelInfo mathModelInfo = mathModelInfos[i];
if (mathModelInfo.getVersion().getOwner().equals(owner)) {
if (!meetSearchCriteria(mathModelInfo)) {
continue;
}
BioModelNode bioModelNode = new BioModelNode(new VCDocumentInfoNode(mathModelInfo), true);
rootNode.add(bioModelNode);
//
// get list of bioModels with the same branch
//
Vector<MathModelInfo> mathModelBranchList = new Vector<MathModelInfo>();
mathModelBranchList.addElement(mathModelInfo);
for (i = i + 1; i < mathModelInfos.length; i++) {
if (mathModelInfos[i].getVersion().getBranchID().equals(mathModelInfo.getVersion().getBranchID())) {
if (!meetSearchCriteria(mathModelInfos[i])) {
continue;
}
mathModelBranchList.add(0, mathModelInfos[i]);
} else {
i--;
break;
}
}
MathModelInfo[] mathModelInfosInBranch = null;
if (getLatestOnly()) {
mathModelInfosInBranch = new MathModelInfo[1];
mathModelInfosInBranch[0] = (MathModelInfo) mathModelBranchList.elementAt(0);
} else {
mathModelInfosInBranch = new MathModelInfo[mathModelBranchList.size()];
mathModelBranchList.copyInto(mathModelInfosInBranch);
}
for (int versionCount = 0; versionCount < mathModelInfosInBranch.length; versionCount++) {
bioModelNode.add(createVersionSubTree(mathModelInfosInBranch[versionCount]));
}
}
}
return rootNode;
}
use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.
the class VCDocumentDbTreeModel method initFinalTree2.
protected static synchronized void initFinalTree2(VCDocumentDbTreeModel vcDocumentDbTreeModel, TreeMap<String, BioModelNode> treeMap, User loginUser) {
BioModelNode ownerNode = (BioModelNode) treeMap.get(loginUser.getName());
BioModelNode tempNode = new BioModelNode();
vcDocumentDbTreeModel.myModelsNode.setUserObject(loginUser);
vcDocumentDbTreeModel.myModelsNode.removeAllChildren();
for (int c = 0; c < ownerNode.getChildCount(); ) {
BioModelNode childNode = (BioModelNode) ownerNode.getChildAt(c);
BioModelNode clone = BioModelNode.deepClone(childNode);
vcDocumentDbTreeModel.myModelsNode.add(clone);
// we keep in tempNode only those children that are public
BigDecimal groupid = GroupAccess.GROUPACCESS_NONE;
VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
Version version = vcdDocumentInfoNode.getVCDocumentInfo().getVersion();
if (version != null && version.getGroupAccess() != null) {
groupid = version.getGroupAccess().getGroupid();
}
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
// also removes the child from owner node
tempNode.add(childNode);
} else {
// c always stays at 0
ownerNode.remove(c);
}
// ownerNode gets empty eventually
}
for (int c = 0; c < tempNode.getChildCount(); ) {
// we put back the public nodes for the login user
BioModelNode childNode = (BioModelNode) tempNode.getChildAt(c);
ownerNode.add(childNode);
}
vcDocumentDbTreeModel.sharedModelsNode.removeAllChildren();
vcDocumentDbTreeModel.otherModelsNode.removeAllChildren();
if (vcDocumentDbTreeModel.publishedModelsNode != null) {
vcDocumentDbTreeModel.publishedModelsNode.removeAllChildren();
}
boolean bTutorial = vcDocumentDbTreeModel.tutorialModelsNode != null;
// boolean bEducation = vcDocumentDbTreeModel.educationModelsNode != null;
boolean bModelBricks = vcDocumentDbTreeModel.modelBricksNode != null;
if (bTutorial) {
vcDocumentDbTreeModel.tutorialModelsNode.removeAllChildren();
}
// if(bEducation){vcDocumentDbTreeModel.educationModelsNode.removeAllChildren();}
if (bModelBricks) {
vcDocumentDbTreeModel.modelBricksNode.removeAllChildren();
}
for (String username : treeMap.keySet()) {
BioModelNode userNode = treeMap.get(username);
BioModelNode parentNode = vcDocumentDbTreeModel.sharedModelsNode;
boolean bSpecificUser = true;
if ((username.equals(USER_tutorial) || username.equals(USER_tutorial610) || username.equals(USER_tutorial611)) && bTutorial) {
parentNode = vcDocumentDbTreeModel.tutorialModelsNode;
// } else if (username.equals(USER_Education) && bEducation) {
// parentNode = vcDocumentDbTreeModel.educationModelsNode;
} else if (username.equals(USER_modelBricks) && bModelBricks) {
parentNode = vcDocumentDbTreeModel.modelBricksNode;
} else {
bSpecificUser = false;
}
for (int c = 0; c < userNode.getChildCount(); c++) {
// we just navigate through all of them, remove none
BioModelNode childNode = (BioModelNode) userNode.getChildAt(c);
VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
if (!bSpecificUser) {
parentNode = vcDocumentDbTreeModel.sharedModelsNode;
BigDecimal groupid = GroupAccess.GROUPACCESS_NONE;
Version version = vcdDocumentInfoNode.getVCDocumentInfo().getVersion();
if (version != null && version.getGroupAccess() != null) {
groupid = version.getGroupAccess().getGroupid();
}
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
parentNode = vcDocumentDbTreeModel.otherModelsNode;
}
}
BioModelNode clone = BioModelNode.deepClone(childNode);
parentNode.add(clone);
}
// Populate 'Published' models tree node
for (int c = 0; c < userNode.getChildCount(); ) {
BioModelNode versionableNode = (BioModelNode) userNode.getChildAt(c);
// Search through versions of BM/MM to see if any are published
for (int i = 0; i < versionableNode.getChildCount(); i++) {
BioModelNode versionBioModelNode = (BioModelNode) versionableNode.getChildAt(i);
VCDocumentInfo versionVCDocumentInfo = (VCDocumentInfo) versionBioModelNode.getUserObject();
if (versionVCDocumentInfo.getPublicationInfos() != null && versionVCDocumentInfo.getPublicationInfos().length > 0) {
// Make new node
BioModelNode newPublishedNode = new BioModelNode(new VCDocumentInfoNode(versionVCDocumentInfo), true);
newPublishedNode.add(versionBioModelNode);
vcDocumentDbTreeModel.publishedModelsNode.add(newPublishedNode);
}
}
userNode.remove(c);
}
}
}
use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.
the class VCDocumentDbTreeModel method initFinalTree.
protected static synchronized void initFinalTree(VCDocumentDbTreeModel vcDocumentDbTreeModel, TreeMap<String, BioModelNode> treeMap, User loginUser) {
BioModelNode ownerNode = (BioModelNode) treeMap.get(loginUser.getName());
BioModelNode tempNode = new BioModelNode();
vcDocumentDbTreeModel.myModelsNode.setUserObject(loginUser);
vcDocumentDbTreeModel.myModelsNode.removeAllChildren();
for (int c = 0; c < ownerNode.getChildCount(); ) {
// c stays zero, during each iteration we keep extracting the first element
BioModelNode childNode = (BioModelNode) ownerNode.getChildAt(c);
// VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
// System.out.println(vcdDocumentInfoNode.getVCDocumentInfo().getVersion().getName());
BioModelNode cloneNode = childNode.clone();
// this slowly empties ownerNode
vcDocumentDbTreeModel.myModelsNode.add(childNode);
boolean isPublic = false;
for (int i = 0; i < childNode.getChildCount(); i++) {
BioModelNode versionBioModelNode = (BioModelNode) childNode.getChildAt(i);
VCDocumentInfo versionVCDocumentInfo = (VCDocumentInfo) versionBioModelNode.getUserObject();
BigDecimal groupid = versionVCDocumentInfo.getVersion().getGroupAccess().getGroupid();
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
isPublic = true;
}
// use the form below if want to populate the Other folder with my Public models
// if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
// use the form below to populate only the Published folder with my Published models
// if( versionVCDocumentInfo.getPublicationInfos() != null && versionVCDocumentInfo.getPublicationInfos().length > 0) {
// BioModelNode versionCloneNode = versionBioModelNode.clone();
// cloneNode.add(versionCloneNode);
// }
}
if (isPublic) {
BioModelNode publicClone = BioModelNode.deepClone(childNode);
// we add all login user models that have at least one public version
tempNode.add(publicClone);
}
// if(cloneNode.getChildCount() > 0) {
// tempNode.add(cloneNode); // we keep adding only the clones of the public versions (if any) to the cloneNode
// }
// ownerNode gets empty eventually
}
for (int c = 0; c < tempNode.getChildCount(); ) {
// we put back in ownerNode the clone nodes with public versions
BioModelNode childNode = (BioModelNode) tempNode.getChildAt(c);
ownerNode.add(childNode);
}
// key is publicationKey, value is the list of model nodes associated with the PublicationInfo object
LinkedHashMap<KeyValue, LinkedList<BioModelNode>> publishedModelsMap = new LinkedHashMap<>();
LinkedHashMap<KeyValue, LinkedList<BioModelNode>> curatedModelsMap = new LinkedHashMap<>();
// key is publicationKey, value is a PublicationInfo instance associated to the DOI
LinkedHashMap<KeyValue, PublicationInfo> publicationsMap = new LinkedHashMap<>();
vcDocumentDbTreeModel.sharedModelsNode.removeAllChildren();
boolean bTutorial = vcDocumentDbTreeModel.tutorialModelsNode != null;
// boolean bEducation = vcDocumentDbTreeModel.educationModelsNode != null;
boolean bModelBricks = vcDocumentDbTreeModel.modelBricksNode != null;
boolean bPublished = vcDocumentDbTreeModel.publishedModelsNode != null;
boolean bCurated = vcDocumentDbTreeModel.curatedModelsNode != null;
boolean bOther = vcDocumentDbTreeModel.otherModelsNode != null;
if (bTutorial) {
vcDocumentDbTreeModel.tutorialModelsNode.removeAllChildren();
}
// if(bEducation){vcDocumentDbTreeModel.educationModelsNode.removeAllChildren();}
if (bModelBricks) {
vcDocumentDbTreeModel.modelBricksNode.removeAllChildren();
}
if (bPublished) {
vcDocumentDbTreeModel.publishedModelsNode.removeAllChildren();
}
if (bCurated) {
vcDocumentDbTreeModel.curatedModelsNode.removeAllChildren();
}
if (bOther) {
vcDocumentDbTreeModel.otherModelsNode.removeAllChildren();
}
for (String username : treeMap.keySet()) {
// iterate through all users
// if(username.equals(USER_modelBricks)) {
// System.out.print(username);
// System.out.println();
// }
BioModelNode userNode = treeMap.get(username);
// initialize to something
BioModelNode parentNode = vcDocumentDbTreeModel.sharedModelsNode;
boolean bSpecificUser = true;
if ((username.equals(USER_tutorial) || username.equals(USER_tutorial610) || username.equals(USER_tutorial611)) && bTutorial) {
parentNode = vcDocumentDbTreeModel.tutorialModelsNode;
// } else if (username.equals(USER_Education) && bEducation) {
// parentNode = vcDocumentDbTreeModel.educationModelsNode;
} else if (username.equals(USER_modelBricks) && bModelBricks) {
parentNode = vcDocumentDbTreeModel.modelBricksNode;
} else {
bSpecificUser = false;
}
boolean added = false;
UserNameNode userNameNode = new UserNameNode(username, true);
for (int c = 0; c < userNode.getChildCount(); c++) {
// we just navigate through all of them, remove none
BioModelNode childNode = (BioModelNode) userNode.getChildAt(c);
// --------------------------------------------- 'other' public folder ---------------------------------------
if (!bSpecificUser) {
// if(username.equalsIgnoreCase(loginUser.getName())) {
// break; // TODO: we skip login user from now because it needs real time recalculation
// }
parentNode = vcDocumentDbTreeModel.otherModelsNode;
BioModelNode cloneNode = childNode.clone();
for (int i = 0; i < childNode.getChildCount(); i++) {
BioModelNode versionBioModelNode = (BioModelNode) childNode.getChildAt(i);
VCDocumentInfo versionVCDocumentInfo = (VCDocumentInfo) versionBioModelNode.getUserObject();
BigDecimal groupid = versionVCDocumentInfo.getVersion().getGroupAccess().getGroupid();
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
if (versionVCDocumentInfo.getPublicationInfos() != null && versionVCDocumentInfo.getPublicationInfos().length > 0) {
// we don't show in "Other" anything that is published or curated
continue;
}
// clone the public versions
BioModelNode versionCloneNode = versionBioModelNode.clone();
// and add them to the clone node
cloneNode.add(versionCloneNode);
}
}
if (cloneNode.getChildCount() > 0) {
// we keep adding only the clones of the public versions (if any) to the cloneNode
userNameNode.add(cloneNode);
if (added == false) {
parentNode.add(userNameNode);
added = true;
}
}
} else {
// anything belonging to users Education, Tutorial or modelBricks go to their own folders
if (username.equals(USER_modelBricks)) {
// revision feb 13, 2020 danv
// for modelBricks, only the public clones go the Model Bricks folder
// we'll enforce a single version policy so that we won't have to look into versions to see
// the individual flag of each
VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
BigDecimal groupid = vcdDocumentInfoNode.getVCDocumentInfo().getVersion().getGroupAccess().getGroupid();
// BigDecimal groupid = versionVCDocumentInfo.getVersion().getGroupAccess().getGroupid();
if (groupid.equals(GroupAccess.GROUPACCESS_ALL)) {
// only the public bricks go here
BioModelNode clone = BioModelNode.deepClone(childNode);
parentNode.add(clone);
}
} else {
// for all the other special users we keep the old behavior
BioModelNode clone = BioModelNode.deepClone(childNode);
parentNode.add(clone);
}
}
}
// -------------------------------------------- shared folder -----------------------------------------------
added = false;
userNameNode = new UserNameNode(username, true);
for (int c = 0; c < userNode.getChildCount(); c++) {
// we just navigate through all of them, remove none
if (username.equalsIgnoreCase(loginUser.getName())) {
// the login user can't share with himself
break;
}
BioModelNode childNode = (BioModelNode) userNode.getChildAt(c);
if (!bSpecificUser) {
parentNode = vcDocumentDbTreeModel.sharedModelsNode;
BioModelNode cloneNode = childNode.clone();
for (int i = 0; i < childNode.getChildCount(); i++) {
BioModelNode versionBioModelNode = (BioModelNode) childNode.getChildAt(i);
VCDocumentInfo versionVCDocumentInfo = (VCDocumentInfo) versionBioModelNode.getUserObject();
BigDecimal groupid = versionVCDocumentInfo.getVersion().getGroupAccess().getGroupid();
// System.out.println(" " + groupid);
if (groupid.equals(GroupAccess.GROUPACCESS_ALL) || groupid.equals(GroupAccess.GROUPACCESS_NONE)) {
// we skip private and public versions (that includes published versions)
continue;
}
// clone the shared versions
BioModelNode versionCloneNode = versionBioModelNode.clone();
// and add them to the clone node
cloneNode.add(versionCloneNode);
}
if (cloneNode.getChildCount() > 0) {
// we keep adding only the clones of the shared versions (if any) to the cloneNode
userNameNode.add(cloneNode);
if (added == false) {
// now that we know for sure that the user name node is populated, we add it to the shared node if it's not there already
parentNode.add(userNameNode);
added = true;
}
}
} else {
if (username.equals(USER_modelBricks)) {
// revision feb 13, 2020 danv
// for modelBricks, we make a user name node and we populate it with all the bricks shared with
// the login user
// we'll enforce a single version policy so that we won't have to look into versions to see
// the individual flag of each
parentNode = vcDocumentDbTreeModel.sharedModelsNode;
VCDocumentInfoNode vcdDocumentInfoNode = (VCDocumentInfoNode) childNode.getUserObject();
BigDecimal groupid = vcdDocumentInfoNode.getVCDocumentInfo().getVersion().getGroupAccess().getGroupid();
if (groupid.equals(GroupAccess.GROUPACCESS_ALL) || groupid.equals(GroupAccess.GROUPACCESS_NONE)) {
// nothing to do here with public or private bricks
;
} else {
BioModelNode cloneNode = BioModelNode.deepClone(childNode);
userNameNode.add(cloneNode);
if (added == false) {
// now that we know for sure that the user name node is populated, we add it to the shared node if it's not there already
parentNode.add(userNameNode);
added = true;
}
}
}
}
}
for (int c = 0; c < userNode.getChildCount(); ) {
BioModelNode versionableNode = (BioModelNode) userNode.getChildAt(c);
// Search through versions of BM/MM to see if any are published
for (int i = 0; i < versionableNode.getChildCount(); ) {
// the versions
BioModelNode versionBioModelNode = (BioModelNode) versionableNode.getChildAt(i);
VCDocumentInfo versionVCDocumentInfo = (VCDocumentInfo) versionBioModelNode.getUserObject();
PublicationInfo[] piArray = versionVCDocumentInfo.getPublicationInfos();
if (piArray != null && piArray.length > 0) {
// we already placed this version in Curated, no need to look for more publications for curated
boolean foundCurated = false;
// same as above for published
boolean foundPublished = false;
for (PublicationInfo pi : piArray) {
KeyValue key = pi.getPublicationKey();
if (!publicationsMap.containsKey(key)) {
publicationsMap.put(key, pi);
}
if (versionVCDocumentInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Published)) {
// published
if (foundPublished) {
continue;
}
// String vn = versionVCDocumentInfo.getVersion().getName();
// String vo = versionVCDocumentInfo.getVersion().getOwner().getName();
// String vk = versionVCDocumentInfo.getVersion().getVersionKey().toString();
// System.out.println(vk);
LinkedList<BioModelNode> modelsList;
if (publishedModelsMap.containsKey(key)) {
modelsList = publishedModelsMap.get(key);
} else {
modelsList = new LinkedList<>();
}
BioModelNode newPublishedNode = new BioModelNode(new VCDocumentInfoNode(versionVCDocumentInfo), true);
BioModelNode clonedNode = versionBioModelNode.clone();
newPublishedNode.add(clonedNode);
modelsList.add(newPublishedNode);
publishedModelsMap.put(key, modelsList);
foundPublished = true;
} else {
// curated
if (foundCurated) {
// otherwise we may add the same version multiple times to Curated, once for each PublicationInfo
continue;
}
// the code below shows by author + model name
BioModelNode newCuratedNode = new BioModelNode(new VCDocumentInfoNode(versionVCDocumentInfo), true);
BioModelNode clonedNode = versionBioModelNode.clone();
newCuratedNode.add(clonedNode);
vcDocumentDbTreeModel.curatedModelsNode.add(newCuratedNode);
// the code below shows by Publication Title
// LinkedList<BioModelNode> modelsList;
// if(curatedModelsMap.containsKey(key)) {
// modelsList = curatedModelsMap.get(key);
// } else {
// modelsList = new LinkedList<> ();
// }
// BioModelNode newCuratedNode = new BioModelNode(new VCDocumentInfoNode(versionVCDocumentInfo), true);
// BioModelNode clonedNode = versionBioModelNode.clone();
// newCuratedNode.add(clonedNode);
// modelsList.add(newCuratedNode);
// curatedModelsMap.put(key, modelsList);
foundCurated = true;
}
}
}
versionableNode.remove(i);
}
userNode.remove(c);
}
}
shallowOrderByPublication(publishedModelsMap, publicationsMap);
for (KeyValue key : publishedModelsMap.keySet()) {
LinkedList<BioModelNode> modelsList = publishedModelsMap.get(key);
PublicationInfo pi = publicationsMap.get(key);
BioModelNode newPublicationNode = new BioModelNode.PublicationInfoNode(pi, true);
for (BioModelNode node : modelsList) {
newPublicationNode.add(node);
}
vcDocumentDbTreeModel.publishedModelsNode.add(newPublicationNode);
}
// for (int c = 0; c < vcDocumentDbTreeModel.modelBricksNode.getChildCount(); c++) {
if (bModelBricks) {
for (int i = 0; i < vcDocumentDbTreeModel.modelBricksNode.getChildCount(); ) {
BioModelNode childNode = (BioModelNode) vcDocumentDbTreeModel.modelBricksNode.getChildAt(0);
vcDocumentDbTreeModel.curatedModelsNode.add(childNode);
}
}
}
use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.
the class MathModelDbTreePanel method treeSelection.
/**
* Comment
*/
protected void treeSelection() {
TreePath treePath = getJTree1().getSelectionPath();
if (treePath == null) {
setSelectedVersionInfo(null);
return;
}
BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
Object object = bioModelNode.getUserObject();
if (object instanceof PublicationInfo) {
// TODO: is this line needed?
setSelectedVersionInfo(null);
setSelectedPublicationInfo(bioModelNode);
} else if (object instanceof VersionInfo) {
setSelectedVersionInfo((VersionInfo) object);
} else if (object instanceof VCDocumentInfoNode && bioModelNode.getChildCount() > 0 && ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject() instanceof MathModelInfo) {
MathModelInfo mathModelInfo = (MathModelInfo) ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject();
setSelectedVersionInfo(mathModelInfo);
} else {
setSelectedVersionInfo(null);
}
}
use of cbit.vcell.desktop.VCellBasicCellRenderer.VCDocumentInfoNode in project vcell by virtualcell.
the class GeometryTreePanel method treeSelection.
/**
* Comment
*/
protected void treeSelection() {
TreePath treePath = getJTree1().getSelectionPath();
if (treePath == null) {
setSelectedVersionInfo(null);
return;
}
BioModelNode bioModelNode = (BioModelNode) treePath.getLastPathComponent();
Object object = bioModelNode.getUserObject();
try {
BeanUtils.setCursorThroughout(this, java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
if (object instanceof VersionInfo) {
setSelectedVersionInfo((VersionInfo) object);
} else if (object instanceof VCDocumentInfoNode && bioModelNode.getChildCount() > 0 && ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject() instanceof GeometryInfo) {
GeometryInfo geometryInfo = (GeometryInfo) ((BioModelNode) bioModelNode.getChildAt(0)).getUserObject();
setSelectedVersionInfo(geometryInfo);
} else {
setSelectedVersionInfo(null);
}
} catch (Exception exc) {
handleException(exc);
} finally {
BeanUtils.setCursorThroughout(this, java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
}
}
Aggregations