промежуточный. Рефакторинг публикации теста из текущего проекта.
This commit is contained in:
@@ -7,7 +7,6 @@ import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.Common.TestingServer;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
||||
public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
||||
boolean from_current_project;
|
||||
@@ -19,9 +18,12 @@ public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
||||
@Override
|
||||
public boolean fillObjectFields() throws Exception {
|
||||
target.description = project.getLocalName();
|
||||
if (!project.description.isEmpty())
|
||||
if (!project.description.isEmpty()) {
|
||||
target.description += " " + project.description;
|
||||
target.description = Utils.ReplaceForbiddenSymbols(target.description);
|
||||
}
|
||||
target.group_id = group_id;
|
||||
//--
|
||||
if (from_current_project) {
|
||||
target.dim = project.testMaxDim;
|
||||
return super.fillObjectFields();
|
||||
@@ -39,7 +41,7 @@ public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
target.description = Utils.ReplaceForbiddenSymbols(target.description);
|
||||
target.packProject(project);
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
@@ -66,11 +68,6 @@ public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
||||
return super.canStart(args);
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
super.performDone();
|
||||
passes.get(PassCode_2021.PublishTestProject).Do(project, pk);
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
if (from_current_project)
|
||||
super.performFinish();
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Global;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.PassException;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
public class PublishTestProject extends TestingSystemPass<db_project_info> {
|
||||
Object test_id;
|
||||
byte[] bytes = null;
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
target = (db_project_info) args[0];
|
||||
test_id = args[1];
|
||||
bytes = null;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
File src = new File(Global.TempDirectory, String.valueOf(test_id));
|
||||
Utils.CheckAndCleanDirectory(src);
|
||||
target.Clone(src, false);
|
||||
//--
|
||||
FileUtils.copyFile(target.db.getFile(),
|
||||
Paths.get(src.getAbsolutePath(), Constants.data, target.db.getFile().getName()).toFile());
|
||||
//--
|
||||
//архивация.
|
||||
File archive = Utils.getTempFileName(String.valueOf(test_id));
|
||||
//---
|
||||
if (passes.get(PassCode_2021.ZipFolderPass).Do(src.getAbsolutePath(), archive.getAbsolutePath())) {
|
||||
bytes = Utils.packFile(archive);
|
||||
} else throw new PassException("Не удалось создать архив проекта");
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
ShowMessage1(target.name);
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.PublishTestProject, String.valueOf(test_id), bytes));
|
||||
}
|
||||
@Override
|
||||
protected void performFail() throws Exception {
|
||||
super.performFail();
|
||||
passes.get(PassCode_2021.SynchronizeTests).Do();
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package Visual_DVM_2021.Passes;
|
||||
import Common.Current;
|
||||
import Common.Database.DataSet;
|
||||
import Common.Database.rDBObject;
|
||||
import Common.UI.UI;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
|
||||
import java.util.Vector;
|
||||
public class DeleteSelectedServerObjects extends TestingSystemPass<Vector<rDBObject>> {
|
||||
Class objects_class;
|
||||
public DeleteSelectedServerObjects(Class class_in){
|
||||
objects_class=class_in;
|
||||
}
|
||||
Vector<String> names;
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/Delete.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
DataSet table = server.db.tables.get(objects_class);
|
||||
if (table.getCheckedCount() == 0) {
|
||||
Log.Writeln_("Не отмечено ни одного объекта.");
|
||||
return false;
|
||||
}
|
||||
Vector checkedItems = table.getCheckedItems();
|
||||
target = new Vector<>();
|
||||
names = new Vector<>();
|
||||
for (Object o : checkedItems) {
|
||||
rDBObject r = (rDBObject)o;
|
||||
if (Current.getAccount().CheckAccessRights(r.sender_address, Log)) {
|
||||
names.add(r.description);
|
||||
target.add(r);
|
||||
}
|
||||
}
|
||||
if (target.isEmpty()) {
|
||||
Log.Writeln_("Не отмечено ни одного объекта, принадлежащего текущему пользователю.");
|
||||
return false;
|
||||
}
|
||||
return UI.Warning(getDescription()+"\n" + String.join("\n", names));
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.DeleteObjects, "", target));
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
super.performFinish();
|
||||
passes.get(PassCode_2021.SynchronizeTests).Do();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,6 @@ public enum PassCode_2021 {
|
||||
OpenSapforEtalonVersion,
|
||||
OpenSapforVersion,
|
||||
PublishServerSapfor,
|
||||
PublishTestProject,
|
||||
DeleteTest,
|
||||
DeleteConfiguration,
|
||||
AbortTaskPackage,
|
||||
@@ -320,8 +319,6 @@ public enum PassCode_2021 {
|
||||
return "Удалить тест";
|
||||
case PublishServerSapfor:
|
||||
return "Опубликовать собранную версию SAPFOR";
|
||||
case PublishTestProject:
|
||||
return "Отправить проект теста";
|
||||
case DeleteGroup:
|
||||
return "Удалить группу";
|
||||
case UpdateProperty:
|
||||
|
||||
Reference in New Issue
Block a user