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); }
return rootAccess ? Filter.INCLUDE : Filter.EXCLUDE; } else { return rootAccess ? Predicates.and(exceptions) : Predicates.or(exceptions); wsAccess ? Predicates.and(layerExceptions) : Predicates.or(layerExceptions); exceptions.add(combined); return rootAccess ? Filter.INCLUDE : Filter.EXCLUDE; } else { Filter filter = rootAccess ? Predicates.and(exceptions) : Predicates.or(exceptions); Predicates.and(Predicates.isInstanceOf(LayerInfo.class), filter); Filter layerGroupFilter = Predicates.isInstanceOf(LayerGroupInfo.class); return Predicates.or(layerFilter, layerGroupFilter); } else { return filter; return rootAccess ? Filter.INCLUDE : Filter.EXCLUDE; } else { return rootAccess ? Predicates.and(exceptions) : Predicates.or(exceptions);
public void visit(StyleInfo style) { Filter layersAssociated = Predicates.or(Predicates.equal("defaultStyle", style), anyStyle); Filter groupAssociated = Predicates.or(Predicates.equal("rootLayerStyle", style), anyStyle); try (CloseableIterator<LayerGroupInfo> it = catalog.list(LayerGroupInfo.class, groupAssociated)) {
return Predicates.or(localLayerFilter, inWorkspace()); } else if (WorkspaceInfo.class.isAssignableFrom(clazz)) { groupIdFilters.add(Predicates.equal("id", group.getId())); return Predicates.or(groupIdFilters); layersIdFilters.add(Predicates.equal("id", layer.getId())); return Predicates.or(layersIdFilters);
private Filter standardFilter(Class<? extends CatalogInfo> clazz) { final Filter forGlobal; if (LocalWorkspace.get() != null) { // TODO need a well known implementation // Show globals unless an object with the same name is in the local workspace forGlobal = super.getSecurityFilter(clazz); } else { // Global request, show all globals forGlobal = Predicates.acceptAll(); } // If it's a global use the global filter, otherwise check if it's in the local workspace return Predicates.or( Predicates.and(Predicates.isNull("workspace.id"), forGlobal), Predicates.and( Predicates.factory.not(Predicates.isNull("workspace.id")), inWorkspace())); }
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); }
assertEquals(expected, actual); filter = or(contains("name", "t2"), contains("name", "t1")); expected = Sets.newHashSet(ft1, ft2); actual = Sets.newHashSet(catalog.list(FeatureTypeInfo.class, filter)); assertEquals(expected, actual); filter = or(contains("styles.name", "s6"), equal("defaultStyle.name", "s1")); expected = Sets.newHashSet(l1, l3); actual = Sets.newHashSet(catalog.list(LayerInfo.class, filter));
private Filter buildSearchTermsFilter(Object value) { String converted = getParameter(SEARCH_TERMS.key, value, String.class); // split into parts separated by spaces, but not bits in double quotes Pattern MATCH_TERMS_SPLITTER = Pattern.compile("([^\"]\\S*|\".+?\")\\s*"); Matcher m = MATCH_TERMS_SPLITTER.matcher(converted); List<String> keywords = new ArrayList<>(); while (m.find()) { String group = m.group(1); if (group.startsWith("\"") && group.endsWith("\"") && group.length() > 1) { group = group.substring(1, group.length() - 1); } keywords.add(group); } // turn into a list of Like filters // TODO: actually implement a full text search function List<Filter> filters = keywords.stream() .map(s -> FF.like(FF.property("htmlDescription"), "%" + s + "%")) .collect(Collectors.toList()); // combine and return Filter result = Predicates.or(filters); return result; }
/** * This method returns a filter based on the defined keywords. * * @return a {@link Filter} which uses the defined Keywords. If no keyword is present * Filter.INCLUDE is returned */ protected Filter getFilter() { final String[] keywords = getKeywords(); Filter filter = acceptAll(); if (null != keywords) { for (String keyword : keywords) { Filter propContains = Predicates.fullTextSearch(keyword); // chain the filters together if (Filter.INCLUDE == filter) { filter = propContains; } else { filter = or(filter, propContains); } } } return filter; }
@Override protected Filter getFilter() { Filter filter = super.getFilter(); // need to get only advertised and enabled layers Filter isLayerInfo = Predicates.isInstanceOf(LayerInfo.class); Filter isLayerGroupInfo = Predicates.isInstanceOf(LayerGroupInfo.class); Filter enabledFilter = Predicates.equal("resource.enabled", true); Filter storeEnabledFilter = Predicates.equal("resource.store.enabled", true); Filter advertisedFilter = Predicates.equal("resource.advertised", true); // return only layer groups that are not containers Filter nonContainerGroup = Predicates.or( Predicates.equal("mode", LayerGroupInfo.Mode.EO), Predicates.equal("mode", LayerGroupInfo.Mode.NAMED), Predicates.equal("mode", LayerGroupInfo.Mode.OPAQUE_CONTAINER), Predicates.equal("mode", LayerGroupInfo.Mode.SINGLE)); // Filter for the Layers Filter layerFilter = Predicates.and(isLayerInfo, enabledFilter, storeEnabledFilter, advertisedFilter); // Filter for the LayerGroups Filter layerGroupFilter = Predicates.and(isLayerGroupInfo, nonContainerGroup); // Or filter for merging them Filter orFilter = Predicates.or(layerFilter, layerGroupFilter); // And between the new filter and the initial filter return Predicates.and(filter, orFilter); }