@Test void filter() { BundleFilter bundleFilter = new BundleFilter(new EntityFilterRegistry(Collections.emptySet())); Bundle bundle = FilterTestUtils.getBundle(); Bundle filteredBundle = bundleFilter.filter("/my/folder/path", new FilterConfiguration(), bundle); assertEquals(1, filteredBundle.getEntities(Folder.class).size()); assertNotNull(filteredBundle.getFolderTree()); }
public Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle) { filterConfiguration.getEntityFilters().keySet().forEach(k -> { boolean noFilters = filterRegistry.getEntityFilters().stream().noneMatch(f -> k.equals(f.getFilterableEntityName())); if (noFilters) { throw new IllegalArgumentException("Unknown entity type: " + k); } }); Bundle filteredBundle = new Bundle(); filterRegistry.getEntityFilters() .forEach(ef -> ((List<? extends GatewayEntity>) ef.filter(folderPath, filterConfiguration, bundle, filteredBundle)) .forEach(e -> { final Map<String, GatewayEntity> entities = filteredBundle.getEntities((Class<GatewayEntity>) e.getClass()); entities.put(e.getId(), e); } ) ); FolderFilter.parentFolders(folderPath, bundle).forEach(f -> filteredBundle.getFolders().put(f.getId(), f)); FolderTree folderTree = new FolderTree(filteredBundle.getFolders().values()); filteredBundle.setFolderTree(folderTree); return filteredBundle; }
BundleFilter { public Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle) { filterConfiguration.getEntityFilters().keySet().forEach(k -> { boolean noFilters = filterRegistry.getEntityFilters().stream().noneMatch(f -> k.equals(f.getFilterableEntityName())); if (noFilters) { throw new IllegalArgumentException("Unknown entity type: " + k); } }); Bundle filteredBundle = new Bundle(); filterRegistry.getEntityFilters() .forEach(ef -> ((List<? extends GatewayEntity>) ef.filter(folderPath, filterConfiguration, bundle, filteredBundle)) .forEach(e -> { final Map<String, GatewayEntity> entities = filteredBundle.getEntities((Class<GatewayEntity>) e.getClass()); entities.put(e.getId(), e); } ) ); FolderFilter.parentFolders(folderPath, bundle).forEach(f -> filteredBundle.getFolders().put(f.getId(), f)); FolderTree folderTree = new FolderTree(filteredBundle.getFolders().values()); filteredBundle.setFolderTree(folderTree); return filteredBundle; } }
BundleFilter { public Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle) { filterConfiguration.getEntityFilters().keySet().forEach(k -> { boolean noFilters = filterRegistry.getEntityFilters().stream().noneMatch(f -> k.equals(f.getFilterableEntityName())); if (noFilters) { throw new IllegalArgumentException("Unknown entity type: " + k); } }); Bundle filteredBundle = new Bundle(); filterRegistry.getEntityFilters() .forEach(ef -> ((List<? extends GatewayEntity>) ef.filter(folderPath, filterConfiguration, bundle, filteredBundle)) .forEach(e -> { final Map<String, GatewayEntity> entities = filteredBundle.getEntities((Class<GatewayEntity>) e.getClass()); entities.put(e.getId(), e); } ) ); FolderFilter.parentFolders(folderPath, bundle).forEach(f -> filteredBundle.getFolders().put(f.getId(), f)); FolderTree folderTree = new FolderTree(filteredBundle.getFolders().values()); filteredBundle.setFolderTree(folderTree); return filteredBundle; } @Inject  BundleFilter(EntityFilterRegistry filterRegistry); }
BundleFilter { public Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle) { filterConfiguration.getEntityFilters().keySet().forEach(k -> { boolean noFilters = filterRegistry.getEntityFilters().stream().noneMatch(f -> k.equals(f.getFilterableEntityName())); if (noFilters) { throw new IllegalArgumentException("Unknown entity type: " + k); } }); Bundle filteredBundle = new Bundle(); filterRegistry.getEntityFilters() .forEach(ef -> ((List<? extends GatewayEntity>) ef.filter(folderPath, filterConfiguration, bundle, filteredBundle)) .forEach(e -> { final Map<String, GatewayEntity> entities = filteredBundle.getEntities((Class<GatewayEntity>) e.getClass()); entities.put(e.getId(), e); } ) ); FolderFilter.parentFolders(folderPath, bundle).forEach(f -> filteredBundle.getFolders().put(f.getId(), f)); FolderTree folderTree = new FolderTree(filteredBundle.getFolders().values()); filteredBundle.setFolderTree(folderTree); return filteredBundle; } @Inject  BundleFilter(EntityFilterRegistry filterRegistry); Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle); }
BundleFilter { public Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle) { filterConfiguration.getEntityFilters().keySet().forEach(k -> { boolean noFilters = filterRegistry.getEntityFilters().stream().noneMatch(f -> k.equals(f.getFilterableEntityName())); if (noFilters) { throw new IllegalArgumentException("Unknown entity type: " + k); } }); Bundle filteredBundle = new Bundle(); filterRegistry.getEntityFilters() .forEach(ef -> ((List<? extends GatewayEntity>) ef.filter(folderPath, filterConfiguration, bundle, filteredBundle)) .forEach(e -> { final Map<String, GatewayEntity> entities = filteredBundle.getEntities((Class<GatewayEntity>) e.getClass()); entities.put(e.getId(), e); } ) ); FolderFilter.parentFolders(folderPath, bundle).forEach(f -> filteredBundle.getFolders().put(f.getId(), f)); FolderTree folderTree = new FolderTree(filteredBundle.getFolders().values()); filteredBundle.setFolderTree(folderTree); return filteredBundle; } @Inject  BundleFilter(EntityFilterRegistry filterRegistry); Bundle filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle);  }