2023-11-19 02:12:44 +03:00
|
|
|
|
package Visual_DVM_2021.Passes.All;
|
2023-11-20 22:10:21 +03:00
|
|
|
|
import Common.Constants;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.Current;
|
2023-11-16 21:03:25 +03:00
|
|
|
|
import Common.Global;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import Common.UI.UI;
|
2023-11-20 18:01:31 +03:00
|
|
|
|
import Common.Utils.Utils;
|
2023-09-17 22:13:42 +03:00
|
|
|
|
import ProjectData.Project.db_project_info;
|
2023-11-19 02:12:44 +03:00
|
|
|
|
import TestingSystem.Common.Test.Test;
|
|
|
|
|
|
import TestingSystem.Common.TestingServer;
|
|
|
|
|
|
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
2023-11-23 01:17:36 +03:00
|
|
|
|
|
|
|
|
|
|
import java.util.Vector;
|
2023-11-16 21:03:25 +03:00
|
|
|
|
public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
2023-11-20 18:01:31 +03:00
|
|
|
|
boolean from_current_project;
|
2023-11-20 22:10:21 +03:00
|
|
|
|
protected int group_id;
|
2023-11-20 18:01:31 +03:00
|
|
|
|
protected db_project_info project = null;
|
2023-11-16 21:03:25 +03:00
|
|
|
|
public PublishTest() {
|
|
|
|
|
|
super(Global.testingServer, Test.class);
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-16 21:03:25 +03:00
|
|
|
|
public boolean fillObjectFields() throws Exception {
|
2023-11-20 22:10:21 +03:00
|
|
|
|
target.description = project.getLocalName();
|
2023-11-23 01:00:08 +03:00
|
|
|
|
if (!project.description.isEmpty()) {
|
2023-11-20 22:10:21 +03:00
|
|
|
|
target.description += " " + project.description;
|
2023-11-23 01:00:08 +03:00
|
|
|
|
target.description = Utils.ReplaceForbiddenSymbols(target.description);
|
|
|
|
|
|
}
|
2023-11-20 22:10:21 +03:00
|
|
|
|
target.group_id = group_id;
|
2023-11-23 01:17:36 +03:00
|
|
|
|
//подпапок нет. имена совпадают с относительными.
|
|
|
|
|
|
Vector<String> filesNames = new Vector<>();
|
|
|
|
|
|
for (String file: project.db.files.Data.keySet())
|
|
|
|
|
|
filesNames.add(file);
|
|
|
|
|
|
target.files = String.join(";", filesNames);
|
2023-11-23 01:00:08 +03:00
|
|
|
|
//--
|
2023-11-20 18:01:31 +03:00
|
|
|
|
if (from_current_project) {
|
2023-11-23 01:50:04 +03:00
|
|
|
|
// target.max_dim = project.testMaxDim;
|
2023-11-17 00:04:21 +03:00
|
|
|
|
return super.fillObjectFields();
|
2023-11-20 18:01:31 +03:00
|
|
|
|
} else {
|
|
|
|
|
|
switch (project.languageName) {
|
|
|
|
|
|
case fortran:
|
2023-11-23 01:50:04 +03:00
|
|
|
|
target.max_dim = Current.getSapfor().getTextMaxDim(null, project);
|
2023-11-20 18:01:31 +03:00
|
|
|
|
break;
|
|
|
|
|
|
case c:
|
2023-11-23 01:50:04 +03:00
|
|
|
|
target.max_dim = Utils.getCProjectMaxDim(project);
|
2023-11-20 18:01:31 +03:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-20 22:10:21 +03:00
|
|
|
|
protected void performPreparation() throws Exception {
|
2023-11-23 01:00:08 +03:00
|
|
|
|
target.packProject(project);
|
2023-11-20 22:10:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-20 18:01:31 +03:00
|
|
|
|
protected boolean canStart(Object... args) throws Exception {
|
2023-11-20 22:10:21 +03:00
|
|
|
|
group_id = Constants.Nan;
|
2023-11-20 18:01:31 +03:00
|
|
|
|
project = null;
|
|
|
|
|
|
if (args.length == 0) {
|
|
|
|
|
|
from_current_project = true;
|
|
|
|
|
|
if (Current.Check(Log, Current.Group, Current.Project) && UI.Question("Добавить текущий проект в глобальную базу тестов")) {
|
|
|
|
|
|
project = Current.getProject();
|
2023-11-20 22:10:21 +03:00
|
|
|
|
group_id = Current.getGroup().id;
|
2023-11-20 18:01:31 +03:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
from_current_project = false;
|
|
|
|
|
|
project = (db_project_info) args[0];
|
2023-11-20 22:10:21 +03:00
|
|
|
|
group_id = (int) args[1];
|
2023-11-17 00:04:21 +03:00
|
|
|
|
}
|
2023-11-20 18:01:31 +03:00
|
|
|
|
//--
|
|
|
|
|
|
if (project == null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
//--
|
|
|
|
|
|
if (!project.checkSubdirectories(Log))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
//-
|
|
|
|
|
|
return super.canStart(args);
|
2023-11-17 00:04:21 +03:00
|
|
|
|
}
|
|
|
|
|
|
@Override
|
2023-11-20 22:29:38 +03:00
|
|
|
|
protected void performFinish() throws Exception {
|
|
|
|
|
|
if (from_current_project)
|
|
|
|
|
|
super.performFinish();
|
|
|
|
|
|
else disconnect();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void showDone() throws Exception {
|
|
|
|
|
|
if (from_current_project)
|
|
|
|
|
|
super.showDone();
|
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
|
}
|