@Override public List<IComponent> filterNeededComponents( Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) { List<IComponent> neededComponents = new ArrayList<IComponent>(); if (!(item instanceof HCatalogConnectionItem)) { return neededComponents; } IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class); Set<IComponent> components = service.getComponentsFactory().getComponents(); for (IComponent component : components) { if (isValid(item, type, seletetedNode, component, HCATALOG) && !neededComponents.contains(component)) { neededComponents.add(component); } } return neededComponents; }
public static List<IComponent> filterNeededComponents( Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) { if (!GlobalServiceRegister.getDefault().isServiceRegistered(IComponentsService.class)) { return Collections.emptyList(); } IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class); Set<IComponent> components = service.getComponentsFactory().getComponents(); List<IComponent> neededComponents = new ArrayList<IComponent>(); List<IComponent> exceptedComponents = new ArrayList<IComponent>(); for (IComponent component : components) { // for (RepositoryComponentDndFilterSetting dndFilter : getDndFilterSettings()) { IRepositoryComponentDndFilter filter = dndFilter.getFilter(); if (filter == null) { continue; } String repositoryType = filter.getRepositoryType(item, type); if (repositoryType == null) { continue; } if (!exceptedComponents.contains(component) && filter.except(item, type, seletetedNode, component, repositoryType)) { exceptedComponents.add(component); } // if have been excepted, so no need add it to needed component if (!exceptedComponents.contains(component) && !neededComponents.contains(component) && filter.valid(item, type, seletetedNode, component, repositoryType)) { neededComponents.add(component); } } } // remove all excepted components neededComponents.removeAll(exceptedComponents); return sortFilteredComponnents(item, seletetedNode, type, neededComponents); }