fix. было криво реализовано удаление пакетов. переделал на удаление по ключу ( до этого на сервер отправлялся объект целиком)
This commit is contained in:
@@ -118,6 +118,17 @@ public abstract class Database {
|
||||
} else
|
||||
throw new RepositoryRefuseException("Таблица " + Utils.Brackets(table.Name) + " не содержит объект с ключом " + Utils.Brackets(to_delete.getPK().toString()));
|
||||
}
|
||||
public DBObject DeleteByPK(Class object_class, Object key) throws Exception {
|
||||
DBTable table = tables.get(object_class);
|
||||
if (table.Data.containsKey(key)) {
|
||||
DBObject o = (DBObject) table.Data.get(key);
|
||||
delete(table, o);
|
||||
table.Data.remove(key);
|
||||
return o;
|
||||
} else
|
||||
throw new RepositoryRefuseException("Таблица " + Utils.Brackets(table.Name) + " не содержит объект с ключом " + Utils.Brackets(key.toString()));
|
||||
}
|
||||
|
||||
// не работает с автоинкрементом.
|
||||
public DBObject getObjectCopyByPK(Class table_class, Object pk) throws Exception {
|
||||
DBTable table = tables.get(table_class);
|
||||
|
||||
@@ -39,7 +39,6 @@ public enum ServerCode {
|
||||
//--
|
||||
PublishAccountObjects,
|
||||
EditAccountObject,
|
||||
DeleteAccountObjects,
|
||||
//--
|
||||
EXIT,
|
||||
//--
|
||||
@@ -74,5 +73,8 @@ public enum ServerCode {
|
||||
DownloadSapforTasksPackage,
|
||||
Patch,
|
||||
EmailSapforAssembly,
|
||||
//-
|
||||
DeleteAccountObjectByPK,
|
||||
//-
|
||||
OLD
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,10 @@ package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||
import TestingSystem.TasksPackage.TasksPackageState;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||
|
||||
import java.util.Vector;
|
||||
public class DeleteSapforTasksPackage extends TestingSystemPass<SapforTasksPackage> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
@@ -36,10 +32,7 @@ public class DeleteSapforTasksPackage extends TestingSystemPass<SapforTasksPacka
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
target.results = null;
|
||||
Vector<SapforTasksPackage> vector = new Vector<>();
|
||||
vector.add(target);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DeleteAccountObjects, Current.getAccount().email, vector));
|
||||
DeleteAccountObject(target);
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Tasks.TestRunTask;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||
|
||||
import java.util.Vector;
|
||||
public class DeleteSelectedTestsRunTasks extends TestingSystemPass<Vector<TestRunTask>> {
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Delete.png";
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = new Vector<>();
|
||||
//------------------------
|
||||
if (Current.getAccount().CheckRegistered(Log)) {
|
||||
for (TestRunTask task : Global.testingServer.account_db.testRunTasks.getCheckedItems()) {
|
||||
if (!task.state.isActive())
|
||||
target.add(task);
|
||||
}
|
||||
if (target.isEmpty()) {
|
||||
Log.Writeln_("не отмечено неактивных задач.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DeleteAccountObjects, Current.getAccount().email, target));
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
passes.get(PassCode_2021.SynchronizeTestsTasks).Do();
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,6 @@ public enum PassCode_2021 {
|
||||
//-
|
||||
PickCompilerEnvironmentsForTesting,
|
||||
AddDVMParameterForTesting,
|
||||
DeleteSelectedTestsRunTasks,
|
||||
//-
|
||||
RefreshDVMTests,
|
||||
PauseTesting,
|
||||
@@ -470,8 +469,6 @@ public enum PassCode_2021 {
|
||||
return "Возобновить тестирование";
|
||||
case RefreshDVMTests:
|
||||
return "Обновить DVM тесты";
|
||||
case DeleteSelectedTestsRunTasks:
|
||||
return "Удалить отмеченные тестовые задачи";
|
||||
case AddDVMParameterForTesting:
|
||||
return "Добавить параметр DVM системы для группы";
|
||||
case PickCompilerEnvironmentsForTesting:
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package Visual_DVM_2021.Passes;
|
||||
import Common.Current;
|
||||
import Common.Database.DBObject;
|
||||
import Common.Global;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.TestingServer;
|
||||
import javafx.util.Pair;
|
||||
public abstract class TestingSystemPass<T> extends RepositoryPass<TestingServer, T> {
|
||||
public TestingSystemPass() {
|
||||
super(Global.testingServer);
|
||||
@@ -9,4 +14,8 @@ public abstract class TestingSystemPass<T> extends RepositoryPass<TestingServer,
|
||||
protected int getTimeout() {
|
||||
return 120000;
|
||||
}
|
||||
public void DeleteAccountObject(DBObject object) throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DeleteAccountObjectByPK, Current.getAccount().email,
|
||||
new Pair<>(object.getClass(), object.getPK())));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user