подсветка версий с ошибками в журнале

This commit is contained in:
2024-04-07 21:30:11 +03:00
parent 002867274f
commit 8b9400fb95
9 changed files with 125 additions and 66 deletions

View File

@@ -1,7 +1,14 @@
package TestingSystem.Common;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Global;
import Common.Utils.Utils;
import GlobalData.Account.Account;
import Repository.Component.Sapfor.Sapfor;
import Repository.RepositoryRefuseException;
import TestingSystem.Common.Group.Group;
import TestingSystem.Common.Group.GroupsDBTable;
import TestingSystem.Common.Test.Test;
import TestingSystem.Common.Test.TestDBTable;
import TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
import TestingSystem.DVM.Configuration.ConfigurationDBTable;
@@ -12,9 +19,14 @@ import TestingSystem.SAPFOR.SapforConfiguration.SapforConfigurationDBTable;
import TestingSystem.SAPFOR.SapforConfigurationCommand.SapforConfigurationCommandsDBTable;
import TestingSystem.SAPFOR.SapforPackage.SapforPackage;
import TestingSystem.SAPFOR.SapforPackage.SapforPackageDBTable;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapfor;
import TestingSystem.SAPFOR.ServerSapfor.ServerSapforsDBTable;
import Visual_DVM_2021.Passes.All.ZipFolderPass;
import Visual_DVM_2021.Passes.PassCode_2021;
import javafx.util.Pair;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.LinkedHashMap;
@@ -144,4 +156,78 @@ public class TestsDatabase extends SQLiteDatabase {
}
return res;
}
//--
public void SaveTestFromSingleFile(ServerSapfor sapfor, Group group, Test test, File file) throws Exception {
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile);
//----
//архивация.
File archive = test.getArchive();
if (archive.exists())
FileUtils.forceDelete(archive);
//----------->>
ZipFolderPass zip = new ZipFolderPass();
zip.Do(testDirectory.getAbsolutePath(), archive.getAbsolutePath());
//---
//Определение размерности
switch (group.language) {
case fortran:
// временная папка для анализа. чтобы не засорять нормальную.
File tempProject = Utils.getTempFileName("test");
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(testDirectory, tempProject);
//--
if (Sapfor.getMinMaxDim(Sapfor.getTempCopy(new File(sapfor.call_command)), tempProject, test)) {
Update(test);
} else
throw new RepositoryRefuseException("Не удалось определить размерность теста " + Utils.Brackets(test.description));
break;
case c:
test.max_dim = Utils.getCTestMaxDim(testFile);
Update(test);
break;
}
}
//---
public void CreateTestFromSingleFile(Account account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
System.out.println("Создание теста " + file.getName());
Test test = new Test();
test.description = testDescription;
test.sender_name = account.name;
test.sender_address = account.email;
test.group_id = group.id;
test.files = file.getName();
Insert(test);
//->>
SaveTestFromSingleFile(sapfor, group, test, file);
}
public void RefreshGroup(Account account, ServerSapfor sapfor, Pair<Group, Vector<File>> groupData) throws Exception {
Group group = groupData.getKey();
Vector<File> files = groupData.getValue();
//--
Group oldGroup = groups.getGroupByDescription(group.language,group.description);
if (oldGroup == null) {
System.out.println("group "+Utils.Brackets(group.description)+" not found. create.");
Insert(group);
for (File file : files) {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
System.out.println("test "+Utils.Brackets(testDescription) + " create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, group, file, testDescription);
}
} else {
for (File file : files) {
String testDescription = Utils.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
Test oldTest = tests.getTestByDescription(oldGroup.id, testDescription);
if (oldTest == null) {
System.out.println("test "+Utils.Brackets(testDescription) + " not found. create"); //добавить тест.
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
} else {
System.out.println(Utils.Brackets(testDescription) + " found. rewrite"); //добавить тест.
SaveTestFromSingleFile(sapfor, group, oldTest, file);
}
}
}
}
}