public StyleAccessLimits getAccessLimits(Authentication user, StyleInfo style) { if (user == null) { return null; } final String name = user.getName(); return (StyleAccessLimits) getUserMap(name).get(style.getId()); }
public List<LayerInfo> getLayers(StyleInfo style) { String id = style.getId(); Filter filter = or(Predicates.equal("defaultStyle.id", id), Predicates.equal("styles.id", id)); return filterLayers(filter); }
public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof StyleInfo)) return false; final StyleInfo other = (StyleInfo) obj; if (filename == null) { if (other.getFilename() != null) return false; } else if (!filename.equals(other.getFilename())) return false; if (id == null) { if (other.getId() != null) return false; } else if (!id.equals(other.getId())) return false; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; if (workspace == null) { if (other.getWorkspace() != null) return false; } else if (!workspace.equals(other.getWorkspace())) return false; if (format == null) { if (other.getFormat() != null) return false; } else { if (!format.equals(other.getFormat())) return false; } if (languageVersion == null) { if (other.getFormatVersion() != null) return false; } else if (!languageVersion.equals(other.getFormatVersion())) return false; return true; }
public void visit(StyleInfo style) { // find the layers having this style as primary or secondary Filter anyStyle = Predicates.equal("styles.id", style.getId(), MatchAction.ANY); Filter layersAssociated = Predicates.or(Predicates.equal("defaultStyle.id", style.getId()), anyStyle); // remove style references in layers try (CloseableIterator<LayerInfo> it = catalog.list(LayerInfo.class, layersAssociated)) { while (it.hasNext()) { LayerInfo layer = it.next(); removeStyleInLayer(layer, style); } } // groups can also refer to style, reset each reference to the // associated layer default style Filter groupAssociated = Predicates.or(Predicates.equal("rootLayerStyle.id", style.getId()), anyStyle); try (CloseableIterator<LayerGroupInfo> it = catalog.list(LayerGroupInfo.class, groupAssociated)) { while (it.hasNext()) { LayerGroupInfo group = it.next(); removeStyleInLayerGroup(group, style); } } // finally remove the style catalog.remove(style); }
/** Keys for overriding default layer properties */ public static class StyleProperty<T> { T get(Map<StyleProperty, Object> map, T def) { return map != null && map.containsKey(this) ? (T) map.get(this) : def; } public static StyleProperty<String> FORMAT = new StyleProperty<String>(); public static StyleProperty<Version> FORMAT_VERSION = new StyleProperty<Version>(); public static StyleProperty<LegendInfo> LEGEND_INFO = new StyleProperty<LegendInfo>(); }
styles.add(s); expect(s.getId()).andReturn(sId); expect(s.getName()).andReturn(name).anyTimes(); expect(s.getFilename()).andReturn(filename).anyTimes();
@Test public void testGetStyleById() { addStyle(); StyleInfo s2 = catalog.getStyle(s.getId()); assertNotNull(s2); assertNotSame(s, s2); assertEquals(s, s2); }
@Test public void testModifyLayerGroup() throws Exception { testAddLayerGroup(); LayerGroupInfo lg = catalog.getLayerGroupByName("lg"); StyleInfo s = catalog.getFactory().createStyle(); s.setName("foostyle2"); s.setFilename("foostyle2.sld"); catalog.add(s); lg.getStyles().set(0, s); catalog.save(lg); File f = new File(testData.getDataDirectoryRoot(), "layergroups/lg.xml"); Document dom = dom(f); assertXpathEvaluatesTo(s.getId(), "/layerGroup/styles/style/id", dom); }
public void setStyle(StyleInfo style) { if (style == null) styleId = null; else styleId = style.getId(); }
public String getIdValue(Object object, int index) { return ((StyleInfo) object).getId(); } }
public void setStyle( StyleInfo style ) { if(style == null) sid = null; else sid = style.getId(); }
public String getIdValue(StyleInfo object, int index) { return object.getId(); } }
public StyleDetachableModel(StyleInfo style) { this.id = style.getId(); }
public String getIdValue(Object object, int index) { return ((StyleInfo) object).getId(); }
public StyleDetachableModel(StyleInfo style) { this.id = style.getId(); }
public String getIdValue(Object object, int index) { return ((StyleInfo) object).getId(); }
@Override public void visit(StyleInfo style) { StyleInfo otherStyle = otherCatalog.getStyle(style.getId()); if (!(Objects.equals(style, otherStyle) && getStyleFile(style, dataDir).equals(getStyleFile(otherStyle, otherDataDir)))) { differences.add(new InfoDiff(style, otherStyle)); } }
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()); }