@Override public int removeGranules(Filter filter, Hints hints) { // unmap the feature identifiers Filter unmapped = GranuleStoreViewFilterVisitor.unmapIdentifiers(filter, coverageView.getName()); List<CoverageBand> bands = coverageView.getCoverageBands(); int removed = 0; for (CoverageBand band : bands) { String coverageName = band.getInputCoverageBands().get(0).getCoverageName(); GranuleStore granuleStore; try { granuleStore = (GranuleStore) reader.getGranules(coverageName, false); // TODO: We may revisit the #removed granules computation to take into // account cases where we remove different number of records across different // input coverages removed = granuleStore.removeGranules(unmapped, hints); } catch (UnsupportedOperationException e) { LOGGER.log(Level.FINER, e.getMessage(), e); } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); } } return removed; }
@Override public SimpleFeatureCollection getGranules(Query q) throws IOException { return delegate.getGranules(q); }
@Override public void addGranules(SimpleFeatureCollection granules) { delegate.addGranules(granules); }
final GridCoverageReader reader = resPool.getGridCoverageReader(coverageInfo, "regional_currents", null); final GranuleStore granules = (GranuleStore) ((StructuredGridCoverage2DReader) reader).getGranules("regional_currents", true); SimpleFeatureCollection granulesCollection = granules.getGranules(null); assertEquals(1, granulesCollection.size()); final Filter filter = FF.equal(FF.property("location"), FF.literal("sample.grb2"), true); final int removed = granules.removeGranules(filter); assertEquals (1, removed); granulesCollection = granules.getGranules(null); assertEquals(0, granulesCollection.size());
"No valid granule store has been found for: " + coverageName); final SimpleFeatureType indexSchema = store.getSchema(); final SimpleFeature feature = new ShapefileCompatibleFeature(DataUtilities.template(indexSchema)); store.setTransaction(transaction); Utils.FF.literal(fileLocation), !isCaseSensitiveFileSystem(fileBeingProcessed)); store.removeGranules(filter); store.addGranules(collection);
@Override public void updateGranules(String[] attributeNames, Object[] attributeValues, Filter filter) { store.updateGranules(attributeNames, attributeValues, filter); }
@Override public void setTransaction(Transaction transaction) { store.setTransaction(transaction); } }
@Override public Transaction getTransaction() { return delegate.getTransaction(); }
((StructuredGridCoverage2DReader) reader) .getGranules("regional_currents", true); SimpleFeatureCollection granulesCollection = granules.getGranules(null); final int removed = granules.removeGranules(filter); assertEquals(1, removed); granulesCollection = granules.getGranules(null); assertEquals(0, granulesCollection.size());
@Override public void updateGranules(String[] attributeNames, Object[] attributeValues, Filter filter) { delegate.updateGranules(attributeNames, attributeValues, filter); }
@Override public void setTransaction(Transaction transaction) { delegate.setTransaction(transaction); }
@Override public Transaction getTransaction() { return store.getTransaction(); }
/** * Removes granules selected by the given filter, controlled by a set of hints (might be * implementation dependent and eventually ignored). * * @param filter an OpenGIS filter * @param hints a set of hints to control how the removal is performed * @throws IOException if an error occurs modifying the data source */ default int removeGranules(Filter filter, Hints hints) { // the default implementation just delegates to the hint-less version of the method return removeGranules(filter); }
@Override public void addGranules(SimpleFeatureCollection granules) { try { ReTypingFeatureCollection backMapped = new ReTypingFeatureCollection(granules, delegate.getSchema()); store.addGranules(backMapped); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public int removeGranules(Filter filter) { return delegate.removeGranules(filter); }
@Override public int removeGranules(Filter filter) { return store.removeGranules(filter); }
@Override public int removeGranules(Filter filter, Hints hints) { return store.removeGranules(filter, hints); }
@Override public int removeGranules(Filter filter, Hints hints) { return delegate.removeGranules(filter, hints); }
if (policy == GranuleRemovalPolicy.NONE) { removed = delegate.removeGranules(filter, hints); } else { removed = delegate.removeGranules(filter);
private void granulesDeleteInternal( String workspaceName, String storeName, String coverageName, String purge, Filter filter) throws IOException { GranuleStore store = getGranuleStore(workspaceName, storeName, coverageName); if (purge != null) { GranuleRemovalPolicy policy = mapRemovalPolicy(purge); Hints hints = new Hints(Hints.GRANULE_REMOVAL_POLICY, policy); store.removeGranules(filter, hints); } else { store.removeGranules(filter); } }