переделал скачивание стандартных тестов. В дальнейшем будет полностью на сервере.

This commit is contained in:
2023-11-19 00:25:37 +03:00
parent dae90b6c5e
commit f005b5dbc9
4 changed files with 145 additions and 137 deletions

View File

@@ -3,19 +3,17 @@ import Common.Current;
import Common.Global;
import Common.UI.UI;
import Common.Utils.Utils;
import ProjectData.Files.DBProjectFile;
import ProjectData.Project.db_project_info;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Test.Test;
import Visual_DVM_2021.Passes.PassCode_2021;
import Visual_DVM_2021.Passes.PassException;
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Vector;
public class ConvertCorrectnessTests extends TestingSystemPass<File> {
@Override
@@ -49,67 +47,36 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
}
@Override
protected void ServerAction() throws Exception {
Command(new ServerExchangeUnit_2021(ServerCode.RefreshDVMTests));
Vector<Group> groups = (Vector<Group>) response.object;
System.out.println("найдено " + groups.size() + " групп");
Test test = null;
Vector<Test> tests = null;
for (Group group : groups) {
ShowMessage1("Создание группы " + group.description);
tests = new Vector<>();
// group.genName();
group.sender_name = Current.getAccount().name;
group.sender_address = Current.getAccount().email;
//->>
//->>
for (String testFileName : group.testsFiles.keySet()) {
ShowMessage2("Создание теста " + testFileName);
test = new Test();
// test.genName();
test.description = Utils.getNameWithoutExtension(testFileName) + "_" + group.language.getDVMCompile();
test.sender_name = Current.getAccount().name;
test.sender_address = Current.getAccount().email;
test.group_id = group.id;
//->>
File testProject = Paths.get(Global.TempDirectory.getAbsolutePath(), String.valueOf(test.id)).toFile();
Command(new ServerExchangeUnit_2021(ServerCode.RefreshDVMTests, "", Current.getAccount()));
LinkedHashMap<Group, Vector<Test>> ids = (LinkedHashMap<Group, Vector<Test>>) response.object;
ShowMessage1("Определение размерности тестов");
for (Group group : ids.keySet()) {
Vector<Test> tests = ids.get(group);
for (Test test : tests) {
ShowMessage2(group.description+" : "+test.description);
Command(new ServerExchangeUnit_2021(ServerCode.DownloadTest, String.valueOf(test.id)));
File testArchive = Utils.getTempFileName(String.valueOf(test));
response.Unpack(testArchive);
File testProject = new File(Global.TempDirectory, String.valueOf(test.id));
Utils.forceDeleteWithCheck(testProject);
FileUtils.forceMkdir(testProject);
File testFile = Paths.get(testProject.getAbsolutePath(), testFileName).toFile();
Utils.unpackFile(group.testsFiles.get(testFileName), testFile);
//----
DBProjectFile testDBProjectFile = new DBProjectFile();
testDBProjectFile.name = testFile.getName();
testDBProjectFile.file = testFile;
testDBProjectFile.AutoDetectProperties();
//---
passes.get(PassCode_2021.UnzipFolderPass).Do(testArchive.getAbsolutePath(), Global.TempDirectory.getAbsolutePath());
//без создания бд!!
db_project_info vizTestProject = new db_project_info(testProject, "", false);
switch (group.language) {
case fortran:
test.dim = Current.getSapfor().getTextMaxDim(testFile, vizTestProject);
break;
case c:
test.dim = Utils.getCTestMaxDim(testFile);
break;
}
//-
//архивация.
File archive = Utils.getTempFileName("test_archive");
if (passes.get(PassCode_2021.ZipFolderPass).Do(vizTestProject.Home.getAbsolutePath(), archive.getAbsolutePath())) {
// test.project_archive_bytes = Utils.packFile(archive);
if (test.dim >= 0)
tests.add(test);
else UI.Info("для теста " + testFileName + " не удалось определить размерность");
} else throw new PassException("Не удалось заархивировать тест");
}
//->>
if (!tests.isEmpty()) {
ShowMessage1("Публикация группы " + group.description);
Command(new ServerExchangeUnit_2021(ServerCode.PublishObject, "", group));
for (Test test1 : tests) {
ShowMessage2("Публикация теста " + test1.description);
Command(new ServerExchangeUnit_2021(ServerCode.PublishObject, "", test1));
File[] files = testProject.listFiles();
if (files != null && files.length > 0) {
db_project_info vizTestProject = new db_project_info(testProject, "", false);
switch (group.language) {
case fortran:
test.dim = Current.getSapfor().getTextMaxDim(files[0], vizTestProject);
System.out.println(test.dim);
break;
case c:
test.dim = Utils.getCTestMaxDim(files[0]);
System.out.println(test.dim);
break;
}
}
EditObject(test);
}
}
}
@@ -119,3 +86,4 @@ public class ConvertCorrectnessTests extends TestingSystemPass<File> {
passes.get(PassCode_2021.SynchronizeTests).Do();
}
}