промежуточный. часть большого рефакторинга, касательно проходов связанных с сервером. Обновлена публикация групп.
This commit is contained in:
@@ -4,17 +4,13 @@ import Common.Current;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import Repository.Server.ServerCode;
|
||||
import Repository.Server.ServerExchangeUnit_2021;
|
||||
import TestingSystem.Test.ProjectFiles_json;
|
||||
import TestingSystem.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.TestingSystemPass;
|
||||
import Visual_DVM_2021.Passes.Server.TestingSystemPass;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
public class PublishTest extends TestingSystemPass<Test> {
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
@@ -25,19 +21,9 @@ public class PublishTest extends TestingSystemPass<Test> {
|
||||
return "";
|
||||
}
|
||||
protected db_project_info project = null;
|
||||
protected ProjectFiles_json files_json = null;
|
||||
protected boolean checkCurrentGroupAutorship() {
|
||||
if (!Current.getGroup().sender_address.equals(Current.getAccount().email)) {
|
||||
Log.Writeln_("Текущая группа " + Utils.Brackets(Current.getGroup().description)
|
||||
+ " принадлежит пользователю " + Utils.Brackets(Current.getGroup().sender_address)
|
||||
+ "\nВы не являетесь её автором!"
|
||||
);
|
||||
return false;
|
||||
} else return true;
|
||||
}
|
||||
protected boolean setProject() {
|
||||
if (Current.Check(Log, Current.Group, Current.Project) &&
|
||||
checkCurrentGroupAutorship() && checkSubdirectories()
|
||||
checkSubdirectories()
|
||||
&& UI.Question("Добавить текущий проект в глобальную базу тестов")) {
|
||||
project = Current.getProject();
|
||||
switch (project.languageName) {
|
||||
@@ -59,31 +45,18 @@ public class PublishTest extends TestingSystemPass<Test> {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
protected boolean packPrograms() {
|
||||
files_json = project.filesToJson();
|
||||
if (files_json.files.isEmpty()) {
|
||||
Log.Writeln_("В проекте не найдено ни одной активной программы!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
project = null;
|
||||
files_json = null;
|
||||
if (Current.getAccount().CheckRegistered(Log) && setProject() && packPrograms()) {
|
||||
if (Current.getAccount().CheckRegistered(Log) && setProject()) {
|
||||
target = new Test();
|
||||
target.genName();
|
||||
target.description = project.getLocalName() + " " + project.description;
|
||||
// target.project_description=project.description;
|
||||
target.dim = project.testMaxDim;
|
||||
target.date = new Date().getTime();
|
||||
target.sender_name = Current.getAccount().name;
|
||||
target.sender_address = Current.getAccount().email;
|
||||
target.group_id = Current.getGroup().id;
|
||||
target.files_json = Utils.jsonToPrettyFormat(Utils.gson.toJson(files_json));
|
||||
if (fillObjectFields()) {
|
||||
File src = Paths.get(System.getProperty("user.dir"), "Temp", target.id).toFile();
|
||||
File src = Paths.get(System.getProperty("user.dir"), "Temp", String.valueOf(target.id)).toFile();
|
||||
Utils.forceDeleteWithCheck(src);
|
||||
FileUtils.forceMkdir(src);
|
||||
if (project.db.files.Data.isEmpty()) {
|
||||
@@ -108,7 +81,7 @@ public class PublishTest extends TestingSystemPass<Test> {
|
||||
}
|
||||
@Override
|
||||
protected void ServerAction() throws Exception {
|
||||
Command(new ServerExchangeUnit_2021(ServerCode.PublishObject, "", target));
|
||||
PublishObject(target);
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user