package _VisualDVM.GlobalData.User;
import Common.CommonConstants;
import Common.Database.Objects.iDBObject;
import _VisualDVM.GlobalData.Machine.Machine;
import _VisualDVM.TestingSystem.DVM.UserConnection;
import com.sun.org.glassfish.gmbal.Description;

import java.io.File;
import java.nio.file.Paths;
public class User extends iDBObject {
    public String login;
    public String password = "";
    public int machine_id = CommonConstants.Nan;
    public UserAuthentication authentication = UserAuthentication.password;
    public String workspace = ""; //рабочая папка визуализатора пользователя на машине. полный путь.
    public UserState state = UserState.initial;
    //-
    @Description("IGNORE")
    public UserConnection connection = null;
    //--
    public User(Machine machine_in, String login_in, String password_in) {
        machine_id = machine_in.id;
        login = login_in;
        password = password_in;
    }
    public User(String login_in, String password_in) {
        login = login_in;
        password = password_in;
    }
    public User(String login_in, String password_in, String workspace_in) {
        login = login_in;
        password = password_in;
        workspace = workspace_in;
    }
    public User() {
    }
    @Override
    public String getDialogName() {
        return login;
    }
    public String getRemoteProjectsPath() {
        return workspace + "/projects";
    }
    //-ЛОКАЛЬНЫЙ СЛУЧАЙ-----------------------------------------------------------------------
    public File getLocalWorkspace() {
        return new File(workspace);
    }
    public File getLocalProjectsDir() {
        return Paths.get(workspace, "projects").toFile();
    }
    public File getLocalModulesDir() {
        return Paths.get(workspace, "modules").toFile();
    }
    public File getHeaderCodeFile() {
        return Paths.get(workspace, "modules", "Process_r.h").toFile();
    }
    public File getStarterCodeFile() {
        return Paths.get(workspace, "modules", "starter.cpp").toFile();
    }
    public File getStarterFile() {
        return Paths.get(workspace, "modules", "starter").toFile();
    }
    public File getLauncherCodeFile() {
        return Paths.get(workspace, "modules", "launcher.cpp").toFile();
    }
    public File getLauncherFile() {
        return Paths.get(workspace, "modules", "launcher").toFile();
    }
    //-
}
