public void addGridSet(GridSet gridSet) { log.debug("Adding " + gridSet.getName()); getConfigurations() .stream() .filter(c -> c.canSave(gridSet)) .findFirst() .orElseThrow( () -> new UnsupportedOperationException( "No Configuration is able to save gridset " + gridSet.getName())) .addGridSet(gridSet); }
public synchronized void removeGridSet(final String gridSetName) { getConfigurations() .stream() .filter(c -> c.getGridSet(gridSetName).isPresent()) .forEach( c -> { c.removeGridSet(gridSetName); }); }
/** Get all the gridsets provided by this configuration */ default Set<String> getGridSetNames() { return getGridSets().stream().map(GridSet::getName).collect(Collectors.toSet()); }
@Override public void testCanSaveGoodInfo() throws Exception { // Should not be able to save anything as it is read only assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(false)); }
protected Optional<GridSet> getGridSet(String name) { for (GridSetConfiguration c : getConfigurations()) { Optional<GridSet> gridSet = c.getGridSet(name); if (gridSet.isPresent()) { GridSet set = gridSet.get(); return Optional.of(set); } } return Optional.empty(); }
@Override protected void addInfo(GridSetConfiguration config, GridSet info) throws Exception { config.addGridSet(info); }
@Override protected void removeInfo(GridSetConfiguration config, String name) throws Exception { config.removeGridSet(name); }
@Override protected void renameInfo(GridSetConfiguration config, String name1, String name2) throws Exception { config.renameGridSet(name1, name2); }
@Override protected Set<String> getInfoNames(GridSetConfiguration config) throws Exception { return config.getGridSetNames(); }
@Override protected void modifyInfo(GridSetConfiguration config, GridSet info) throws Exception { config.modifyGridSet(info); }
@Override public void testCanSaveGoodInfo() throws Exception { // Should not be able to save anything as it is read only assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(false)); }
@Override protected Optional<GridSet> getInfo(GridSetConfiguration config, String name) throws Exception { return config.getGridSet(name); }
false); gridSetConfiguration.addGridSet(epsg2163);
@Test public void testCanSaveBadInfo() throws Exception { assertThat(config.canSave(getBadInfo("test", 1)), equalTo(false)); }
@Test public void testLayerGridsets() throws Exception { TileLayer layer = requirePresent(((GetCapabilitiesConfiguration) config).getLayer("testExisting")); GridSet gridset = assertPresent(config.getGridSet("testExisting:EPSG:3978")); GridSubset gridSubset = layer.getGridSubset("testExisting:EPSG:3978"); GridSet gridSet2 = gridSubset.getGridSet(); assertThat(gridSet2, equalTo(gridset)); }
@Override protected Collection<? extends GridSet> getInfos(GridSetConfiguration config) throws Exception { return config.getGridSets(); }
@Test public void testCanSaveGoodInfo() throws Exception { assertThat(config.canSave(getGoodInfo("test", 1)), equalTo(true)); }