private DefaultMutableTreeNode newTreeNode(Study study, VDC vdc) { String url = null; if (studyUrl != null) { url = appendParameterToUrl("/dvn/dv/" + vdc.getAlias() + studyUrl, "studyId=" + study.getId()); } StudyUI studyUI = new StudyUI(study); String studyText = studyUI.getMetadata().getTitle(); if (!StringUtil.isEmpty(studyUI.getAuthors())) { studyText += " by " + studyUI.getAuthors(); } return newTreeNode(studyText, url, false); }
private Boolean addCollectionNode( DefaultMutableTreeNode parentNode, VDCCollection c, VDC vdc, boolean alwaysInclude) { boolean includeFlag = alwaysInclude; boolean expandFlag = expandAll; int studyCount = 0; DefaultMutableTreeNode collectionNode = newTreeNode(c, vdc); CollectionUI collUI = new CollectionUI(c); Collection subCollections = collUI.getSubCollections(); for (Iterator it = subCollections.iterator(); it.hasNext(); ) { getNodeObject(collectionNode).setLeaf(false); VDCCollection subColl = (VDCCollection) it.next(); Boolean expanded = addCollectionNode(collectionNode, subColl, vdc, false); if (expanded != null) { includeFlag = true; expandFlag = expanded ? true : expandFlag; } } // check if collection should be included (and determine count) if (studyFilter == null) { includeFlag = true; } else { Iterator studyIter = studyFilter.iterator(); while (studyIter.hasNext()) { Study study = (Study) studyIter.next(); if (isStudyInCollection(study, c, true)) { studyCount++; } } if (studyCount > 0) { includeFlag = true; } } if (includeFlag) { if (c.getId().equals(collectionToBeExpanded)) { expandFlag = true; } // get studies, if need be if (includeStudies) { Iterator studyIter = collUI.getStudies().iterator(); while (studyIter.hasNext()) { Study s = (Study) studyIter.next(); if (studyFilter == null || StudyUI.isStudyInList(s, studyFilter)) { DefaultMutableTreeNode studyNode = newTreeNode(s, vdc); getNodeObject(collectionNode).setLeaf(false); collectionNode.add(studyNode); } } } if (includeCount && studyFilter != null) { getNodeObject(collectionNode) .setText(getNodeObject(collectionNode).getText() + " (" + studyCount + ")"); } getNodeObject(collectionNode).setExpanded(expandFlag); parentNode.add(collectionNode); return expandFlag; } else { // this collection is not included return null; } }