Добавление одного выбранного файла в качестве теста.
This commit is contained in:
5
.idea/workspace.xml
generated
5
.idea/workspace.xml
generated
@@ -7,6 +7,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
|
<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/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromDirectory.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromFile.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromProject.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/All/CreateTestFromProject.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class TestsMenuBar extends DataMenuBar {
|
|||||||
//PassCode_2021.PublishTest,
|
//PassCode_2021.PublishTest,
|
||||||
PassCode_2021.CreateTestFromProject,
|
PassCode_2021.CreateTestFromProject,
|
||||||
PassCode_2021.CreateTestFromDirectory,
|
PassCode_2021.CreateTestFromDirectory,
|
||||||
|
PassCode_2021.CreateTestFromFile,
|
||||||
PassCode_2021.EditTest,
|
PassCode_2021.EditTest,
|
||||||
PassCode_2021.DownloadTest,
|
PassCode_2021.DownloadTest,
|
||||||
PassCode_2021.DeleteTest);
|
PassCode_2021.DeleteTest);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package Common.Utils;
|
|||||||
import Common.Constants;
|
import Common.Constants;
|
||||||
import Common.Global;
|
import Common.Global;
|
||||||
import Common.UI.UI;
|
import Common.UI.UI;
|
||||||
import Common.Utils.Files.VDirectoryChooser;
|
import Common.Utils.Files.VFileChooser_;
|
||||||
import GlobalData.Settings.SettingName;
|
import GlobalData.Settings.SettingName;
|
||||||
import GlobalData.Tasks.TaskState;
|
import GlobalData.Tasks.TaskState;
|
||||||
import ProjectData.Files.DBProjectFile;
|
import ProjectData.Files.DBProjectFile;
|
||||||
@@ -1120,7 +1120,7 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
public static void RestoreSelectedDirectory(VDirectoryChooser directoryChooser) {
|
public static void RestoreSelectedDirectory(VFileChooser_ directoryChooser) {
|
||||||
String last_dir_home =
|
String last_dir_home =
|
||||||
Global.db.settings.get(SettingName.ProjectsSearchDirectory).Value;
|
Global.db.settings.get(SettingName.ProjectsSearchDirectory).Value;
|
||||||
if (!last_dir_home.isEmpty())
|
if (!last_dir_home.isEmpty())
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
if (!Utils.validateProjectFile(dir, Log)) {
|
if (Utils.ContainsCyrillic(dir.getName()) || Utils.ContainsForbiddenName(dir.getName())) {
|
||||||
Log.Writeln_("Имя папки " + Utils.Brackets(dir.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
|
Log.Writeln_("Имя папки " + Utils.Brackets(dir.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -90,16 +90,12 @@ public class CreateTestFromDirectory extends Pass_2021<Test> {
|
|||||||
} else if (file.isFile() && !Utils.ContainsCyrillic(file.getName()) && !Utils.ContainsForbiddenName(file.getName())) {
|
} else if (file.isFile() && !Utils.ContainsCyrillic(file.getName()) && !Utils.ContainsForbiddenName(file.getName())) {
|
||||||
//если файл. все недопустимые файлы просто игнорируются.
|
//если файл. все недопустимые файлы просто игнорируются.
|
||||||
ProjectFile projectFile = new ProjectFile(file);
|
ProjectFile projectFile = new ProjectFile(file);
|
||||||
System.out.println(projectFile.file);
|
|
||||||
System.out.println("1");
|
|
||||||
if (isNotExcluded(projectFile)) {
|
if (isNotExcluded(projectFile)) {
|
||||||
System.out.println("1.5");
|
|
||||||
switch (projectFile.fileType) {
|
switch (projectFile.fileType) {
|
||||||
case program:
|
case program:
|
||||||
if (projectFile.languageName.equals(group.language)) {
|
if (projectFile.languageName.equals(group.language)) {
|
||||||
active_programs++;
|
active_programs++;
|
||||||
project_files.add(projectFile);
|
project_files.add(projectFile);
|
||||||
System.out.println("2");
|
|
||||||
} else
|
} else
|
||||||
other_project_files++;
|
other_project_files++;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,115 @@
|
|||||||
package Visual_DVM_2021.Passes.All;
|
package Visual_DVM_2021.Passes.All;
|
||||||
|
import Common.Constants;
|
||||||
|
import Common.Current;
|
||||||
|
import Common.Utils.Files.VFileChooser;
|
||||||
|
import Common.Utils.Utils;
|
||||||
|
import GlobalData.Settings.SettingName;
|
||||||
|
import ProjectData.Files.FileType;
|
||||||
|
import ProjectData.Files.ProjectFile;
|
||||||
|
import ProjectData.LanguageName;
|
||||||
|
import Repository.Component.Sapfor.Sapfor;
|
||||||
|
import TestingSystem.Common.Group.Group;
|
||||||
import TestingSystem.Common.Test.Test;
|
import TestingSystem.Common.Test.Test;
|
||||||
|
import Visual_DVM_2021.Passes.PassCode_2021;
|
||||||
|
import Visual_DVM_2021.Passes.PassException;
|
||||||
import Visual_DVM_2021.Passes.Pass_2021;
|
import Visual_DVM_2021.Passes.Pass_2021;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
public class CreateTestFromFile extends Pass_2021<Test> {
|
public class CreateTestFromFile extends Pass_2021<Test> {
|
||||||
|
VFileChooser fileChooser = new VFileChooser("Выберите файл для создания теста");
|
||||||
|
//---
|
||||||
|
File file;
|
||||||
|
Group group;
|
||||||
|
boolean from_file_chooser = false;
|
||||||
|
ProjectFile projectFile;
|
||||||
|
//---
|
||||||
|
@Override
|
||||||
|
public String getIconPath() {
|
||||||
|
return "/icons/AddFile.png";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getButtonText() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean canStart(Object... args) throws Exception {
|
||||||
|
projectFile = null;
|
||||||
|
if (args.length == 0) {
|
||||||
|
from_file_chooser = true;
|
||||||
|
if (!Current.Check(Log, Current.Group))
|
||||||
|
return false;
|
||||||
|
group = Current.getGroup();
|
||||||
|
Utils.RestoreSelectedDirectory(fileChooser);
|
||||||
|
file = fileChooser.ShowDialog();
|
||||||
|
if (file == null) {
|
||||||
|
Log.Writeln_("Файл не выбран");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Pass_2021.passes.get(PassCode_2021.UpdateSetting).Do(SettingName.ProjectsSearchDirectory, file.getParent());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
from_file_chooser = false;
|
||||||
|
file = (File) args[0];
|
||||||
|
group = (Group) args[1];
|
||||||
|
}
|
||||||
|
if (Utils.ContainsCyrillic(file.getName()) || Utils.ContainsForbiddenName(file.getName())) {
|
||||||
|
Log.Writeln_("Имя файла " + Utils.Brackets(file.getName()) + " содержит запрещённые символы " + Constants.all_forbidden_characters_string + ", или кириллицу.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//если файл. все недопустимые файлы просто игнорируются.
|
||||||
|
projectFile = new ProjectFile(file);
|
||||||
|
if (!projectFile.fileType.equals(FileType.program) || !projectFile.languageName.equals(group.language)) {
|
||||||
|
Log.Writeln_("Не удалось распознать файл как программу на языке " + group.language.getDescription());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//-----
|
||||||
|
target = new Test();
|
||||||
|
target.sender_address = Current.getAccount().email;
|
||||||
|
target.sender_name = Current.getAccount().name;
|
||||||
|
target.group_id = group.id;
|
||||||
|
target.description = Utils.getNameWithoutExtension(file.getName());
|
||||||
|
target.files = file.getName();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public File packTestCode() throws Exception {
|
||||||
|
target.temp_project_name = Utils.getDateName("test");
|
||||||
|
//-
|
||||||
|
File tempProject = target.getTempProject();
|
||||||
|
File tempArchive = target.getTempArchive();
|
||||||
|
//- создать бд.
|
||||||
|
FileUtils.forceMkdir(tempProject);
|
||||||
|
//--
|
||||||
|
File dst = new File(tempProject, projectFile.file.getName());
|
||||||
|
FileUtils.copyFile(projectFile.file, dst);
|
||||||
|
//---
|
||||||
|
Utils.ClearProjectData(tempProject);
|
||||||
|
//--
|
||||||
|
ZipFolderPass zip = new ZipFolderPass();
|
||||||
|
if (zip.Do(tempProject.getAbsolutePath(), tempArchive.getAbsolutePath())) {
|
||||||
|
target.project_archive_bytes = Utils.packFile(tempArchive);
|
||||||
|
} else throw new PassException("Не удалось создать архив папки с кодом.");
|
||||||
|
return tempProject;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void body() throws Exception {
|
||||||
|
ShowMessage1(file.getName());
|
||||||
|
//--
|
||||||
|
File tempProject = packTestCode(); //создание копии папки, и архивация.
|
||||||
|
//-- получить размерность консольным сапфором. папка уже отправлена и чистить ее не нужно!!
|
||||||
|
ShowMessage2("Синтаксический анализ и определение размерности");
|
||||||
|
if (group.language == LanguageName.fortran) {//если не определит, будут нули.
|
||||||
|
Sapfor.getMinMaxDim(Sapfor.getTempCopy(Current.getSapfor().getFile()), tempProject, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected boolean validate() {
|
||||||
|
return Log.isEmpty();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void performDone() throws Exception {
|
||||||
|
super.performDone();
|
||||||
|
if (from_file_chooser)
|
||||||
|
passes.get(PassCode_2021.PublishTest).Do(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ public class CreateTestFromProject extends CreateTestFromDirectory {
|
|||||||
project = (db_project_info) args[0];
|
project = (db_project_info) args[0];
|
||||||
group = (Group) args[1];
|
group = (Group) args[1];
|
||||||
from_directory_chooser = false;
|
from_directory_chooser = false;
|
||||||
// project.Open();
|
|
||||||
// project.Close();
|
|
||||||
return super.canStart(project.Home, group);
|
return super.canStart(project.Home, group);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user