рефакторинг взаимодействия с бд сервера. был индийский код при альтернативной базе на сервере компонент

This commit is contained in:
2025-03-21 01:21:54 +03:00
parent 78ee5bc428
commit 637e9c5c0f
17 changed files with 93 additions and 139 deletions

View File

@@ -101,6 +101,17 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
zip.Do("Tests", new File(todayBackUp, "Tests.zip").getAbsolutePath());
}
@Override
protected void beforePublishAction(DBObject object) throws Exception {
if (object instanceof ServerSapfor) {
int current_version = getSapforActualVersion();
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
public void afterPublishAction(DBObject object) throws Exception {
if (object instanceof Test) {
Test test = (Test) object;
@@ -181,7 +192,6 @@ 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)) {
@@ -193,7 +203,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
db.Update(sapforConfiguration);
}
}
//--
//-
} else if (object instanceof Group) {
Group group = (Group) object;
LinkedHashMap<Integer, Test> groupTests = db.getMapByFKi(group, Test.class);
@@ -212,17 +222,12 @@ 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);
db.DeleteDependencies(group_test);
}
//--
} else if (object instanceof ServerSapfor) {
Utils_.forceDeleteWithCheck(
new File(
((ServerSapfor) object).home_path
)
);
Utils_.forceDeleteWithCheck(new File(((ServerSapfor) object).home_path));
} else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object;
File workspace = dvmPackage.getLocalWorkspace();
@@ -260,14 +265,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
//--
Vector<SapforSettingsCommand> commands = new Vector<>();
for (SapforSettingsCommand command : db.sapforSettingsCommands.Data.values()) {
if (command.sapforsettings_id == sapforSettings.id)
commands.add(command);
}
for (SapforSettingsCommand command : commands) {
db.Delete(command);
}
}
//-
}
@@ -277,17 +274,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
//-->>>
@Override
protected void beforePublishAction(DBObject object) throws Exception {
if (object instanceof ServerSapfor) {
int current_version = getSapforActualVersion();
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
public int getPort() {
return Constants.TestingServerPort;
}