++
рефакторинг бд файлов тестов.
This commit is contained in:
@@ -28,6 +28,7 @@ import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.Test.TestType;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
@@ -86,6 +87,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
@Override
|
||||
public void StartAction() throws Exception {
|
||||
try {
|
||||
//--
|
||||
// db.Patch();
|
||||
//--
|
||||
machines_db = new MachinesDatabase();
|
||||
machines_db.Activate();
|
||||
} catch (Exception ex) {
|
||||
@@ -107,6 +111,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
}
|
||||
db.saveTestFiles(test);
|
||||
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
|
||||
} else if (object instanceof DVMPackage) {
|
||||
DVMPackage dvmPackage = (DVMPackage) object;
|
||||
@@ -176,6 +181,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
if (object instanceof Test) {
|
||||
Test test = (Test) object;
|
||||
Utils_.forceDeleteWithCheck(test.getServerPath());
|
||||
db.DeleteTestFiles(test);
|
||||
//--
|
||||
for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) {
|
||||
if (dvmConfiguration.tryDeleteTest(test)) {
|
||||
@@ -208,6 +214,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
for (Test group_test : groupTests.values()) {
|
||||
db.Delete(group_test);
|
||||
Utils_.forceDeleteWithCheck(group_test.getServerPath());
|
||||
db.DeleteTestFiles(group_test);
|
||||
}
|
||||
//--
|
||||
} else if (object instanceof ServerSapfor) {
|
||||
@@ -276,6 +283,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
int max_installed_version = db.getInstalledSapforMaxVersion();
|
||||
if (max_installed_version == current_version)
|
||||
throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена");
|
||||
ServerSapfor serverSapfor = (ServerSapfor) object;
|
||||
serverSapfor.version = String.valueOf(current_version);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@@ -301,7 +310,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
|
||||
TextLog Log = new TextLog();
|
||||
SapforPackage autoPackage = tryAutoSapforTesting(sapfor,Log);
|
||||
SapforPackage autoPackage = tryAutoSapforTesting(sapfor, Log);
|
||||
EmailMessage message = Log.isEmpty() ?
|
||||
new EmailMessage(
|
||||
"Запущено автоматическое тестирование версии " + sapfor.version + " системы SAPFOR",
|
||||
@@ -478,34 +487,30 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
else
|
||||
throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id);
|
||||
}
|
||||
void ReplaceTestCode() throws Exception {
|
||||
Test test = (Test) request.object;
|
||||
void replaceTestCode(Test test, ServerSapfor serverSapfor) throws Exception {
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
db.DeleteTestFiles(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else {
|
||||
db.Update(test);
|
||||
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
|
||||
//--
|
||||
db.DeleteTestFiles(test);
|
||||
db.saveTestFiles(test);
|
||||
//--
|
||||
db.DetectTestMinMaxDim(serverSapfor, db.groups.get(test.group_id), test);
|
||||
}
|
||||
}
|
||||
void ReplaceTestCode() throws Exception {
|
||||
replaceTestCode((Test) request.object, db.serverSapfors.getLastDoneVersion());
|
||||
}
|
||||
void ReplaceTestsCodes() throws Exception {
|
||||
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
|
||||
Vector<Test> tests = (Vector<Test>) request.object;
|
||||
for (Test test : tests) {
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else {
|
||||
db.Update(test);
|
||||
db.DetectTestMinMaxDim(serverSapfor, db.groups.get(test.group_id), test);
|
||||
}
|
||||
}
|
||||
for (Test test : (Vector<Test>) request.object)
|
||||
replaceTestCode(test, serverSapfor);
|
||||
}
|
||||
void GetServerName() throws Exception {
|
||||
response.object = name;
|
||||
@@ -592,7 +597,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
void GetSapforForCompilation() throws Exception {
|
||||
//1. Проверить наличие заказов от пользователя
|
||||
ServerSapfor serverSapfor = db.getSapforCopyForCompilation();
|
||||
|
||||
if (serverSapfor == null) {
|
||||
//2 если нет. проверить есть ли свежие версии.
|
||||
int max_version = db.getInstalledSapforMaxVersion();
|
||||
@@ -716,12 +720,19 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
Test test = new Test();
|
||||
test.group_id = group.id;
|
||||
test.description = name;
|
||||
test.packedFilesJson = Utils_.gson.toJson(filesJson);
|
||||
test.sender_address = group.sender_address;
|
||||
test.sender_name = group.sender_name;
|
||||
test.extended_description = descriptions.get(name);
|
||||
db.Insert(test);
|
||||
//---
|
||||
Vector<TestFile> testFiles = new Vector<>();
|
||||
for (File file : files)
|
||||
testFiles.add(new TestFile(test, file));
|
||||
db.BeginTransaction();
|
||||
for (TestFile testFile : testFiles)
|
||||
db.Insert(testFile);
|
||||
db.Commit();
|
||||
//---
|
||||
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id));
|
||||
//---
|
||||
if (testProject.exists())
|
||||
|
||||
Reference in New Issue
Block a user