no message

This commit is contained in:
2023-11-23 22:38:21 +03:00
parent b3401bfe1c
commit 509c858b1a
10 changed files with 89 additions and 173 deletions

12
.idea/workspace.xml generated
View File

@@ -7,13 +7,13 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFolder.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishTests.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestsMenuBar/TestsMenuBar.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/UI/Menus_2023/TestsMenuBar/TestsMenuBar.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Utils/Utils.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Utils/Utils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/RepositoryServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Server/ServerCode.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ProjectData/Project/db_project_info.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ProjectData/Project/db_project_info.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/Common/Test/Test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateGroupFromDirectory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateGroupFromDirectory.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFolder.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFolder.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestsGroupFromSelectedVersions.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishTest.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/PublishTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/PassCode_2021.java" afterDir="false" />
</list>

View File

@@ -1063,7 +1063,6 @@ public class db_project_info extends DBObject {
} else {
if (//!file.state.equals(FileState.Excluded)&&
(!file.fileType.equals(FileType.header) || migrate_headers)) {
File toCopy = Paths.get(target.Home.getAbsolutePath(), file.name).toFile();
if (!toCopy.exists())
Files.copy(file.file.toPath(), toCopy.toPath());
@@ -1558,4 +1557,15 @@ public class db_project_info extends DBObject {
}
return true;
}
public void clearData() throws Exception {
File project_data = new File(Home, Constants.data);
File[] files = project_data.listFiles();
if (files != null) {
for (File file : files) {
if (!file.getName().equalsIgnoreCase("new_project_base.sqlite")) {
FileUtils.forceDelete(file);
}
}
}
}
}

View File

@@ -15,7 +15,6 @@ import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
public class Test extends riDBObject {
@Description("DEFAULT 1")
public int min_dim = 1; //мин размерность теста.
@@ -77,13 +76,16 @@ public class Test extends riDBObject {
return new File(Global.TempDirectory, temp_project_name);
}
//--
/*
public void packProject(db_project_info project) throws Exception {
//если берем из текущего проекта.
temp_project_name = Utils.getDateName("test");
//-
File tempProject = getTempProject();
File tempArchive = getTempArchive();
//-
FileUtils.forceMkdir(tempProject);
project.clearData();
project.Clone(tempProject, false);
//--
FileUtils.copyFile(project.db.getFile(),
@@ -93,6 +95,27 @@ public class Test extends riDBObject {
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив проекта");
}
*/
public void packCode(File dir) throws Exception {
temp_project_name = Utils.getDateName("test");
//-
File tempProject = getTempProject();
File tempArchive = getTempArchive();
//- создать бд.
db_project_info project = new db_project_info(dir);
project.Open();
project.Close();
//-
project.clearData();
//-
FileUtils.forceMkdir(tempProject);
FileUtils.copyDirectory(dir, tempProject);
//--
ZipFolderPass zip = new ZipFolderPass();
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
project_archive_bytes = Utils.packFile(tempArchive);
} else throw new PassException("Не удалось создать архив папки с кодом.");
}
public boolean unpackProjectOnServer() throws Exception {
File tmpArchive = new File(Global.TempDirectory, temp_project_name + ".zip");
@@ -125,4 +148,7 @@ public class Test extends riDBObject {
throw new RepositoryRefuseException("Не удалось переписать архив проекта");
return true;
}
public String getFilesForTable(){
return files.replace("\n", ";");
}
}

View File

@@ -39,7 +39,7 @@ public class TestDBTable extends iDBTable<Test> {
case 4:
return object.max_dim;
case 5:
return object.files;
return object.getFilesForTable();
default:
return null;
}

View File

@@ -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 {

View File

@@ -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) + "\е является папкой!");
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);
}
}

View File

@@ -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 (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) {
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);
}
}

View File

@@ -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 {

View File

@@ -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;
}
protected boolean canStart(Object... args) throws Exception {
target = (Test) args[0];
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();
}
}

View File

@@ -297,7 +297,6 @@ public enum PassCode_2021 {
DeleteConfiguration,
AbortTaskPackage,
//--
CreateTestFromDirectory,
CreateGroupFromDirectory,
PublishTests,
CreateTestFromFolder,
@@ -315,8 +314,7 @@ public enum PassCode_2021 {
return "Удаление Open MP директив";
case CreateGroupFromDirectory:
return "Создать группу тестов из папки";
case CreateTestFromDirectory:
return "Создать тест из папки";
case AbortTaskPackage:
return "Прерывать пакет тестирования DVM";
case DeleteConfiguration: