package _VisualDVM.Repository.SubscriberWorkspace;
import _VisualDVM.Current;
import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm;
public class SubscriberWorkspaceDBTable extends iDBTable<SubscriberWorkspace> {
    public SubscriberWorkspaceDBTable() {
        super(SubscriberWorkspace.class);
    }
    public SubscriberWorkspace findWorkspace(String email, String machineURL, String login) {
        return this.Data.values().stream().filter(subscriberWorkspace ->
                subscriberWorkspace.email.equals(email) &&
                        subscriberWorkspace.URL.equals(machineURL) &&
                        subscriberWorkspace.login.equals(login)).findFirst().orElse(null);
    }
    //--
    @Override
    public String getSingleDescription() {
        return "рабочая папка";
    }
    @Override
    public String getPluralDescription() {
        return "рабочие папки";
    }
    @Override
    public Current CurrentName() {
        return Current.SubscriberWorkspace;
    }
    //-
    @Override
    public String[] getUIColumnNames() {
        return new String[]{"URL", "пользователь", "папка"};
    }
    @Override
    protected DataSetControlForm createUI() {
        return new DataSetControlForm(this);
    }
    @Override
    public Object getFieldAt(SubscriberWorkspace object, int columnIndex) {
        switch (columnIndex) {
            case 1:
                return object.URL;
            case 2:
                return object.login;
            case 3:
                return object.path;
        }
        return null;
    }
}
