package be.iminds.ilabt.jfed.experimenter_gui.editor.properties.cmi;

import javax.inject.Singleton;

/**
 * This class is responsible for managing the available ComponentManagerInfo of each authority.
 * <p/>
 * User: twalcari
 * Date: 8/28/2014
 * Time: 16:55
 */
@Singleton
@Deprecated
public class GlobalCMIManager implements CMIManager {
//    private static final Logger LOG = LoggerFactory.getLogger(ComponentManagerInfo.class);
//
//    private final TestbedInfoSource testbedInfoSource;
//    private final JFedGuiConfig config;
//
//    private final ObservableList<ComponentManagerInfo> componentManagerInfos;
//
//    private final ComponentManagerInfoFactory componentManagerInfoFactory;
//
//    @Inject
//    public GlobalCMIManager(TestbedInfoSource testbedInfoSource, JFedGuiConfig config,
//                            ComponentManagerInfoFactory componentManagerInfoFactory,
//                            SfaModel sfaModel) {
//        this.testbedInfoSource = testbedInfoSource;
//        this.config = config;
//        this.componentManagerInfoFactory = componentManagerInfoFactory;
//        componentManagerInfos = FXCollections.observableArrayList();
//
//        CompletableFuture.supplyAsync(() -> {
//            List<ComponentManagerInfo> result = new ArrayList<>();
//
//            testbedInfoSource.getServers().forEach(server -> {
//
//                ComponentManagerInfo cmi = componentManagerInfoFactory.
//                        createComponentManagerInfo(server, config.getTestbedDescription(server.getDefaultComponentManagerAsGeniUrn()), sfaModel);
//
//                cmi.getAvailableResources().updateComponentIds();
//                cmi.getAllResources().updateComponentIds();
//
//                result.add(cmi);
//            });
//
//
//            Collections.sort(result, Comparator.comparing(cmi -> cmi.getAuthority().getName().toLowerCase()));
//            return result;
//
//        }).thenAccept(cmiList ->
//                Platform.runLater(() -> componentManagerInfos.addAll(cmiList)));
//
//
//    }
//
//    @Override
//    public ObservableList<ComponentManagerInfo> getComponentManagerInfos() {
//        return componentManagerInfos;
//    }
//
//    @Override
//    public ObservableList<FXRspecNode> filterComponentIds(ComponentManagerInfo cmi, ObservableList<FXRspecNode> nodesList) {
//        return nodesList;
//    }
//
//    @Override
//    public ComponentManagerInfo getComponentManagerInfo(GeniUrn componentManagerId) {
//        for (ComponentManagerInfo cmi : componentManagerInfos) {
//            if (TestbedInfoSource.isAuthoritative(cmi.getAuthority(), componentManagerId))
//                return cmi;
//        }
//        LOG.debug("Did not find component_manager for \"" + componentManagerId + "\" in list with " + componentManagerInfos.size() + " CMs");
//        return null;
//    }


}
