no message
This commit is contained in:
@@ -63,10 +63,12 @@ public class CreateGroupFromDirectory extends Pass_2021<Group> {
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
/*
|
||||
for (File file : files) {
|
||||
ShowMessage1("создание проекта: "+file.getName());
|
||||
passes.get(PassCode_2021.CreateTestFromDirectory).Do(file, group_id);
|
||||
}
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Utils.Files.VDirectoryChooser;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.io.File;
|
||||
public class CreateTestFromDirectory extends Pass_2021<Test> {
|
||||
db_project_info project = null;
|
||||
int group_id;
|
||||
File dir;
|
||||
VDirectoryChooser directoryChooser = new VDirectoryChooser("Выбор домашней папки теста");
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/CreateProject.png";
|
||||
}
|
||||
@Override
|
||||
public String getButtonText() {
|
||||
return "";
|
||||
}
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
group_id = Constants.Nan;
|
||||
project = null;
|
||||
dir = null;
|
||||
target = null;
|
||||
//-
|
||||
if (args.length == 0) {
|
||||
if (!Current.Check(Log, Current.Group))
|
||||
return false;
|
||||
group_id = Current.getGroup().id;
|
||||
dir = directoryChooser.ShowDialog();
|
||||
} else {
|
||||
dir = (File) args[0];
|
||||
group_id = (int) args[1];
|
||||
}
|
||||
//-
|
||||
if (dir == null)
|
||||
return false;
|
||||
//--
|
||||
if (!dir.isDirectory()) {
|
||||
Log.Writeln_(Utils.Brackets(dir) + "\nне является папкой!");
|
||||
return false;
|
||||
}
|
||||
//-
|
||||
if (dir.getName().equals(Constants.data)) {
|
||||
Log.Writeln_(Utils.Brackets(dir) + "\nявляется служебной папкой визуализатора!");
|
||||
return false;
|
||||
}
|
||||
return Utils.validateProjectFolder(dir, Log) && Utils.containsSource(dir, true);
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
passes.get(PassCode_2021.CloseCurrentProject).Do();
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
project = new db_project_info(dir);
|
||||
project.CreateVersionsTree();
|
||||
project.Open();
|
||||
project.Close();
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
super.performDone();
|
||||
passes.get(PassCode_2021.PublishTest).Do(project,group_id);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,9 @@ import Common.Current;
|
||||
import Common.Utils.Files.VDirectoryChooser;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Files.ProjectFile;
|
||||
import ProjectData.LanguageName;
|
||||
import TestingSystem.Common.Group.Group;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||
import Visual_DVM_2021.Passes.Pass_2021;
|
||||
|
||||
import java.io.File;
|
||||
@@ -24,19 +25,25 @@ public class CreateTestFromFolder extends Pass_2021<Test> {
|
||||
protected boolean needsAnimation() {
|
||||
return true;
|
||||
}
|
||||
Group group = null;
|
||||
File dir = null;
|
||||
boolean show_log;
|
||||
Vector<ProjectFile> project_files = new Vector<>();
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
show_log = true;
|
||||
if (!Current.Check(Log, Current.Group))
|
||||
return false;
|
||||
dir = directoryChooser.ShowDialog();
|
||||
group = Current.getGroup();
|
||||
} else {
|
||||
show_log = false;
|
||||
dir = (File) args[0];
|
||||
group = (Group) args[1];
|
||||
}
|
||||
if (dir ==null) {
|
||||
Log.Writeln_("Папка не выбрана.");
|
||||
if (dir == null) {
|
||||
if (show_log) Log.Writeln_("Папка не выбрана.");
|
||||
return false;
|
||||
}
|
||||
//---
|
||||
@@ -49,20 +56,19 @@ public class CreateTestFromFolder extends Pass_2021<Test> {
|
||||
int other_project_files = 0;
|
||||
//---
|
||||
if (dir.getName().equalsIgnoreCase(Constants.data)) {
|
||||
Log.Writeln_("Папка " + Utils.Brackets(dir) + " является служебной папкой визуализатора.");
|
||||
if (show_log) Log.Writeln_("Папка " + Utils.Brackets(dir) + " является служебной папкой визуализатора.");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
if (files == null) {
|
||||
Log.Writeln_("Не удалось получить список файлов для папки " + Utils.Brackets(dir) + ".");
|
||||
if (show_log) Log.Writeln_("Не удалось получить список файлов для папки " + Utils.Brackets(dir) + ".");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
for (File file : files) {
|
||||
if (!Utils.validateProjectFile(file, Log)) {
|
||||
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName())
|
||||
+ " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу."
|
||||
);
|
||||
if (show_log)
|
||||
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
|
||||
bad++;
|
||||
}
|
||||
if (file.isDirectory() && !file.getName().equalsIgnoreCase(Constants.data)) {
|
||||
@@ -73,7 +79,7 @@ public class CreateTestFromFolder extends Pass_2021<Test> {
|
||||
project_files.add(projectFile);
|
||||
switch (projectFile.fileType) {
|
||||
case program:
|
||||
if (projectFile.languageName.equals(LanguageName.fortran))
|
||||
if (projectFile.languageName.equals(group.language))
|
||||
fortran_programs++;
|
||||
else
|
||||
other_project_files++;
|
||||
@@ -89,20 +95,32 @@ public class CreateTestFromFolder extends Pass_2021<Test> {
|
||||
}
|
||||
//--
|
||||
if (subdirs > 0) {
|
||||
Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки.");
|
||||
if (show_log) Log.Writeln_("Папка " + Utils.Brackets(dir) + " содержит вложенные подпапки.");
|
||||
return false;
|
||||
}
|
||||
if (bad > 0) {
|
||||
return false;
|
||||
}
|
||||
if (fortran_programs == 0) {
|
||||
Log.Writeln_("Папка не содержит ни одной программы на языке FORTRAN.");
|
||||
if (show_log)
|
||||
Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + ".");
|
||||
return false;
|
||||
}
|
||||
if (other_project_files > 0) {
|
||||
Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке FORTRAN, или заголовочными.");
|
||||
if (show_log)
|
||||
Log.Writeln_("Папка содержит файлы, не являющиеся программами на языке FORTRAN, или заголовочными.");
|
||||
return false;
|
||||
}
|
||||
//-----
|
||||
target = new Test();
|
||||
target.sender_address = Current.getAccount().email;
|
||||
target.sender_name = Current.getAccount().name;
|
||||
target.group_id = group.id;
|
||||
target.description = dir.getName();
|
||||
Vector<String> filesNames = new Vector<>();
|
||||
for (ProjectFile projectFile : project_files)
|
||||
filesNames.add(projectFile.file.getName());
|
||||
target.files = String.join("\n", filesNames);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
@@ -113,5 +131,12 @@ public class CreateTestFromFolder extends Pass_2021<Test> {
|
||||
}
|
||||
System.out.println("===================");
|
||||
//--
|
||||
target.packCode(dir); //создание копии папки, и архивация.
|
||||
//--
|
||||
}
|
||||
@Override
|
||||
protected void performDone() throws Exception {
|
||||
super.performDone();
|
||||
passes.get(PassCode_2021.PublishTest).Do(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +71,14 @@ public class CreateTestsGroupFromSelectedVersions extends Pass_2021<Vector<db_pr
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
/*
|
||||
for (db_project_info vizTestProject : target) {
|
||||
//на случай если версия в текущем сеансе еще не открывалась.
|
||||
vizTestProject.Open();
|
||||
vizTestProject.Close();
|
||||
if (!passes.get(PassCode_2021.PublishTest).Do(vizTestProject, Current.getGroup().id)) break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
|
||||
@@ -1,86 +1,15 @@
|
||||
package Visual_DVM_2021.Passes.All;
|
||||
import Common.Constants;
|
||||
import Common.Current;
|
||||
import Common.Global;
|
||||
import Common.UI.UI;
|
||||
import Common.Utils.Utils;
|
||||
import ProjectData.Project.db_project_info;
|
||||
import TestingSystem.Common.Test.Test;
|
||||
import TestingSystem.Common.TestingServer;
|
||||
import Visual_DVM_2021.Passes.Server.PublishServerObject;
|
||||
|
||||
import java.util.Vector;
|
||||
public class PublishTest extends PublishServerObject<TestingServer, Test> {
|
||||
boolean from_current_project;
|
||||
protected int group_id;
|
||||
protected db_project_info project = null;
|
||||
public PublishTest() {
|
||||
super(Global.testingServer, Test.class);
|
||||
}
|
||||
@Override
|
||||
public boolean fillObjectFields() throws Exception {
|
||||
target.description = project.getLocalName();
|
||||
if (!project.description.isEmpty()) {
|
||||
target.description += " " + project.description;
|
||||
target.description = Utils.ReplaceForbiddenSymbols(target.description);
|
||||
}
|
||||
target.group_id = group_id;
|
||||
//подпапок нет. имена совпадают с относительными.
|
||||
Vector<String> filesNames = new Vector<>(project.db.files.Data.keySet());
|
||||
target.files = String.join(";", filesNames);
|
||||
//--
|
||||
if (from_current_project) {
|
||||
// target.max_dim = project.testMaxDim;
|
||||
return super.fillObjectFields();
|
||||
} else {
|
||||
switch (project.languageName) {
|
||||
case fortran:
|
||||
target.max_dim = Current.getSapfor().getTextMaxDim(null, project);
|
||||
break;
|
||||
case c:
|
||||
target.max_dim = Utils.getCProjectMaxDim(project);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void performPreparation() throws Exception {
|
||||
target.packProject(project);
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
group_id = Constants.Nan;
|
||||
project = null;
|
||||
if (args.length == 0) {
|
||||
from_current_project = true;
|
||||
if (Current.Check(Log, Current.Group, Current.Project) && UI.Question("Добавить текущий проект в глобальную базу тестов")) {
|
||||
project = Current.getProject();
|
||||
group_id = Current.getGroup().id;
|
||||
}
|
||||
} else {
|
||||
from_current_project = false;
|
||||
project = (db_project_info) args[0];
|
||||
group_id = (int) args[1];
|
||||
}
|
||||
//--
|
||||
if (project == null)
|
||||
return false;
|
||||
//--
|
||||
if (!project.checkSubdirectories(Log))
|
||||
return false;
|
||||
//-
|
||||
return super.canStart(args);
|
||||
}
|
||||
@Override
|
||||
protected void performFinish() throws Exception {
|
||||
if (from_current_project)
|
||||
super.performFinish();
|
||||
else disconnect();
|
||||
}
|
||||
@Override
|
||||
protected void showDone() throws Exception {
|
||||
if (from_current_project)
|
||||
super.showDone();
|
||||
target = (Test) args[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user