TreeSet<Object> result = new TreeSet<>(visitor.getUnique()); return result;
private void initVisitor() { visitor = new UniqueVisitor(this.idFieldName); visitor.setStartIndex(currentVisitorStart); visitor.setMaxFeatures(STEP_LOAD); try { fc.accepts(visitor, new NullProgressListener()); visitorIterator = visitor.getUnique().iterator(); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Extract the domain of a dimension as a set of unique values. * * <p>It retrieves a comma separated list of values as a Set of {@link String}. * * @return a comma separated list of values as a {@link String}. * @throws IOException */ Set extractDomain(final String attribute) throws IOException { Query query = new Query(typeName); query.setPropertyNames(Arrays.asList(attribute)); final UniqueVisitor visitor = new UniqueVisitor(attribute); granuleCatalog.computeAggregateFunction(query, visitor); return visitor.getUnique(); }
/** * Check if there is any granule referred by other coverages. * * @param coverageName * @return * @throws IOException */ private boolean checkForReferences(String coverageName) throws IOException { final String[] coverageNames = parentReader.getGridCoverageNames(); for (String typeName : coverageNames) { if (!coverageName.equalsIgnoreCase(typeName)) { Query query = new Query(typeName); final SimpleFeatureCollection collection = granuleCatalog.getGranules(query); UniqueVisitor visitor = new UniqueVisitor(parentReader.locationAttributeName); collection.accepts(visitor, null); Set<String> features = visitor.getUnique(); if (features.size() > 0) { return true; } } } return false; }
private List<String> collectFilesFromTable(DataStore sourceStore, String table) throws IOException { final SimpleFeatureSource featureSource = sourceStore.getFeatureSource(table); final Properties properties = getCoverageConfiguration(table); String locationAttribute = getProperty( properties, Utils.Prop.LOCATION_ATTRIBUTE, Utils.DEFAULT_LOCATION_ATTRIBUTE); PathType pathType = PathType.RELATIVE.valueOf( getProperty(properties, Utils.Prop.PATH_TYPE, PathType.ABSOLUTE.name())); // query the location attribute Query q = new Query(table); q.setPropertyNames(new String[] {locationAttribute}); // extract unique values UniqueVisitor uniqueLocations = new UniqueVisitor(locationAttribute); featureSource.getFeatures(q).accepts(uniqueLocations, null); Set<String> locations = uniqueLocations.getUnique(); // map via pathtype and return return locations .stream() .map(l -> pathType.resolvePath(configuration.getMosaicDirectory().getPath(), l)) .map(url -> URLs.urlToFile(url).getAbsolutePath()) .collect(Collectors.toList()); }
private List<String> collectFilesFromTable(ImageMosaicReader reader, String coverage) throws IOException { // grab the necessary background info final String mosaicDirectoryPath = configuration.getMosaicDirectory().getAbsolutePath(); final GranuleSource granuleSource = reader.getGranules(coverage, true); final MosaicConfigurationBean configuration = reader.getRasterManager(coverage).getConfiguration(); final CatalogConfigurationBean catalogConfiguration = configuration.getCatalogConfigurationBean(); final PathType pathType = catalogConfiguration.getPathType(); if (pathType != PathType.ABSOLUTE && pathType != PathType.RELATIVE) { throw new MigrationException("Cannot perform migration with path type " + pathType); } // query the location attribute final String locationAttribute = catalogConfiguration.getLocationAttribute(); Query q = new Query(coverage); q.setPropertyNames(new String[] {locationAttribute}); // extract unique values UniqueVisitor uniqueLocations = new UniqueVisitor(locationAttribute); final SimpleFeatureCollection granules = granuleSource.getGranules(q); granules.accepts(uniqueLocations, null); Set<String> locations = uniqueLocations.getUnique(); // map via pathtype and return return locations .stream() .map(l -> pathType.resolvePath(mosaicDirectoryPath, l)) .map(url -> URLs.urlToFile(url).getAbsolutePath()) .collect(Collectors.toList()); }
UniqueVisitor visitor = new UniqueVisitor(parentReader.locationAttributeName); collection.accepts(visitor, null); Set<String> features = visitor.getUnique(); final String coverageName = query.getTypeName();
Set<Date> values = visitor.getUnique(); if (values.size() <= 0) { result = null;
Set<Object> values = visitor.getUnique(); if (values.size() <= 0) { result = null;
TreeSet<Object> result = new TreeSet<>(visitor.getUnique()); return result;