fix. было криво реализовано удаление пакетов. переделал на удаление по ключу ( до этого на сервер отправлялся объект целиком)
This commit is contained in:
@@ -118,6 +118,17 @@ public abstract class Database {
|
|||||||
} else
|
} else
|
||||||
throw new RepositoryRefuseException("Таблица " + Utils.Brackets(table.Name) + " не содержит объект с ключом " + Utils.Brackets(to_delete.getPK().toString()));
|
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 {
|
public DBObject getObjectCopyByPK(Class table_class, Object pk) throws Exception {
|
||||||
DBTable table = tables.get(table_class);
|
DBTable table = tables.get(table_class);
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ public enum ServerCode {
|
|||||||
//--
|
//--
|
||||||
PublishAccountObjects,
|
PublishAccountObjects,
|
||||||
EditAccountObject,
|
EditAccountObject,
|
||||||
DeleteAccountObjects,
|
|
||||||
//--
|
//--
|
||||||
EXIT,
|
EXIT,
|
||||||
//--
|
//--
|
||||||
@@ -74,5 +73,8 @@ public enum ServerCode {
|
|||||||
DownloadSapforTasksPackage,
|
DownloadSapforTasksPackage,
|
||||||
Patch,
|
Patch,
|
||||||
EmailSapforAssembly,
|
EmailSapforAssembly,
|
||||||
|
//-
|
||||||
|
DeleteAccountObjectByPK,
|
||||||
|
//-
|
||||||
OLD
|
OLD
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import Repository.RepositoryRefuseException;
|
|||||||
import Repository.RepositoryServer;
|
import Repository.RepositoryServer;
|
||||||
import Repository.Server.ServerCode;
|
import Repository.Server.ServerCode;
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
import SapforTestingSystem.Json.SapforTasksResults_json;
|
|
||||||
import SapforTestingSystem.SapforTask.SapforTask;
|
import SapforTestingSystem.SapforTask.SapforTask;
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
import SapforTestingSystem.ServerSapfor.ServerSapfor;
|
||||||
@@ -310,11 +309,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
groups.sort(Comparator.comparing(o -> o.description));
|
groups.sort(Comparator.comparing(o -> o.description));
|
||||||
return groups;
|
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
|
@Override
|
||||||
protected void Session() throws Exception {
|
protected void Session() throws Exception {
|
||||||
DBObject dbObject = null;
|
DBObject dbObject = null;
|
||||||
@@ -406,21 +400,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
response.object = dbObject;
|
response.object = dbObject;
|
||||||
break;
|
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:
|
case PublishAccountObjects:
|
||||||
Print("Опубликовать объекты для пользователя " + request.arg);
|
Print("Опубликовать объекты для пользователя " + request.arg);
|
||||||
SetCurrentAccountDB(request.arg);
|
SetCurrentAccountDB(request.arg);
|
||||||
@@ -523,6 +502,13 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
|||||||
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
response = new ServerExchangeUnit_2021(ServerCode.OK);
|
||||||
response.object = Utils.packFile(account_db.getFile());
|
response.object = Utils.packFile(account_db.getFile());
|
||||||
break;
|
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:
|
default:
|
||||||
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
throw new RepositoryRefuseException("Неподдерживаемый код: " + code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,10 @@ package Visual_DVM_2021.Passes.All;
|
|||||||
import Common.Current;
|
import Common.Current;
|
||||||
import Common.UI.UI;
|
import Common.UI.UI;
|
||||||
import Common.Utils.Utils;
|
import Common.Utils.Utils;
|
||||||
import Repository.Server.ServerCode;
|
|
||||||
import Repository.Server.ServerExchangeUnit_2021;
|
|
||||||
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
import SapforTestingSystem.SapforTasksPackage.SapforTasksPackage;
|
||||||
import TestingSystem.TasksPackage.TasksPackageState;
|
import TestingSystem.TasksPackage.TasksPackageState;
|
||||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||||
|
|
||||||
import java.util.Vector;
|
|
||||||
public class DeleteSapforTasksPackage extends TestingSystemPass<SapforTasksPackage> {
|
public class DeleteSapforTasksPackage extends TestingSystemPass<SapforTasksPackage> {
|
||||||
@Override
|
@Override
|
||||||
public String getIconPath() {
|
public String getIconPath() {
|
||||||
@@ -36,10 +32,7 @@ public class DeleteSapforTasksPackage extends TestingSystemPass<SapforTasksPacka
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
target.results = null;
|
DeleteAccountObject(target);
|
||||||
Vector<SapforTasksPackage> vector = new Vector<>();
|
|
||||||
vector.add(target);
|
|
||||||
Command(new ServerExchangeUnit_2021(ServerCode.DeleteAccountObjects, Current.getAccount().email, vector));
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void performDone() throws Exception {
|
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,
|
PickCompilerEnvironmentsForTesting,
|
||||||
AddDVMParameterForTesting,
|
AddDVMParameterForTesting,
|
||||||
DeleteSelectedTestsRunTasks,
|
|
||||||
//-
|
//-
|
||||||
RefreshDVMTests,
|
RefreshDVMTests,
|
||||||
PauseTesting,
|
PauseTesting,
|
||||||
@@ -470,8 +469,6 @@ public enum PassCode_2021 {
|
|||||||
return "Возобновить тестирование";
|
return "Возобновить тестирование";
|
||||||
case RefreshDVMTests:
|
case RefreshDVMTests:
|
||||||
return "Обновить DVM тесты";
|
return "Обновить DVM тесты";
|
||||||
case DeleteSelectedTestsRunTasks:
|
|
||||||
return "Удалить отмеченные тестовые задачи";
|
|
||||||
case AddDVMParameterForTesting:
|
case AddDVMParameterForTesting:
|
||||||
return "Добавить параметр DVM системы для группы";
|
return "Добавить параметр DVM системы для группы";
|
||||||
case PickCompilerEnvironmentsForTesting:
|
case PickCompilerEnvironmentsForTesting:
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package Visual_DVM_2021.Passes;
|
package Visual_DVM_2021.Passes;
|
||||||
|
import Common.Current;
|
||||||
|
import Common.Database.DBObject;
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
|
import Repository.Server.ServerCode;
|
||||||
|
import Repository.Server.ServerExchangeUnit_2021;
|
||||||
import TestingSystem.TestingServer;
|
import TestingSystem.TestingServer;
|
||||||
|
import javafx.util.Pair;
|
||||||
public abstract class TestingSystemPass<T> extends RepositoryPass<TestingServer, T> {
|
public abstract class TestingSystemPass<T> extends RepositoryPass<TestingServer, T> {
|
||||||
public TestingSystemPass() {
|
public TestingSystemPass() {
|
||||||
super(Global.testingServer);
|
super(Global.testingServer);
|
||||||
@@ -9,4 +14,8 @@ public abstract class TestingSystemPass<T> extends RepositoryPass<TestingServer,
|
|||||||
protected int getTimeout() {
|
protected int getTimeout() {
|
||||||
return 120000;
|
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