package _VisualDVM.ServerObjectsCache;
import _VisualDVM.Global;
import _VisualDVM.TestingSystem.DVM.DVMCompilationOption.DVMCompilationOption;
import _VisualDVM.TestingSystem.DVM.DVMCompilationOptionsSet.DVMCompilationOptionsSet;
import _VisualDVM.TestingSystem.DVM.DVMEnvironment.DVMEnvironment;
import _VisualDVM.TestingSystem.DVM.DVMEnvironmentsSet.DVMEnvironmentsSet;
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;

import java.util.Vector;
public class DVMSettingsCache extends VisualCache {
    public String optionsSummary = null;
    public String environmentsSummary = null;
    //--
    public DVMSettingsCache(DVMSettings dvmSettings) {
        //-->>
        Vector<String> optionsSummary_ = new Vector<>();
        Vector<DVMCompilationOptionsSet> optionsSets = Global.testingServer.db.getVectorByFK(dvmSettings, DVMCompilationOptionsSet.class);
        for (DVMCompilationOptionsSet optionsSet : optionsSets) {
            Vector<String> optionsValues = new Vector<>();
            Vector<DVMCompilationOption> options = Global.testingServer.db.getVectorByFK(optionsSet, DVMCompilationOption.class);
            for (DVMCompilationOption option : options) {
                optionsValues.add(option.print());
            }
            optionsSummary_.add(String.join(" ", optionsValues));
        }
        optionsSummary = String.join(";\n", optionsSummary_);
        //-->>
        Vector<String> environmentsSummary_ = new Vector<>();
        Vector<DVMEnvironmentsSet> environmentsSets = Global.testingServer.db.getVectorByFK(dvmSettings, DVMEnvironmentsSet.class);
        for (DVMEnvironmentsSet environmentsSet : environmentsSets) {
            Vector<String> environmentsValues = new Vector<>();
            Vector<DVMEnvironment> environments = Global.testingServer.db.getVectorByFK(environmentsSet, DVMEnvironment.class);
            for (DVMEnvironment environment : environments) {
                environmentsValues.add(environment.print());
            }
            environmentsSummary_.add(String.join(" ", environmentsValues));
        }
        environmentsSummary = String.join(";\n", environmentsSummary_);
    }
}
