108 lines
3.6 KiB
Java
108 lines
3.6 KiB
Java
package TestingSystem.DVM.DVMPackage;
|
|
import Common.Constants;
|
|
import Common.Current;
|
|
import Common.Database.DBObject;
|
|
import Common.Global;
|
|
import GlobalData.Account.Account;
|
|
import GlobalData.Compiler.Compiler;
|
|
import GlobalData.Machine.Machine;
|
|
import GlobalData.Machine.MachineType;
|
|
import GlobalData.User.User;
|
|
import TestingSystem.Common.TasksPackageState;
|
|
import TestingSystem.Common.TestingPackage.TestingPackage;
|
|
import TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
|
import TestingSystem.DVM.DVMTasks.DVMRunTask;
|
|
|
|
import java.io.File;
|
|
import java.util.Vector;
|
|
public class DVMPackage extends TestingPackage<DVMPackage_json> {
|
|
//---
|
|
public String machine_name = "";
|
|
public String machine_address = "";
|
|
public int machine_port = 22;
|
|
//---
|
|
public String user_name = "";
|
|
public String user_password;
|
|
public String user_workspace;
|
|
//---
|
|
public DVMPackage() {
|
|
}
|
|
public DVMPackage(Account account, Machine machine, User user, Compiler compiler, int kernels_in){
|
|
id = Constants.Nan;
|
|
//-
|
|
sender_name = account.name;
|
|
sender_address = account.email;
|
|
//-
|
|
machine_name = machine.name;
|
|
machine_address = machine.address;
|
|
machine_port = machine.port;
|
|
//-
|
|
user_name = user.login;
|
|
user_password = user.password;
|
|
user_workspace = user.workspace;
|
|
//-
|
|
drv = compiler.call_command;
|
|
version = compiler.getVersionInfo();
|
|
//-
|
|
kernels = kernels_in; //Global.properties.TestingKernels;
|
|
needsEmail = Global.properties.EmailOnTestingProgress ? 1 : 0;
|
|
//--
|
|
package_json = new DVMPackage_json();
|
|
//--
|
|
state = TasksPackageState.Queued;
|
|
}
|
|
@Override
|
|
public Class getJsonClass() {
|
|
return DVMPackage_json.class;
|
|
}
|
|
@Override
|
|
public File getHomeDirectory() {
|
|
return Global.DVMPackagesDirectory;
|
|
}
|
|
public DVMPackage(DVMPackage p) {
|
|
super(p);
|
|
this.SynchronizeFields(p);
|
|
}
|
|
//---
|
|
@Override
|
|
public void SynchronizeFields(DBObject src) {
|
|
super.SynchronizeFields(src);
|
|
DVMPackage tasksPackage = (DVMPackage) src;
|
|
machine_name = tasksPackage.machine_name;
|
|
machine_address = tasksPackage.machine_address;
|
|
machine_port = tasksPackage.machine_port;
|
|
user_name = tasksPackage.user_name;
|
|
user_workspace = tasksPackage.user_workspace;
|
|
user_password = tasksPackage.user_password;
|
|
}
|
|
public Machine getMachine() {
|
|
return new Machine(machine_name, machine_address, machine_port, MachineType.Server);
|
|
}
|
|
public User getUser() {
|
|
return new User(user_name, user_password, user_workspace);
|
|
}
|
|
@Override
|
|
public boolean isVisible() {
|
|
return (!DVMPackageDBTable.filterMyOnly || Current.getAccount().email.equals(sender_address))&&
|
|
(!DVMPackageDBTable.filterActive || state.isActive() );
|
|
}
|
|
public void saveTasks(Vector<DVMCompilationTask> tasks, int allTasksCount){
|
|
tasksCount=allTasksCount;
|
|
//--
|
|
package_json=new DVMPackage_json();
|
|
DVMPackage_json json = package_json;
|
|
//инициализируем идентификаторы задач.
|
|
for (DVMCompilationTask compilationTask : tasks) {
|
|
//--
|
|
compilationTask.id = json.getMaxTaskId();
|
|
//-
|
|
for (DVMRunTask runTask : compilationTask.runTasks) {
|
|
runTask.id = json.getMaxTaskId();
|
|
runTask.dvmcompilationtask_id = compilationTask.id;
|
|
}
|
|
}
|
|
json.compilationTasks.addAll(tasks);
|
|
}
|
|
}
|
|
|