package _VisualDVM.GlobalData.RunConfiguration;
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.Visual.DataSetControlForm;
import _VisualDVM.GlobalData.DVMParameter.DVMParameter;
import _VisualDVM.GlobalData.EnvironmentValue.EnvironmentValue;
import _VisualDVM.GlobalData.RunConfiguration.UI.RunConfigurationsForm;
import _VisualDVM.GlobalData.Tasks.RunTask.RunTask;

import javax.swing.*;
import java.util.LinkedHashMap;
public class RunConfigurationsDBTable extends iDBTable<RunConfiguration> {
    public RunConfigurationsDBTable() {
        super(RunConfiguration.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(RunTask.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
        res.put(EnvironmentValue.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
        res.put(DVMParameter.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
        return res;
    }
    @Override
    protected DataSetControlForm createUI(JPanel mountPanel) {
        return new RunConfigurationsForm(this, mountPanel);
    }
    public void Patch() throws Exception {
        for (RunConfiguration c : Data.values()) {
            c.Patch();
            getDb().Update(c);
        }
    }
}
