package _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable;
import Common.Utils.Vector_;
import Common.Visual.DataSetControlForm;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.UI.SapforConfigurationsForm;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfigurationGroup.SapforConfigurationGroup;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfigurationSettings.SapforConfigurationSettings;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfigurationTest.SapforConfigurationTest;
import _VisualDVM.TestingSystem.SAPFOR.SapforPackageConfiguration.SapforPackageConfiguration;

import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.Vector;
public class SapforConfigurationDBTable extends iDBTable<SapforConfiguration> {
    public SapforConfigurationDBTable() {
        super(SapforConfiguration.class);
    }
    @Override
    public String getSingleDescription() {
        return "конфигурация";
    }
    @Override
    public String getPluralDescription() {
        return "конфигурации";
    }
    @Override
    public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
        LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
        res.put(SapforConfigurationGroup.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
        res.put(SapforConfigurationTest.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
        res.put(SapforConfigurationSettings.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.PASSIVE));
        res.put(SapforPackageConfiguration.class, new FKBehaviour(FKDataBehaviour.NONE, FKCurrentObjectBehaviuor.PASSIVE));
        return res;
    }
    @Override
    protected DataSetControlForm createUI(JPanel mountPanel) {
        return new SapforConfigurationsForm(this, mountPanel);
    }
    public Vector<SapforConfiguration> getAutoConfigurations() {
        Vector<SapforConfiguration> res = new Vector_<>();
        for (SapforConfiguration configuration : Data.values()) {
            if (configuration.autoTesting != 0)
                res.add(configuration);
        }
        return res;
    }
}
