public void remove(Product product) { AbstractTimeSeries timeSeries = map.remove(product); if (timeSeries != null) { List<ProductLocation> locationList = timeSeries.getProductLocations(); for (ProductLocation productLocation : locationList) { productLocation.closeProducts(); } timeSeries.dispose(); } }
private Variable[] getVariables(ProductLocationsPaneModel locationsModel, ProgressMonitor pm) { try { pm.beginTask("Scanning product locations...", locationsModel.getSize()); for (int i = 0; i < locationsModel.getSize(); i++) { final ProductLocation location = locationsModel.getElementAt(i); location.loadProducts(new SubProgressMonitor(pm, 1)); final Collection<Product> products = location.getProducts(ProgressMonitor.NULL).values(); if (!products.isEmpty()) { final Product product = products.iterator().next(); final String[] bandNames = product.getBandNames(); final Variable[] variables = new Variable[bandNames.length]; for (int j = 0; j < bandNames.length; j++) { variables[j] = new Variable(bandNames[j]); } location.closeProducts(); // @todo se - ?? return variables ?? - really a shortcut after the first product? // in this case only the variables of the first product are returned. return variables; } else { location.closeProducts(); } } } finally { pm.done(); } return new Variable[0]; }
@Override public void removeProductLocation(ProductLocation productLocation) { // remove metadata final MetadataElement timeSeriesRootElement = tsProduct.getMetadataRoot().getElement(TIME_SERIES_ROOT_NAME); MetadataElement productLocationsElement = timeSeriesRootElement.getElement(PRODUCT_LOCATIONS); removeAttributeWithValue(PL_PATH, productLocation.getPath(), productLocationsElement); // remove variables for this productLocation updateAutoGrouping(); // TODO ??? final Band[] bands = tsProduct.getBands(); final MetadataElement sourceProductPaths = timeSeriesRootElement.getElement(SOURCE_PRODUCT_PATHS); for (Map.Entry<String, Product> productEntry : productLocation.getProducts(ProgressMonitor.NULL).entrySet()) { final Product product = productEntry.getValue(); removeAttributeWithValue(PL_PATH, productEntry.getKey(), sourceProductPaths); String timeString = formatTimeString(product); productTimeMap.remove(timeString); for (Band band : bands) { if (band.getName().endsWith(timeString)) { tsProduct.removeBand(band); } } } productLocation.closeProducts(); productLocationList.remove(productLocation); fireChangeEvent(new TimeSeriesChangeEvent(TimeSeriesChangeEvent.PROPERTY_PRODUCT_LOCATIONS, productLocationList, this)); }