void appendLeafNode(MutableTreeNode parentNode, DefaultTreeModel treeModel, InvDataset dataset) { final OpendapLeaf leaf = new OpendapLeaf(dataset.getName(), dataset); final int fileSize = (int) (OpendapUtils.getDataSizeInBytes(leaf) / 1024); leaf.setFileSize(fileSize); final InvAccess dapAccess = dataset.getAccess(ServiceType.OPENDAP); if (dapAccess != null) { leaf.setDapAccess(true); leaf.setDapUri(dapAccess.getStandardUrlName()); } final InvAccess fileAccess = dataset.getAccess(ServiceType.FILE); if (fileAccess != null) { leaf.setFileAccess(true); leaf.setFileUri(fileAccess.getStandardUrlName()); } else { final InvAccess serverAccess = dataset.getAccess(ServiceType.HTTPServer); if (serverAccess != null) { leaf.setFileAccess(true); leaf.setFileUri(serverAccess.getStandardUrlName()); } } final boolean hasNestedDatasets = dataset.hasNestedDatasets(); appendDataNodeToParent(parentNode, treeModel, leaf); fireLeafAdded(leaf, hasNestedDatasets); }
@Override public boolean accept(OpendapLeaf leaf) { DAPVariable[] dapVariables = leaf.getDAPVariables(); if (noVariablesAreSelected()) { return true; } for (DAPVariable dapVariable : dapVariables) { Boolean isSelected = listModel.variableToSelected.get(dapVariable); boolean leafContainsVariable = isSelected == null ? false : isSelected; if (leafContainsVariable) { return true; } } return false; }
private void collectURIs() { final TreePath[] selectionPaths = ((JTree) catalogTree.getComponent()).getSelectionModel().getSelectionPaths(); if (selectionPaths == null || selectionPaths.length <= 0) { return; } for (TreePath selectionPath : selectionPaths) { final DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) selectionPath.getLastPathComponent(); if (CatalogTreeUtils.isDapNode(treeNode) || CatalogTreeUtils.isFileNode(treeNode)) { final OpendapLeaf leaf = (OpendapLeaf) treeNode.getUserObject(); if (leaf.isDapAccess()) { dapURIs.put(leaf.getDapUri(), leaf.getFileSize() >= 2 * 1024 * 1024); } else if (leaf.isFileAccess()) { fileURIs.add(leaf.getFileUri()); } } } }
private void setMetadataText(int componentIndex, OpendapLeaf leaf) { String text = null; try { if (leaf.isDapAccess()) { if (metaInfoArea.getSelectedIndex() == DDS_AREA_INDEX) { text = OpendapUtils.getResponse(leaf.getDdsUri()); } else if (metaInfoArea.getSelectedIndex() == DAS_AREA_INDEX) { text = OpendapUtils.getResponse(leaf.getDasUri()); } } else if (leaf.isFileAccess()) { if (metaInfoArea.getSelectedIndex() == DDS_AREA_INDEX) { text = "No DDS information for file '" + leaf.getName() + "'."; } else if (metaInfoArea.getSelectedIndex() == DAS_AREA_INDEX) { text = "No DAS information for file '" + leaf.getName() + "'."; } } } catch (IOException e) { BeamLogManager.getSystemLogger().warning("Unable to retrieve meta information for file '" + leaf.getName() + "'."); } setResponseText(componentIndex, text); }
@Before public void setUp() throws Exception { opendapLeaf = new OpendapLeaf("blah", new InvDataset(null, "") { }); opendapLeaf.setDapUri("http://domain/dap_node"); opendapLeaf.setFileUri("http://domain/file_node"); }
private OpendapLeaf createLeaf() { return new OpendapLeaf("", new InvDataset(null, "") { @Override public DateRange getTimeCoverage() { return new DateRange(new GregorianCalendar(2010, 0, 1).getTime(), new GregorianCalendar(2011, 0, 1).getTime()); } }); } }
final TreeCellRenderer dapCellRenderer = jTree.getCellRenderer(); final OpendapLeaf opendapLeaf = new OpendapLeaf("This is A dap Node", new InvDataset(null, "") { }); opendapLeaf.setDapAccess(true); final OpendapLeaf fileLeaf = new OpendapLeaf("This is A File Node", new InvDataset(null, "") { }); fileLeaf.setFileAccess(true); final Object dapNode = new DefaultMutableTreeNode(opendapLeaf); final Object fileNode = new DefaultMutableTreeNode(fileLeaf);
@Before public void setUp() { Lm.verifyLicense("Brockmann Consult", "BEAM", "lCzfhklpZ9ryjomwWxfdupxIcuIoCxg2"); variableFilter = new VariableFilter(new JCheckBox(), new CatalogTree(null, new DefaultAppContext(""), null)); variableFilter.getUI(); leaf = new OpendapLeaf("leafName", new InvDataset(null, "") { }); DArrayDimension[] dArrayDimensions = {new DArrayDimension(10, "dimName")}; dapVariable = new DAPVariable("vName", "vType", "vDataType", dArrayDimensions); leaf.addDAPVariable(dapVariable); }
@Test public void testThatOpendapLeafWhichHasNoDapServiceSetIsResolvedToFalse() { final OpendapLeaf userObject = new OpendapLeaf("name", new InvDataset(null, "") { }); userObject.setDapAccess(false); final DefaultMutableTreeNode noDapNode = new DefaultMutableTreeNode(userObject); assertEquals(false, CatalogTreeUtils.isDapNode(noDapNode)); }
@Override public boolean accept(OpendapLeaf leaf) { String text = expressionTextField.getText(); if (StringUtils.isNullOrEmpty(text)) { return true; } text = text.replace("*", ".*").toLowerCase(); Pattern pattern = Pattern.compile(text); final Matcher matcher = pattern.matcher(leaf.getName().toLowerCase()); return matcher.matches(); }
public String getDdsUri() { return getDapUri() + ".dds"; }
@Test public void testGetVariables() { DAPVariable variable = new DAPVariable("vname", "vtype", "vdatatype", new DArrayDimension[]{new DArrayDimension(10, "dname")}); opendapLeaf.addDAPVariable(variable); assertEquals(1, opendapLeaf.getDAPVariables().length); assertSame(variable, opendapLeaf.getDAPVariables()[0]); }
public DAPVariable[] extractVariables(OpendapLeaf leaf) { DDS dds = getDDS(leaf.getDdsUri()); return extractVariables(dds); }
@Test public void testGetFileURI() { assertEquals("http://domain/file_node", opendapLeaf.getFileUri()); }
@Test public void testGetDasURI() { assertEquals("http://domain/dap_node.das", opendapLeaf.getDasUri()); }
private OpendapLeaf createLeaf(final double upperLeftLat, final double upperLeftLon, final double bottomRightLat, final double bottomRightLon) { return new OpendapLeaf("", new InvDataset(null, "") { @Override public ThreddsMetadata.GeospatialCoverage getGeospatialCoverage() { ThreddsMetadata.GeospatialCoverage geospatialCoverage = new ThreddsMetadata.GeospatialCoverage(); geospatialCoverage.setBoundingBox(new LatLonRect( new LatLonPointImpl(upperLeftLat, upperLeftLon), new LatLonPointImpl(bottomRightLat, bottomRightLon))); return geospatialCoverage; } }); }
@Test public void testAccept_AcceptAllIfNoVariableIsSelected() throws Exception { OpendapLeaf leaf2 = new OpendapLeaf("leafName2", new InvDataset(null, "") { }); DAPVariable dapVariable2 = createDAPVariable("vName2"); leaf2.addDAPVariable(dapVariable2); variableFilter.addVariable(dapVariable); variableFilter.addVariable(dapVariable2); variableFilter.setVariableSelected(dapVariable, false); variableFilter.setVariableSelected(dapVariable2, false); assertTrue(variableFilter.accept(leaf)); assertTrue(variableFilter.accept(leaf2)); }
@Test public void testThatOpendapLeafWhichHasDapServiceSetIsResolvedToTrue() { final OpendapLeaf userObject = new OpendapLeaf("name", new InvDataset(null, "") { }); userObject.setDapAccess(true); final DefaultMutableTreeNode notADapNode = new DefaultMutableTreeNode(userObject); assertEquals(true, CatalogTreeUtils.isDapNode(notADapNode)); } }
public String getDdxUri() { return getDapUri() + ".ddx"; }