public void save(MapInfo map) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(map); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(map, propertyNames, oldValues, newValues); commitProxy(map); afterSaved(map, propertyNames, oldValues, newValues); }
@Override public LayerGroupInfo getLayerGroupByName(String name) { return getLayerGroupByName(NO_WORKSPACE, name); }
all = (List<T>) namespaces.list(of, toPredicate(filter)); } else if (WorkspaceInfo.class.isAssignableFrom(of)) { all = (List<T>) workspaces.list(of, toPredicate(filter)); } else if (StoreInfo.class.isAssignableFrom(of)) { all = (List<T>) stores.list(of, toPredicate(filter)); } else if (ResourceInfo.class.isAssignableFrom(of)) { all = (List<T>) resources.list(of, toPredicate(filter)); } else if (LayerInfo.class.isAssignableFrom(of)) { all = (List<T>) layers.list(of, toPredicate(filter)); } else if (LayerGroupInfo.class.isAssignableFrom(of)) { all = (List<T>) layerGroups.list(of, toPredicate(filter)); } else if (PublishedInfo.class.isAssignableFrom(of)) { all = new ArrayList<>(); all.addAll((List<T>) layers.list(LayerInfo.class, toPredicate(filter))); all.addAll((List<T>) layerGroups.list(LayerGroupInfo.class, toPredicate(filter))); } else if (StyleInfo.class.isAssignableFrom(of)) { all = (List<T>) styles.list(of, toPredicate(filter)); } else if (MapInfo.class.isAssignableFrom(of)) { all = (List<T>) new ArrayList<>(maps); for (int i = sortByList.length - 1; i >= 0; i--) { SortBy sortBy = sortByList[i]; Ordering<Object> ordering = Ordering.from(comparator(sortBy)); if (SortOrder.DESCENDING.equals(sortBy.getSortOrder())) { ordering = ordering.reverse();
@Override public <T extends CatalogInfo> CloseableIterator<T> list( final Class<T> of, final Filter filter, @Nullable Integer offset, @Nullable Integer count, @Nullable SortBy... sortOrder) { if (sortOrder != null) { for (SortBy so : sortOrder) { if (sortOrder != null && !canSort(of, so.getPropertyName().getPropertyName())) { throw new IllegalArgumentException( "Can't sort objects of type " + of.getName() + " by " + so.getPropertyName()); } } } Iterable<T> iterable = iterable(of, filter, sortOrder); if (offset != null && offset.intValue() > 0) { iterable = Iterables.skip(iterable, offset.intValue()); } if (count != null && count.intValue() >= 0) { iterable = Iterables.limit(iterable, count.intValue()); } Iterator<T> iterator = iterable.iterator(); return new CloseableIteratorAdapter<T>(iterator); }
public <T extends ResourceInfo> T getResourceByStore( StoreInfo store, String name, Class<T> clazz) { T resource = null; NamespaceInfo ns = null; if (store.getWorkspace() != null && store.getWorkspace().getName() != null && (ns = getNamespaceByPrefix(store.getWorkspace().getName())) != null) { resource = resources.findByName(new NameImpl(ns.getId(), name), clazz); if (resource != null && !(store.equals(resource.getStore()))) { return null; } } else { // should not happen, but some broken test code sets up namespaces without equivalent // workspaces // or stores without workspaces resource = resources.findFirst( clazz, r -> name.equals(r.getName()) && store.equals(r.getStore())); } return wrapInModificationProxy(resource, clazz); }
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 CatalogImpl() { facade = new DefaultCatalogFacade(this); // wrap the default catalog facade with the facade capable of handling isolated workspaces // behavior facade = new IsolatedCatalogFacade(facade); setFacade(facade); resourcePool = ResourcePool.create(this); }
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<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 void save(StoreInfo store) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(store); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(store, propertyNames, oldValues, newValues); stores.update(store); commitProxy(store); afterSaved(store, propertyNames, oldValues, newValues); }
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); }
public void save(LayerInfo layer) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(layer); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(layer, propertyNames, oldValues, newValues); layers.update(layer); commitProxy(layer); afterSaved(layer, propertyNames, oldValues, newValues); }
public void save(LayerGroupInfo layerGroup) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(layerGroup); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(layerGroup, propertyNames, oldValues, newValues); layerGroups.update(layerGroup); commitProxy(layerGroup); afterSaved(layerGroup, propertyNames, oldValues, newValues); }
public void save(NamespaceInfo namespace) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(namespace); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(namespace, propertyNames, oldValues, newValues); namespaces.update(namespace); commitProxy(namespace); afterSaved(namespace, propertyNames, oldValues, newValues); }
public void save(StyleInfo style) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(style); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(style, propertyNames, oldValues, newValues); styles.update(style); commitProxy(style); afterSaved(style, propertyNames, oldValues, newValues); }
public void save(ResourceInfo resource) { ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(resource); // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(resource, propertyNames, oldValues, newValues); resources.update(resource); layers.update(resource); commitProxy(resource); afterSaved(resource, propertyNames, oldValues, newValues); }
public void save(WorkspaceInfo workspace) { // need to synch up the default store lookup ModificationProxy h = (ModificationProxy) Proxy.getInvocationHandler(workspace); WorkspaceInfo ws = (WorkspaceInfo) h.getProxyObject(); if (!workspace.getName().equals(ws.getName())) { DataStoreInfo ds = defaultStores.remove(ws.getName()); if (ds != null) { defaultStores.put(workspace.getName(), ds); } } // figure out what changed List<String> propertyNames = h.getPropertyNames(); List<Object> newValues = h.getNewValues(); List<Object> oldValues = h.getOldValues(); beforeSaved(workspace, propertyNames, oldValues, newValues); workspaces.update(workspace); commitProxy(workspace); afterSaved(workspace, propertyNames, oldValues, newValues); }