public List<MapInfo> getMaps() { return ModificationProxy.createList(new ArrayList(maps), MapInfo.class); }
public List<LayerGroupInfo> getLayerGroups() { return ModificationProxy.createList( new ArrayList<>(layerGroups.values()), LayerGroupInfo.class); }
public Collection<? extends ServiceInfo> getServices() { return ModificationProxy.createList(filter(services, null), ServiceInfo.class); }
public List<LayerInfo> getLayers() { return ModificationProxy.createList(new ArrayList<>(layers.values()), LayerInfo.class); }
public List<StyleInfo> getStyles() { return ModificationProxy.createList(new ArrayList<>(styles.values()), StyleInfo.class); }
public List<NamespaceInfo> getNamespaces() { return ModificationProxy.createList( new ArrayList<>(namespaces.values()), NamespaceInfo.class); }
public List<WorkspaceInfo> getWorkspaces() { return ModificationProxy.createList( new ArrayList<>(workspaces.values()), WorkspaceInfo.class); }
@Override public Collection<? extends ServiceInfo> getServices(WorkspaceInfo workspace) { return ModificationProxy.createList(filter(services, workspace), ServiceInfo.class); }
public <T extends StoreInfo> List<T> getStores(Class<T> clazz) { return ModificationProxy.createList(stores.list(clazz, CatalogInfoLookup.TRUE), clazz); }
public <T extends ResourceInfo> List<T> getResources(Class<T> clazz) { return ModificationProxy.createList(resources.list(clazz, CatalogInfoLookup.TRUE), clazz); }
public List<LayerInfo> getLayers(ResourceInfo resource) { // in the current setup we cannot have multiple layers associated to the same // resource, as they would all share the same name (the one of the resource) so // a direct lookup becomes possible Name name = RESOURCE_NAME_MAPPER.apply(resource); LayerInfo layer = layers.findByName(name, LayerInfo.class); if (layer == null) { return Collections.emptyList(); } else { List<LayerInfo> matches = new ArrayList<>(); matches.add(layer); return ModificationProxy.createList(matches, LayerInfo.class); } // we check the id first as it's faster to compare than a full blown equals // String id = resource.getId(); // List<LayerInfo> matches = layers.list(LayerInfo.class, li -> // id.equals(li.getResource().getId()) && resource.equals(li.getResource())); // return ModificationProxy.createList(matches,LayerInfo.class); }
/** * Helper method that removes from a list the catalog objects not visible in the current * context. This method takes care of the proper modification proxy unwrapping \ wrapping. * * @param objects list of catalog object, wrapped with a modification proxy * @param type the class of the list objects * @param filter filter that checks if an element should be visible * @return a list wrapped with a modification proxy that contains the visible catalog objects */ private <T extends CatalogInfo> List<T> filterIsolated( List<T> objects, Class<T> type, Function<T, T> filter) { // unwrap the catalog objects list List<T> unwrapped = ModificationProxy.unwrap(objects); // filter the non visible catalog objects and wrap the resulting list with a modification // proxy return ModificationProxy.createList( unwrapped .stream() .filter(store -> filter.apply(store) != null) .collect(Collectors.toList()), type); }
@Override public List<NamespaceInfo> getNamespacesByURI(String uri) { List<NamespaceInfo> found = namespaces.list( NamespaceInfo.class, namespaceInfo -> namespaceInfo.getURI().equals(uri)); return ModificationProxy.createList(found, NamespaceInfo.class); }
public <T extends ResourceInfo> List<T> getResourcesByStore(StoreInfo store, Class<T> clazz) { List<T> matches = resources.list(clazz, r -> store.equals(r.getStore())); return ModificationProxy.createList(matches, clazz); }
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); }
public <T extends StoreInfo> List<T> getStoresByWorkspace( WorkspaceInfo workspace, Class<T> clazz) { // TODO: support ANY_WORKSPACE? WorkspaceInfo ws; if (workspace == null) { ws = getDefaultWorkspace(); } else { ws = workspace; } List<T> matches = stores.list(clazz, s -> ws.equals(s.getWorkspace())); return ModificationProxy.createList(matches, clazz); }
public List<LayerGroupInfo> getLayerGroupsByWorkspace(WorkspaceInfo workspace) { // TODO: support ANY_WORKSPACE? WorkspaceInfo ws; if (workspace == null) { ws = getDefaultWorkspace(); } else { ws = workspace; } Predicate<LayerGroupInfo> predicate; if (workspace == NO_WORKSPACE) { predicate = lg -> lg.getWorkspace() == null; } else { predicate = lg -> ws.equals(lg.getWorkspace()); } List<LayerGroupInfo> matches = layerGroups.list(LayerGroupInfo.class, predicate); return ModificationProxy.createList(matches, LayerGroupInfo.class); }
public <T extends ResourceInfo> List<T> getResourcesByNamespace( NamespaceInfo namespace, Class<T> clazz) { // TODO: support ANY_NAMESPACE? NamespaceInfo ns; if (namespace == null) { ns = getDefaultNamespace(); } else { ns = namespace; } List<T> matches = resources.list(clazz, r -> ns.equals(r.getNamespace())); return ModificationProxy.createList(matches, clazz); }
public List<StyleInfo> getStylesByWorkspace(WorkspaceInfo workspace) { // TODO: support ANY_WORKSPACE? List<StyleInfo> matches; if (workspace == NO_WORKSPACE) { matches = styles.list(StyleInfo.class, s -> s.getWorkspace() == null); } else { WorkspaceInfo ws; if (workspace == null) { ws = getDefaultWorkspace(); } else { ws = workspace; } matches = styles.list(StyleInfo.class, s -> ws.equals(s.getWorkspace())); } return ModificationProxy.createList(matches, StyleInfo.class); }
return ModificationProxy.createList(all, of);