2023-09-17 22:13:42 +03:00
|
|
|
package Visual_DVM_2021.Passes.All;
|
2023-10-06 22:51:09 +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;
|
|
|
|
|
import Common.Utils.Utils;
|
|
|
|
|
import ProjectData.Project.db_project_info;
|
|
|
|
|
import TestingSystem.Test.Test;
|
2023-11-16 21:03:25 +03:00
|
|
|
import TestingSystem.TestingServer;
|
2023-09-17 22:13:42 +03:00
|
|
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
2023-11-16 21:03:25 +03:00
|
|
|
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
2023-09-17 22:13:42 +03:00
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.nio.file.Paths;
|
2023-11-16 21:03:25 +03:00
|
|
|
public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
|
|
|
|
public PublishTest() {
|
|
|
|
|
super(Global.testingServer, Test.class);
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
protected db_project_info project = null;
|
|
|
|
|
protected boolean setProject() {
|
2023-11-16 21:03:25 +03:00
|
|
|
if (Current.Check(Log, Current.Group, Current.Project)
|
2023-09-17 22:13:42 +03:00
|
|
|
&& UI.Question("Добавить текущий проект в глобальную базу тестов")) {
|
|
|
|
|
project = Current.getProject();
|
2023-11-16 21:03:25 +03:00
|
|
|
if (project.checkSubdirectories(Log)) {
|
|
|
|
|
switch (project.languageName) {
|
|
|
|
|
case fortran:
|
|
|
|
|
return passes.get(PassCode_2021.SPF_GetMaxMinBlockDistribution).Do();
|
|
|
|
|
case c:
|
|
|
|
|
project.testMaxDim = Utils.getCProjectMaxDim(project);
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
2023-11-16 21:03:25 +03:00
|
|
|
public boolean fillObjectFields() throws Exception {
|
|
|
|
|
if (setProject()) {
|
2023-09-17 22:13:42 +03:00
|
|
|
target.description = project.getLocalName() + " " + project.description;
|
|
|
|
|
target.dim = project.testMaxDim;
|
|
|
|
|
target.group_id = Current.getGroup().id;
|
2023-11-16 21:03:25 +03:00
|
|
|
if (super.fillObjectFields()) {
|
|
|
|
|
File src = Utils.getTempFileName("test");
|
|
|
|
|
Utils.CheckAndCleanDirectory(src);
|
2023-09-17 22:13:42 +03:00
|
|
|
project.Clone(src, false);
|
2023-11-16 21:03:25 +03:00
|
|
|
FileUtils.copyFile(project.db.getFile(),
|
|
|
|
|
Paths.get(src.getAbsolutePath(),Constants.data, project.db.getFile().getName()).toFile());
|
2023-09-17 22:13:42 +03:00
|
|
|
//архивация.
|
|
|
|
|
File archive = Utils.getTempFileName("test_archive");
|
|
|
|
|
if (passes.get(PassCode_2021.ZipFolderPass).Do(src.getAbsolutePath(), archive.getAbsolutePath())) {
|
|
|
|
|
target.project_archive_bytes = Utils.packFile(archive);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-11-16 21:03:25 +03:00
|
|
|
//--
|
2023-09-17 22:13:42 +03:00
|
|
|
}
|