void insertCatalogElements(InputStream catalogIS, URI catalogBaseUri, DefaultMutableTreeNode parent, boolean expandPath) { final List<InvDataset> catalogDatasets = CatalogTreeUtils.getCatalogDatasets(catalogIS, catalogBaseUri); insertCatalogElements(catalogDatasets, parent, expandPath); }
public void resolveCatalogReferenceNode(DefaultMutableTreeNode catalogReferenceNode, boolean expandPath) { final DefaultTreeModel model = (DefaultTreeModel) jTree.getModel(); final DefaultMutableTreeNode parent = (DefaultMutableTreeNode) catalogReferenceNode.getParent(); model.removeNodeFromParent(catalogReferenceNode); try { List<InvDataset> catalogDatasets = CatalogTreeUtils.getCatalogDatasets(catalogReferenceNode); insertCatalogElements(catalogDatasets, parent, expandPath); } catch (Exception e) { String msg = MessageFormat.format("Unable to completely resolve catalog. Reason: {0}", e.getMessage()); BeamLogManager.getSystemLogger().warning(msg); appContext.handleError(msg, e); } }
@Test public void testThatOneCatalogReferenceNodeHasBeenAdded() throws URISyntaxException, IOException { //preparation final URI catalogBaseUri = new URI("http://sonst.wo.hin/catalog.xml"); InputStream catalogIS = null; try { catalogIS = getThreddsCatalogInputStreamWithOneChildCatalogReference(); //execution catalogTree.insertCatalogElements(catalogIS, catalogBaseUri, parentNode, false); //verification assertEquals(1, parentNode.getChildCount()); final DefaultMutableTreeNode catalogNameNode = (DefaultMutableTreeNode) parentNode.getChildAt(0); assertEquals("CatalogName", catalogNameNode.getUserObject()); final TreeNode catalogReferenceNode = catalogNameNode.getChildAt(0); assertEquals(true, CatalogTreeUtils.isCatalogReferenceNode(catalogReferenceNode)); } finally { if (catalogIS != null) { catalogIS.close(); } } }
@Test public void testThatTwoDapDatasetsHaveBeenAdded() throws URISyntaxException, IOException { //preparation final URI catalogBaseUri = new URI("http://every.where/child/catalog.xml"); InputStream catalogIS = null; try { catalogIS = getThreddsCatalogInputStreamWithTwoChildDapDatasets(); //execution catalogTree.insertCatalogElements(catalogIS, catalogBaseUri, parentNode, false); //verification assertEquals(2, parentNode.getChildCount()); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(0))); assertEquals(true, CatalogTreeUtils.isDapNode(parentNode.getChildAt(1))); DefaultMutableTreeNode firstChild = (DefaultMutableTreeNode) parentNode.getChildAt(0); OpendapLeaf firstLeaf = (OpendapLeaf) firstChild.getUserObject(); assertEquals("http://every.where/opendap/hyrax/data/child/ProductName.N1.nc.dds", firstLeaf.getDdsUri()); DefaultMutableTreeNode secondChild = (DefaultMutableTreeNode) parentNode.getChildAt(1); OpendapLeaf secondLeaf = (OpendapLeaf) secondChild.getUserObject(); assertEquals("http://every.where/opendap/hyrax/data/child/OtherProductName.N1.nc.dds", secondLeaf.getDdsUri()); } finally { if (catalogIS != null) { catalogIS.close(); } } }