package be.iminds.ilabt.jfed.experimenter_gui.slice.jobs;

import be.iminds.ilabt.jfed.experiment.Experiment;
import be.iminds.ilabt.jfed.experiment.SfaExperimentPart;
import be.iminds.ilabt.jfed.highlevel.controller.TaskThread;
import be.iminds.ilabt.jfed.highlevel.tasks.HighLevelTaskFactory;
import be.iminds.ilabt.jfed.lowlevel.GeniUserProvider;
import be.iminds.ilabt.jfed.preferences.JFedGuiPreferences;
import be.iminds.ilabt.jfed.preferences.ProxyPreferencesManager;
import be.iminds.ilabt.jfed.util.ProxyServiceUtil;

import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import java.util.Collection;

/**
 * User: twalcari
 * Date: 1/11/2016
 * Time: 15:37
 */
@Singleton
public class ExperimenterJobFactory {

    private final Provider<HighLevelTaskFactory> hltfProvider;
    private final Provider<TaskThread> ttProvider;

    private final Provider<GeniUserProvider> geniUserProviderProvider;
    private final Provider<JFedGuiPreferences> jFedPreferencesProvider;
    private final Provider<ProxyPreferencesManager> proxyPreferencesManagerProvider;
    private final Provider<ProxyServiceUtil> proxyServiceUtilProvider;

    @Inject
    public ExperimenterJobFactory(Provider<HighLevelTaskFactory> hltfProvider, Provider<TaskThread> ttProvider,
                                  Provider<GeniUserProvider> geniUserProviderProvider,
                                  Provider<JFedGuiPreferences> jFedPreferencesProvider,
                                  Provider<ProxyPreferencesManager> proxyPreferencesManagerProvider,
                                  Provider<ProxyServiceUtil> proxyServiceUtilProvider) {
        this.hltfProvider = hltfProvider;
        this.ttProvider = ttProvider;
        this.geniUserProviderProvider = geniUserProviderProvider;
        this.jFedPreferencesProvider = jFedPreferencesProvider;
        this.proxyPreferencesManagerProvider = proxyPreferencesManagerProvider;
        this.proxyServiceUtilProvider = proxyServiceUtilProvider;
    }

    public QoeJob createQoeJob(Experiment experiment, Collection<SfaExperimentPart> experimentParts){
        return new QoeJob(experiment, experimentParts, hltfProvider.get(), ttProvider.get());
    }

    public TestConnectivityJob createTestConnectivityJob(Experiment experiment){
        return   new TestConnectivityJob(experiment,
                hltfProvider.get(), ttProvider.get()
                , geniUserProviderProvider.get(), jFedPreferencesProvider.get(),
                proxyPreferencesManagerProvider.get(), proxyServiceUtilProvider.get());
    }
}
