package _VisualDVM.TestingSystem.Common.MachineProcess;
import Common.Database.Tables.DataSet;
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;

import java.util.LinkedHashMap;
public class MachineProcessSet extends DataSet<String, MachineProcess> {
    public MachineProcessSet() {
        super(String.class, MachineProcess.class);
    }
    public LinkedHashMap<String, MachineProcess> getSortedByKeys() {
        LinkedHashMap<String, MachineProcess> res = new LinkedHashMap<>();
        for (MachineProcess process : Data.values())
            res.put(process.getUniqueKey(), process);
        return res;
    }
    public boolean hasProcessForPackage(DVMPackage package_in) {
        for (MachineProcess process : Data.values()) {
            if (
                    process.machineAddress.equals(package_in.machine_address) &&
                            process.machinePort == package_in.machine_port &&
                            process.userName.equals(package_in.user_name) &&
                            process.userWorkspace.equals(package_in.user_workspace)
            ) {
                return true;
            }
        }
        return false;
    }
}
