fix. было криво реализовано удаление пакетов. переделал на удаление по ключу ( до этого на сервер отправлялся объект целиком)

This commit is contained in:
2023-11-15 01:16:16 +03:00
parent 72b098b156
commit cf65448a13
7 changed files with 31 additions and 78 deletions

View File

@@ -15,7 +15,6 @@ import Repository.RepositoryRefuseException;
import Repository.RepositoryServer;
import Repository.Server.ServerCode;
import Repository.Server.ServerExchangeUnit_2021;
import SapforTestingSystem.Json.SapforTasksResults_json;
import SapforTestingSystem.SapforTask.SapforTask;
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
import SapforTestingSystem.ServerSapfor.ServerSapfor;
@@ -310,11 +309,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
groups.sort(Comparator.comparing(o -> o.description));
return groups;
}
public SapforTasksResults_json getSapforPackageResults(SapforTasksPackage sapforTasksPackage) throws Exception {
File results_file = new File(sapforTasksPackage.workspace, Constants.results_json);
return (SapforTasksResults_json) Utils.jsonFromFile(
results_file, SapforTasksResults_json.class);
}
@Override
protected void Session() throws Exception {
DBObject dbObject = null;
@@ -406,21 +400,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = dbObject;
break;
case DeleteAccountObjects:
Print("Удалить список объектов с базы пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
Vector<Object> objects = (Vector<Object>) request.object;
account_db.BeginTransaction();
for (Object object : objects) {
dbObject = (DBObject) object;
if (canDelete(dbObject)) {
account_db.DeleteWithCheck(dbObject);
DeleteAction(dbObject);
}
}
account_db.Commit();
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
case PublishAccountObjects:
Print("Опубликовать объекты для пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
@@ -523,6 +502,13 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
response = new ServerExchangeUnit_2021(ServerCode.OK);
response.object = Utils.packFile(account_db.getFile());
break;
case DeleteAccountObjectByPK:
Print("Удалить объект из базы пользователя " + request.arg);
SetCurrentAccountDB(request.arg);
Pair<Class, Object> to_delete = (Pair<Class, Object>) request.object;
DeleteAction(account_db.DeleteByPK(to_delete.getKey(), to_delete.getValue()));
response = new ServerExchangeUnit_2021(ServerCode.OK);
break;
default:
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
}