public StyleInfo getDefaultStyle() { return delegate.getDefaultStyle(); }
protected void handleNoStyles() { // handle no styles -- use default try { if (styleCount == 0 && info != null && info instanceof LayerInfo) { StyleInfo styleInfo = ((LayerInfo) info).getDefaultStyle(); if (styleInfo != null) { visit(styleInfo.getStyle()); } } } catch (IOException e) { throw new UncheckedIOException(e); } finally { // clean up state styleCount = 0; } }
public List<LayerInfo> getLayers(StyleInfo style) { List<LayerInfo> matches = layers.list( LayerInfo.class, li -> style.equals(li.getDefaultStyle()) || li.getStyles().contains(style)); return ModificationProxy.createList(matches, LayerInfo.class); }
protected boolean handleLayerGroup() { // NamedLayer - LayerGroup: ignore any defined styles and use the layer group instead if (info != null && info instanceof LayerGroupInfo) { LayerGroupInfo lg = (LayerGroupInfo) info; List<LayerInfo> layers = lg.layers(); List<StyleInfo> styles = lg.styles(); try { for (int i = 0; i < layers.size(); i++) { info = layers.get(i); StyleInfo style = styles.get(i); if (style == null) { visit(layers.get(i).getDefaultStyle().getStyle()); } else { visit(styles.get(i).getStyle()); } } } catch (IOException e) { throw new UncheckedIOException(e); } return true; } return false; }
private void removeStyleInLayerGroup(LayerGroupInfo group, StyleInfo style) { boolean dirty = false; // root layer style if (style.equals(group.getRootLayerStyle())) { group.setRootLayerStyle( getResourceDefaultStyle(group.getRootLayer().getResource(), style)); dirty = true; } // layer styles List<StyleInfo> styles = group.getStyles(); for (int i = 0; i < styles.size(); i++) { StyleInfo publishedStyle = styles.get(i); if (publishedStyle != null && publishedStyle.equals(style)) { // if publishedStyle is not null, we have a layer LayerInfo layer = (LayerInfo) group.getLayers().get(i); if (!layer.getDefaultStyle().equals(style)) { // use default style styles.set(i, layer.getDefaultStyle()); } else { styles.set(i, getResourceDefaultStyle(layer.getResource(), style)); } dirty = true; } } if (dirty) { catalog.save(group); } }
private void removeStyleInLayer(LayerInfo layer, StyleInfo style) { boolean dirty = false; // remove it from the associated styles if (layer.getStyles().remove(style)) { dirty = true; } // if it's the default style, choose an associated style or reset it to the default one StyleInfo ds = layer.getDefaultStyle(); if (ds != null && ds.equals(style)) { dirty = true; StyleInfo newDefaultStyle; if (layer.getStyles().size() > 0) { newDefaultStyle = layer.getStyles().iterator().next(); layer.getStyles().remove(newDefaultStyle); } else { newDefaultStyle = getResourceDefaultStyle(layer.getResource(), style); } layer.setDefaultStyle(newDefaultStyle); } if (dirty) { catalog.save(layer); } }
final LayerInfo other = (LayerInfo) obj; if (defaultStyle == null) { if (other.getDefaultStyle() != null) return false; } else if (!defaultStyle.equals(other.getDefaultStyle())) return false; if (id == null) { if (other.getId() != null) return false;
if (layer.getDefaultStyle() == null) { try { LOGGER.log(
protected void resolve(LayerInfo layer) { setId(layer); ResourceInfo resource = ResolvingProxy.resolve(getCatalog(), layer.getResource()); if (resource != null) { resource = unwrap(resource); layer.setResource(resource); } StyleInfo style = ResolvingProxy.resolve(getCatalog(), layer.getDefaultStyle()); if (style != null) { style = unwrap(style); layer.setDefaultStyle(style); } LinkedHashSet<StyleInfo> styles = new LinkedHashSet<StyleInfo>(); for (StyleInfo s : layer.getStyles()) { s = ResolvingProxy.resolve(getCatalog(), s); s = unwrap(s); styles.add(s); } ((LayerInfoImpl) layer).setStyles(styles); }
while (it.hasNext()) { LayerInfo li = it.next(); if (style.equals(li.getDefaultStyle())) add(li, ModificationType.STYLE_RESET); else if (li.getStyles().contains(style)) add(li, ModificationType.EXTRA_STYLE_REMOVED);
@Test public void testDanglingReferenceOnModificationProxy() { LayerInfo li = getCatalog().getLayerByName(getLayerId(SystemTestData.BUILDINGS)); assertNull(li.getDefaultStyle()); }
expect(l.getType()).andReturn(PublishedType.VECTOR).anyTimes(); expect(l.getResource()).andReturn(r).anyTimes(); expect(l.getDefaultStyle()).andReturn(s).anyTimes(); expect(l.getStyles()).andReturn(Collections.singleton(s)).anyTimes(); expect(l.isEnabled()).andReturn(true).anyTimes();
@Test public void testGenericStyle() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.GENERICENTITY.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.GENERICENTITY)); LayerInfo li = cb.buildLayer(fti); // check we assigned the generic style assertEquals("generic", li.getDefaultStyle().getName()); }
@Test public void testCascadeStyle() { Catalog catalog = getCatalog(); StyleInfo style = catalog.getStyleByName(LAKES.getLocalPart()); assertNotNull(style); new CascadeDeleteVisitor(catalog).visit(style); assertNull(catalog.getStyleByName(LAKES.getLocalPart())); LayerInfo layer = catalog.getLayerByName(getLayerId(LAKES)); assertEquals("polygon", layer.getDefaultStyle().getName()); } }
@Test public void testGeometryless() throws Exception { // build a feature type (it's already in the catalog, but we just want to // check it's built as expected // LINES is a feature type with a native SRS, so we want the bounds to be there Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getDataStoreByName(MockData.GEOMETRYLESS.getPrefix())); FeatureTypeInfo fti = cb.buildFeatureType(toName(MockData.GEOMETRYLESS)); LayerInfo layer = cb.buildLayer(fti); cb.setupBounds(fti); // perform basic checks assertEquals(CatalogBuilder.DEFAULT_SRS, fti.getSRS()); assertNotNull(fti.getNativeBoundingBox()); assertTrue(fti.getNativeBoundingBox().isEmpty()); assertNotNull(fti.getLatLonBoundingBox()); assertFalse(fti.getLatLonBoundingBox().isEmpty()); assertNull(layer.getDefaultStyle()); }
ModificationProxy.unwrap(li2.getResource())); assertSame( ModificationProxy.unwrap(li.getDefaultStyle()), ModificationProxy.unwrap(li2.getDefaultStyle())); assertSame( ModificationProxy.unwrap(li.getStyles().iterator().next()), ModificationProxy.unwrap(lim.getDefaultStyle()), ModificationProxy.unwrap(lim2.getDefaultStyle())); assertSame( ModificationProxy.unwrap(lim.getStyles().iterator().next()),
assertEquals(s, l.getDefaultStyle()); assertNotNull(l.getStyles()); assertEquals(1, l.getStyles().size());
public void testTruncateByLayerAndStyle() throws Exception { String layerName = tileLayer.getName(); String styleName = "notACachedStyle"; mediator.truncateByLayerAndStyle(layerName, styleName); verify(tileBreeder, never()).dispatchTasks(any(GWCTask[].class)); styleName = layer.getDefaultStyle().getName(); mediator.truncateByLayerAndStyle(layerName, styleName); int expected = tileLayer.getGridSubsets().size() * tileLayer.getMimeTypes().size(); verify(tileBreeder, times(expected)).dispatchTasks(any(GWCTask[].class)); }
private void addToMap(final WMSMapContent map, final QName typeName) throws IOException { final FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart()); List<LayerInfo> layers = getCatalog().getLayers(ftInfo); StyleInfo defaultStyle = layers.get(0).getDefaultStyle(); Style style = defaultStyle.getStyle(); map.addLayer(new FeatureLayer(ftInfo.getFeatureSource(null, null), style)); }
StyleInfo writeStyleAndImport(String sld, String filename, File dir) throws IOException { FileUtils.write(new File(dir, filename), sld); ImportContext imp = importer.createContext(new Directory(dir)); importer.run(imp); assertEquals(ImportContext.State.COMPLETE, imp.getState()); checkNoErrors(imp); return getCatalog().getStyle(imp.getTasks().get(0).getLayer().getDefaultStyle().getId()); }