рефакторинг бд файлов тестов.
This commit is contained in:
2025-03-20 17:48:18 +03:00
parent 3f4ef5f198
commit 0b5f8c6ec7
22 changed files with 374 additions and 359 deletions

25
.idea/workspace.xml generated
View File

@@ -7,17 +7,28 @@
</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 afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/projectFile_.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestFile/TestFile.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestFile/TestFilesDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" /> <change beforePath="$PROJECT_DIR$/properties" beforeDir="false" afterPath="$PROJECT_DIR$/properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Database/Database.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Database/Database.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Passes/DeleteObjectPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Passes/DeleteObjectPass.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/Component/Sapfor/Sapfor.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/StartSelectedDVMConfigurations.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/StartSelectedDVMConfigurations.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromDirectory.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromDirectory.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ServerObjectsCache/ConfigurationCache.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ServerObjectsCache/ConfigurationCache.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Configuration/Configuration.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Configuration/Configuration.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CreateTestFromProject.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ReplaceTestProject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/ReplaceTestProject.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/DBProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/ProjectFile.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ProjectData/Files/ProjectFile.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ServerObjectsCache/TestCache.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ServerObjectsCache/TestCache.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Group/Group.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Group/Group.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/Test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/Test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/Test/TestDBTable.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/Common/TestsDatabase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationDialog.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationDialog.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/LocalDVMTestingPlanner.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationFields.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationFields.form" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationFields.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationFields.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationsForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/TestingSystem/DVM/DVMConfiguration/UI/DVMConfigurationsForm.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />

View File

@@ -15,7 +15,7 @@
"AutoTestsLoad": true, "AutoTestsLoad": true,
"ConfirmPassesStart": true, "ConfirmPassesStart": true,
"ShowPassesDone": true, "ShowPassesDone": true,
"FocusPassesResult": true, "FocusPassesResult": false,
"collapseCredentials": true, "collapseCredentials": true,
"collapseFileGraphs": false, "collapseFileGraphs": false,
"collapseFileMessages": true, "collapseFileMessages": true,

View File

@@ -318,6 +318,21 @@ public abstract class Database {
prepareTablesStatements(); prepareTablesStatements();
Synchronize(); Synchronize();
} }
public void DeleteDependencies(DBObject object) throws Exception{
DBTable object_table = getTable(object.getClass());
for (Class dep : object_table.getFKDependencies().keySet()) {
switch (object_table.getFKDependencies().get(dep).data) {
case NONE:
break;
case DROP:
DropByFK(object, dep);
break;
case DELETE:
DeleteByFK(object, dep);
break;
}
}
}
public void DropUI() { public void DropUI() {
SaveLastSelections(); SaveLastSelections();
} }

View File

@@ -35,18 +35,7 @@ public abstract class DeleteObjectPass<D extends DBObject> extends ObjectPass<D>
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {
getDb().Delete(target); getDb().Delete(target);
for (Class dep : getTable().getFKDependencies().keySet()) { getDb().DeleteDependencies(target);
switch (getTable().getFKDependencies().get(dep).data) {
case NONE:
break;
case DROP:
getDb().DropByFK(target, dep);
break;
case DELETE:
getDb().DeleteByFK(target, dep);
break;
}
}
} }
//тут именно на финише, чтобы в любом случае вся таблица всегда была видна. //тут именно на финише, чтобы в любом случае вся таблица всегда была видна.
@Override @Override

View File

@@ -12,9 +12,8 @@ import _VisualDVM.Passes.Sapfor.SapforAnalysis;
import _VisualDVM.ProjectData.Files.DBProjectFile; import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor; import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor;
import _VisualDVM.ProjectData.Project.db_project_info; import _VisualDVM.ProjectData.Project.db_project_info;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.Utils; import _VisualDVM.Utils;
import javafx.util.Pair; import javafx.util.Pair;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -393,15 +392,9 @@ public abstract class Sapfor extends OSDComponent {
test.max_dim = res.getValue(); test.max_dim = res.getValue();
} }
public static void getTestMinMaxDime_C(Test test) { public static void getTestMinMaxDime_C(Test test) {
File workspace = test.getServerPath();
Vector<File> files = new Vector<>();
TestFilesJson filesJson = Utils_.gson.fromJson(test.packedFilesJson, TestFilesJson.class);
for (TestFileJson fileJson : filesJson.values) {
files.add(new File(workspace, fileJson.name));
}
int min_dim = 0; int min_dim = 0;
int max_dim = 0; int max_dim = 0;
for (File file : files) { for (File file : test.getServerFiles()) {
max_dim = Math.max(max_dim, getFileMaxDim_C(file)); max_dim = Math.max(max_dim, getFileMaxDim_C(file));
} }
test.min_dim = min_dim; test.min_dim = min_dim;

View File

@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
import java.util.Vector; import java.util.Vector;
public class Constants { public class Constants {
public static final int version = 1218; public static final int version = 1219;
public static final int planner_version = 24; public static final int planner_version = 24;
public static final int testingMaxKernels = 64; public static final int testingMaxKernels = 64;
//-- //--

View File

@@ -6,11 +6,9 @@ import Common.Visual.Windows.Dialog.VDirectoryChooser;
import _VisualDVM.Constants; import _VisualDVM.Constants;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.TestingSystem.Common.Group.Group; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.Utils; import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@@ -23,7 +21,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
boolean from_files_chooser = false; boolean from_files_chooser = false;
Vector<File> files = null; Vector<File> files = null;
//-- //--
Vector<ProjectFile> project_files = new Vector<>(); Vector<TestFile> testFiles = new Vector<>();
@Override @Override
public String getIconPath() { public String getIconPath() {
return "/icons/OpenProject.png"; return "/icons/OpenProject.png";
@@ -106,7 +104,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
return false; return false;
} }
//--- //---
project_files = new Vector<>(); testFiles = new Vector<>();
//-- //--
for (File file : files) { for (File file : files) {
//----- //-----
@@ -118,22 +116,22 @@ public class CreateTestFromDirectory extends Pass<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); TestFile testFile = new TestFile(file);
if (isNotExcluded(projectFile)) { if (isNotExcluded(testFile)) {
switch (projectFile.fileType) { switch (testFile.fileType) {
case program: case program:
if (projectFile.languageName.equals(group.language)) { if (testFile.languageName.equals(group.language)) {
active_programs++; active_programs++;
project_files.add(projectFile); testFiles.add(testFile);
} else } else
other_project_files++; other_project_files++;
break; break;
case header: case header:
headers++; headers++;
project_files.add(projectFile); testFiles.add(testFile);
break; break;
case none: case none:
project_files.add(projectFile); testFiles.add(testFile);
other_project_files++; other_project_files++;
break; break;
default: default:
@@ -153,7 +151,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + "."); Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + ".");
return false; return false;
} }
if (project_files.isEmpty()) { if (testFiles.isEmpty()) {
Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка " + Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка " +
group.language.getDescription() + "\n" + group.language.getDescription() + "\n" +
group.language.PrintExtensions() group.language.PrintExtensions()
@@ -162,16 +160,10 @@ public class CreateTestFromDirectory extends Pass<Test> {
//---- //----
if (!initTarget()) return false; if (!initTarget()) return false;
//---- //----
TestFilesJson filesJson = new TestFilesJson(); target.files = new Vector<>(testFiles);
Vector<String> filesNames = new Vector<>();
for (ProjectFile projectFile : project_files) {
filesNames.add(projectFile.file.getName());
filesJson.values.add(new TestFileJson(projectFile));
}
target.packedFilesJson = Utils_.gson.toJson(filesJson);
return true; return true;
} }
public boolean isNotExcluded(ProjectFile projectFile) { public boolean isNotExcluded(TestFile testFile) {
return true; return true;
} }
//- //-
@@ -183,10 +175,13 @@ public class CreateTestFromDirectory extends Pass<Test> {
//- создать бд. //- создать бд.
FileUtils.forceMkdir(tempProject); FileUtils.forceMkdir(tempProject);
//-- //--
for (ProjectFile projectFile : project_files) { for (TestFile testFile : testFiles) {
File dst = new File(tempProject, projectFile.file.getName()); File src = new File(dir, testFile.name);
FileUtils.copyFile(projectFile.file, dst); File dst = new File(tempProject, testFile.name);
FileUtils.copyFile(src, dst);
} }
target.files = new Vector<>();
target.files.addAll(testFiles);
//--- //---
Utils.ClearProjectData(tempProject); Utils.ClearProjectData(tempProject);
//-- //--

View File

@@ -4,19 +4,19 @@ import Common.Passes.PassException;
import Common.Utils.Utils_; import Common.Utils.Utils_;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.ProjectData.Files.FileType; import _VisualDVM.ProjectData.Files.FileType;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.TestingSystem.Common.Group.Group; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.Utils; import _VisualDVM.Utils;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.Vector;
public class CreateTestFromFile extends Pass<Test> { public class CreateTestFromFile extends Pass<Test> {
//---- //----
Group group; Group group;
ProjectFile projectFile; TestFile testFile;
File file;
//---- //----
@Override @Override
protected boolean needsAnimation() { protected boolean needsAnimation() {
@@ -32,20 +32,20 @@ public class CreateTestFromFile extends Pass<Test> {
} }
@Override @Override
protected boolean canStart(Object... args) throws Exception { protected boolean canStart(Object... args) throws Exception {
projectFile = null; testFile = null;
File file_in = (File) args[0]; file = (File) args[0];
group = (Group) args[1]; group = (Group) args[1];
//-- //--
if (Utils_.ContainsCyrillic(file_in.getName()) || Utils_.ContainsForbiddenName(file_in.getName())) { if (Utils_.ContainsCyrillic(file.getName()) || Utils_.ContainsForbiddenName(file.getName())) {
Log.Writeln_("Имя файла " + Utils_.Brackets(file_in.getName()) Log.Writeln_("Имя файла " + Utils_.Brackets(file.getName())
+ " содержит запрещённые символы " + + " содержит запрещённые символы " +
Utils_.printAllForbiddenCharacters() + ", или кириллицу."); Utils_.printAllForbiddenCharacters() + ", или кириллицу.");
return false; return false;
} }
//-- //--
projectFile = new ProjectFile(file_in); testFile = new TestFile(file);
if (!projectFile.fileType.equals(FileType.program) || !projectFile.languageName.equals(group.language)) { if (!testFile.fileType.equals(FileType.program) || !testFile.languageName.equals(group.language)) {
Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file_in.getName()) + Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file.getName()) +
" как программу на языке " + group.language.getDescription()); " как программу на языке " + group.language.getDescription());
return false; return false;
} }
@@ -54,10 +54,10 @@ public class CreateTestFromFile extends Pass<Test> {
target.sender_address = Global.mainModule.getAccount().email; target.sender_address = Global.mainModule.getAccount().email;
target.sender_name = Global.mainModule.getAccount().name; target.sender_name = Global.mainModule.getAccount().name;
target.group_id = group.id; target.group_id = group.id;
target.description = Utils_.getNameWithoutExtension(file_in.getName()); target.description = Utils_.getNameWithoutExtension(file.getName());
TestFilesJson filesJson = new TestFilesJson(); target.files = new Vector<>();
filesJson.values.add(new TestFileJson(new ProjectFile(file_in))); target.files.add(testFile);
target.packedFilesJson = Utils_.gson.toJson(filesJson); //--
return true; return true;
} }
public File packTestCode() throws Exception { public File packTestCode() throws Exception {
@@ -68,8 +68,8 @@ public class CreateTestFromFile extends Pass<Test> {
//- создать бд. //- создать бд.
FileUtils.forceMkdir(tempProject); FileUtils.forceMkdir(tempProject);
//-- //--
File dst = new File(tempProject, projectFile.file.getName()); File dst = new File(tempProject, testFile.name);
FileUtils.copyFile(projectFile.file, dst); FileUtils.copyFile(file, dst);
//--- //---
Utils.ClearProjectData(tempProject); Utils.ClearProjectData(tempProject);
//-- //--
@@ -81,7 +81,7 @@ public class CreateTestFromFile extends Pass<Test> {
} }
@Override @Override
protected void body() throws Exception { protected void body() throws Exception {
ShowMessage1(projectFile.file.getName()); ShowMessage1(testFile.name);
packTestCode(); packTestCode();
} }
} }

View File

@@ -2,9 +2,9 @@ package _VisualDVM.Passes.All;
import _VisualDVM.Current; import _VisualDVM.Current;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.ProjectData.Files.FileState; import _VisualDVM.ProjectData.Files.FileState;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.ProjectData.Project.db_project_info; import _VisualDVM.ProjectData.Project.db_project_info;
import _VisualDVM.TestingSystem.Common.Group.Group; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
//добавить в текущую группу новый тест из текущего проекта. //добавить в текущую группу новый тест из текущего проекта.
public class CreateTestFromProject extends CreateTestFromDirectory { public class CreateTestFromProject extends CreateTestFromDirectory {
db_project_info project; db_project_info project;
@@ -37,8 +37,8 @@ public class CreateTestFromProject extends CreateTestFromDirectory {
return false; return false;
} }
@Override @Override
public boolean isNotExcluded(ProjectFile projectFile) { public boolean isNotExcluded(TestFile testFile) {
return project.db.files.containsKey(projectFile.file.getName()) && return project.db.files.containsKey(testFile.name) &&
!project.db.files.get(projectFile.file.getName()).state.equals(FileState.Excluded); !project.db.files.get(testFile.name).state.equals(FileState.Excluded);
} }
} }

View File

@@ -3,6 +3,7 @@ import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Server.TestingServerPass; import _VisualDVM.Passes.Server.TestingServerPass;
import _VisualDVM.Repository.Server.ServerCode; import _VisualDVM.Repository.Server.ServerCode;
import _VisualDVM.ServerObjectsCache.VisualCaches;
import java.io.Serializable; import java.io.Serializable;
//заменить текущий тест на текущий проект. //заменить текущий тест на текущий проект.
@@ -27,6 +28,12 @@ public class ReplaceTestProject extends CreateTestFromProject {
Global.mainModule.getPass(PassCode.SynchronizeTests).Do(); Global.mainModule.getPass(PassCode.SynchronizeTests).Do();
} }
@Override @Override
protected void showDone() throws Exception {
super.showFinish();
VisualCaches.RefreshCache(target);
Global.testingServer.db.tests.getUI().Show(target.getPK());
}
@Override
protected boolean initTarget() throws Exception { protected boolean initTarget() throws Exception {
if (Global.testingServer.db.tests.getUI().CheckCurrent(Log)) { if (Global.testingServer.db.tests.getUI().CheckCurrent(Log)) {
target = Global.testingServer.db.tests.getUI().getCurrent(); target = Global.testingServer.db.tests.getUI().getCurrent();

View File

@@ -70,7 +70,7 @@ public class DBProjectFile extends ProjectFile {
Init(file_, father_); Init(file_, father_);
//имя относительно папки проекта. //имя относительно папки проекта.
RefreshName(); RefreshName();
AutoDetectProperties(); AutoDetectProperties(file_.getName());
} }
public static Pair<Integer, String> decodeParserMessage(String S, String file_in) { public static Pair<Integer, String> decodeParserMessage(String S, String file_in) {
Integer line = 1; Integer line = 1;

View File

@@ -8,102 +8,24 @@ import _VisualDVM.ProjectData.LanguageName;
import javax.swing.*; import javax.swing.*;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
//возможно, в дальнейшем унаследовать от него DBProjectFile, но пока лучше не трогать то что работает. public class ProjectFile extends projectFile_ {
public class ProjectFile extends DBObject {
public File file = null; //собственно, файл на который ссылаемся. public File file = null; //собственно, файл на который ссылаемся.
public FileType fileType = FileType.none;
public LanguageName languageName = LanguageName.n;
public LanguageStyle style = LanguageStyle.none;
public FileState state = FileState.Undefined; //состояние файла. public FileState state = FileState.Undefined; //состояние файла.
public ProjectFile() { public ProjectFile() {
} }
public ProjectFile(File file_in) { public ProjectFile(File file_in) {
super(file_in);
file = file_in; file = file_in;
AutoDetectProperties();
} }
@Override @Override
public Object getPK() { public Object getPK() {
return file.getName(); return file.getName();
} }
public void AutoDetectProperties() { @Override
AutoDetectProperties(file.getName());
}
public void AutoDetectProperties(String name_in) { public void AutoDetectProperties(String name_in) {
//проверка запретных имен. super.AutoDetectProperties(name_in);
String[] forbiddenNames = new String[]{ if (fileType.equals(FileType.forbidden) || fileType.equals(FileType.none))
CommonConstants.INTERRUPT, state= FileState.Excluded;
Constants.launch_script_name,
Constants.default_binary_name,
//--
CommonConstants.DONE,
CommonConstants.TIMEOUT,
Constants.out_file,
Constants.err_file,
Constants.time_file,
"Makefile"
};
for (String forbidden : forbiddenNames) {
if (name_in.equalsIgnoreCase(forbidden)) {
fileType = FileType.forbidden;
return;
}
}
//-
switch (Utils_.getExtensionFromName(name_in)) {
case "f":
case "fdv":
case "for":
case "f77":
fileType = FileType.program;
languageName = LanguageName.fortran;
style = LanguageStyle.fixed;
break;
case "f90":
fileType = FileType.program;
languageName = LanguageName.fortran;
style = LanguageStyle.free;
break;
case "c":
case "cdv":
fileType = FileType.program;
languageName = LanguageName.c;
break;
case "cpp":
fileType = FileType.program;
languageName = LanguageName.cpp;
break;
case "h":
fileType = FileType.header;
break;
case "fh":
fileType = FileType.header;
languageName = LanguageName.fortran;
break;
case "o":
case "gcda":
case "gcno":
case "gcov":
case "exe":
case "pdf":
fileType = FileType.forbidden;
break;
case "":
if (Utils_.isIntegerValue(name_in)) {
fileType = FileType.forbidden;
} else {
state = FileState.Excluded;
fileType = FileType.none;
languageName = LanguageName.n;
}
break;
default:
//все остальное считаем исключенными из рассмотрения.
//если юзеру надо сам их разблочит.
state = FileState.Excluded;
fileType = FileType.none;
languageName = LanguageName.n;
break;
}
} }
public String ImageKey() { public String ImageKey() {
//icons/files/Excludeddata.png //icons/files/Excludeddata.png
@@ -130,6 +52,7 @@ public class ProjectFile extends DBObject {
} }
return new ImageIcon(imageUrl); return new ImageIcon(imageUrl);
} }
public String getUnixName() { public String getUnixName() {
return Utils_.toU(file.getName()); return Utils_.toU(file.getName());
} }
@@ -137,23 +60,10 @@ public class ProjectFile extends DBObject {
public String toString() { public String toString() {
return file.getName(); return file.getName();
} }
public String getQSourceName() { public String getQSourceName() {
return Utils_.DQuotes(getUnixName()); return Utils_.DQuotes(getUnixName());
} }
public String getStyleOptions() {
if (languageName == LanguageName.fortran) {
switch (style) {
case fixed:
case extended:
return "-FI";
case free:
return "-f90";
case none:
break;
}
}
return "";
}
public boolean isNotExcludedProgram() { public boolean isNotExcludedProgram() {
return fileType.equals(FileType.program) && !languageName.equals(LanguageName.n) && !state.equals(FileState.Excluded); return fileType.equals(FileType.program) && !languageName.equals(LanguageName.n) && !state.equals(FileState.Excluded);
} }

View File

@@ -0,0 +1,113 @@
package _VisualDVM.ProjectData.Files;
import Common.CommonConstants;
import Common.Database.Objects.DBObject;
import Common.Utils.Utils_;
import _VisualDVM.Constants;
import _VisualDVM.ProjectData.LanguageName;
import java.io.File;
public abstract class projectFile_ extends DBObject {
public FileType fileType = FileType.none;
public LanguageName languageName = LanguageName.n;
public LanguageStyle style = LanguageStyle.none;
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
projectFile_ src_ = (projectFile_) src;
fileType = src_.fileType;
languageName = src_.languageName;
style = src_.style;
}
public projectFile_(){}
public projectFile_(File file_in){
AutoDetectProperties(file_in.getName());
}
public void AutoDetectProperties(String name_in) {
//проверка запретных имен.
String[] forbiddenNames = new String[]{
CommonConstants.INTERRUPT,
Constants.launch_script_name,
Constants.default_binary_name,
//--
CommonConstants.DONE,
CommonConstants.TIMEOUT,
Constants.out_file,
Constants.err_file,
Constants.time_file,
"Makefile"
};
for (String forbidden : forbiddenNames) {
if (name_in.equalsIgnoreCase(forbidden)) {
fileType = FileType.forbidden;
return;
}
}
//-
switch (Utils_.getExtensionFromName(name_in)) {
case "f":
case "fdv":
case "for":
case "f77":
fileType = FileType.program;
languageName = LanguageName.fortran;
style = LanguageStyle.fixed;
break;
case "f90":
fileType = FileType.program;
languageName = LanguageName.fortran;
style = LanguageStyle.free;
break;
case "c":
case "cdv":
fileType = FileType.program;
languageName = LanguageName.c;
break;
case "cpp":
fileType = FileType.program;
languageName = LanguageName.cpp;
break;
case "h":
fileType = FileType.header;
break;
case "fh":
fileType = FileType.header;
languageName = LanguageName.fortran;
break;
case "o":
case "gcda":
case "gcno":
case "gcov":
case "exe":
case "pdf":
fileType = FileType.forbidden;
break;
case "":
if (Utils_.isIntegerValue(name_in)) {
fileType = FileType.forbidden;
} else {
fileType = FileType.none;
languageName = LanguageName.n;
}
break;
default:
fileType = FileType.none;
languageName = LanguageName.n;
break;
}
}
//-
public String getStyleOptions() {
if (languageName == LanguageName.fortran) {
switch (style) {
case fixed:
case extended:
return "-FI";
case free:
return "-f90";
case none:
break;
}
}
return "";
}
}

View File

@@ -1,18 +1,22 @@
package _VisualDVM.ServerObjectsCache; package _VisualDVM.ServerObjectsCache;
import Common.Utils.Utils_; import _VisualDVM.Global;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import java.util.Vector; import java.util.Vector;
public class TestCache extends VisualCache { public class TestCache extends VisualCache {
public String srcNames = ""; public String srcNames = "";
public TestCache(Test object) { public TestCache(Test object) {
Vector<String> names = new Vector<>(); Vector<String> names = new Vector<>();
Vector<TestFile> files = Global.testingServer.db.getVectorByFK(object, TestFile.class);
for (TestFile testFile : files)
names.add(testFile.name);
/*
TestFilesJson json = Utils_.gson.fromJson(object.packedFilesJson, TestFilesJson.class); TestFilesJson json = Utils_.gson.fromJson(object.packedFilesJson, TestFilesJson.class);
for (TestFileJson testJson : json.values) { for (TestFileJson testJson : json.values) {
names.add(testJson.name); names.add(testJson.name);
} }
*/
srcNames = String.join(";", names); srcNames = String.join(";", names);
} }
} }

View File

@@ -86,24 +86,4 @@ public class Group extends riDBObject {
if (UI.isActive()) if (UI.isActive())
Global.mainModule.getUI().getMainWindow().ShowCheckedTestsCount(); Global.mainModule.getUI().getMainWindow().ShowCheckedTestsCount();
} }
public String GenerateMakefile(Test test, String dvm_drv, String flags_in) {
//----->>
LinkedHashMap<LanguageName, Vector<ProjectFile>> programs = test.getPrograms();
Vector<String> titles = new Vector<>();
Vector<String> objects = new Vector<>();
Vector<String> bodies = new Vector<>();
String binary = Utils_.DQuotes("0");
//----->>
generateForLanguage(dvm_drv, programs, language, titles, objects, bodies, flags_in);
//----->>
return String.join("\n",
"LINK_COMMAND=" + Utils_.DQuotes(dvm_drv) + " " +
language.getDVMLink(),
"LINK_FLAGS=" + flags_in + "\n",
String.join("\n", titles),
"all: " + binary,
binary + " : " + String.join(" ", objects),
"\t" + Utils.MFVar("LINK_COMMAND") + " " + Utils.MFVar("LINK_FLAGS") + " " + String.join(" ", objects) + " -o " + binary,
String.join(" ", bodies));
}
} }

View File

@@ -6,16 +6,11 @@ import Common.Utils.Utils_;
import Common.Visual.UI; import Common.Visual.UI;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.All.UnzipFolderPass; import _VisualDVM.Passes.All.UnzipFolderPass;
import _VisualDVM.ProjectData.Files.FileType; import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.ProjectData.LanguageName;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import com.sun.org.glassfish.gmbal.Description; import com.sun.org.glassfish.gmbal.Description;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.File; import java.io.File;
import java.util.LinkedHashMap;
import java.util.Vector; import java.util.Vector;
public class Test extends riDBObject { public class Test extends riDBObject {
@Description("DEFAULT 0") @Description("DEFAULT 0")
@@ -28,13 +23,14 @@ public class Test extends riDBObject {
public int group_id = CommonConstants.Nan; public int group_id = CommonConstants.Nan;
@Description("DEFAULT ''") @Description("DEFAULT ''")
public String extended_description = ""; public String extended_description = "";
@Description("DEFAULT ''") //--для отправки при публикации---------------->>>
public String packedFilesJson = "";
//--------------------------------------------->>>
@Description("IGNORE") @Description("IGNORE")
public String temp_project_name = ""; public String temp_project_name = "";
@Description("IGNORE") @Description("IGNORE")
public byte[] project_archive_bytes = null; public byte[] project_archive_bytes = null;
@Description("IGNORE")
public Vector<TestFile> files = null;
//public String packedFilesJson; //вывести!
//--------------------------------------------->>> //--------------------------------------------->>>
public Test(Test test) { public Test(Test test) {
this.SynchronizeFields(test); this.SynchronizeFields(test);
@@ -50,7 +46,6 @@ public class Test extends riDBObject {
args = t.args; args = t.args;
group_id = t.group_id; group_id = t.group_id;
extended_description = t.extended_description; extended_description = t.extended_description;
packedFilesJson = t.packedFilesJson;
} }
@Override @Override
public void select(boolean flag) { public void select(boolean flag) {
@@ -99,21 +94,11 @@ public class Test extends riDBObject {
//-- //--
return true; return true;
} }
//todo проджект файлы тут не нужны. сделать с учетом джсона public Vector<File> getServerFiles(){
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms() { File path = getServerPath();
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>(); Vector<File> res = new Vector<>();
//-- for (TestFile testFile : Global.testingServer.db.getVectorByFK(this, TestFile.class))
res.put(LanguageName.fortran, new Vector<>()); res.add(new File(path, testFile.name));
res.put(LanguageName.c, new Vector<>());
res.put(LanguageName.cpp, new Vector<>());
//--
TestFilesJson json = Utils_.gson.fromJson(packedFilesJson, TestFilesJson.class);
for (TestFileJson file : json.values) {
//--
if (file.type.equals(FileType.program) &&
(!file.language.equals(LanguageName.n)))
res.get(file.language).add(new ProjectFile(new File(file.name)));
}
return res; return res;
} }
} }

View File

@@ -1,10 +1,17 @@
package _VisualDVM.TestingSystem.Common.Test; package _VisualDVM.TestingSystem.Common.Test;
import Common.Database.Objects.DBObject;
import Common.Database.Tables.FKBehaviour;
import Common.Database.Tables.FKCurrentObjectBehaviuor;
import Common.Database.Tables.FKDataBehaviour;
import Common.Database.Tables.iDBTable; import Common.Database.Tables.iDBTable;
import Common.Visual.DataSetControlForm; import Common.Visual.DataSetControlForm;
import _VisualDVM.Constants;
import _VisualDVM.TestingSystem.Common.Group.Group; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.Test.UI.TestsForm; import _VisualDVM.TestingSystem.Common.Test.UI.TestsForm;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import javax.swing.*; import javax.swing.*;
import java.util.LinkedHashMap;
import java.util.Vector; import java.util.Vector;
public class TestDBTable extends iDBTable<Test> { public class TestDBTable extends iDBTable<Test> {
public TestDBTable() { public TestDBTable() {
@@ -19,6 +26,12 @@ public class TestDBTable extends iDBTable<Test> {
return "тесты"; return "тесты";
} }
@Override @Override
public LinkedHashMap<Class<? extends DBObject>, FKBehaviour> getFKDependencies() {
LinkedHashMap<Class<? extends DBObject>, FKBehaviour> res = new LinkedHashMap<>();
res.put(TestFile.class, new FKBehaviour(FKDataBehaviour.DELETE, FKCurrentObjectBehaviuor.ACTIVE));
return res;
}
@Override
protected DataSetControlForm createUI(JPanel mountPanel) { protected DataSetControlForm createUI(JPanel mountPanel) {
return new TestsForm(this, mountPanel); return new TestsForm(this, mountPanel);
} }
@@ -29,9 +42,9 @@ public class TestDBTable extends iDBTable<Test> {
} }
return false; return false;
} }
public Test getTestByDescription(int group_id_in, String description_in) { public Test getStandardTestByDescription(int group_id_in, String description_in) {
for (Test test : Data.values()) { for (Test test : Data.values()) {
if (test.sender_address.equals("vmk-post@yandex.ru") && if (test.sender_address.equals(Constants.MailAddress) &&
(test.group_id == group_id_in) && (test.description.equalsIgnoreCase(description_in))) (test.group_id == group_id_in) && (test.description.equalsIgnoreCase(description_in)))
return test; return test;
} }
@@ -49,18 +62,4 @@ public class TestDBTable extends iDBTable<Test> {
} }
return selectedTests.isEmpty() ? allTests : selectedTests; return selectedTests.isEmpty() ? allTests : selectedTests;
} }
/*
public LinkedHashMap<Integer,Test> getGroupTests(Group group){
Vector<Test> res = new Vector<>();
for (Test test: Data.values()){
if (test.group_id==group.id){
res.add(test);
}
}
return res;
}
*/
} }

View File

@@ -0,0 +1,45 @@
package _VisualDVM.TestingSystem.Common.TestFile;
import Common.CommonConstants;
import Common.Database.Objects.DBObject;
import _VisualDVM.ProjectData.Files.projectFile_;
import _VisualDVM.TestingSystem.Common.Test.Test;
import com.google.gson.annotations.Expose;
import com.sun.org.glassfish.gmbal.Description;
import java.io.File;
public class TestFile extends projectFile_ {
@Expose
@Description("PRIMARY KEY,AUTOINCREMENT")
public int id;
public int test_id = CommonConstants.Nan;
public String name; //имя относительно корневой папки проекта. не ключ.
@Override
public Object getPK() {
return id;
}
@Override
public Object getEmptyFK() {
return CommonConstants.Nan;
}
@Override
public void SynchronizeFields(DBObject src) {
super.SynchronizeFields(src);
TestFile src_ = (TestFile) src;
id = src_.id;
test_id = src_.test_id;
name = src_.name;
}
public TestFile() {
}
public TestFile(Test test) {
test_id = test.id;
}
public TestFile(File file_in){
super(file_in);
name = file_in.getName();
}
public TestFile(Test test, File file_in){
this(file_in);
test_id = test.id;
}
}

View File

@@ -0,0 +1,7 @@
package _VisualDVM.TestingSystem.Common.TestFile;
import Common.Database.Tables.DBTable;
public class TestFilesDBTable extends DBTable<Integer,TestFile> {
public TestFilesDBTable() {
super(Integer.class,TestFile.class);
}
}

View File

@@ -28,6 +28,7 @@ import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson; import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.Test.TestType; import _VisualDVM.TestingSystem.Common.Test.TestType;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill; import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration; import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage; import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
@@ -86,6 +87,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
@Override @Override
public void StartAction() throws Exception { public void StartAction() throws Exception {
try { try {
//--
// db.Patch();
//--
machines_db = new MachinesDatabase(); machines_db = new MachinesDatabase();
machines_db.Activate(); machines_db.Activate();
} catch (Exception ex) { } catch (Exception ex) {
@@ -107,6 +111,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
+ "\nТест будет удален" + "\nТест будет удален"
); );
} }
db.saveTestFiles(test);
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test); db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
} else if (object instanceof DVMPackage) { } else if (object instanceof DVMPackage) {
DVMPackage dvmPackage = (DVMPackage) object; DVMPackage dvmPackage = (DVMPackage) object;
@@ -176,6 +181,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
if (object instanceof Test) { if (object instanceof Test) {
Test test = (Test) object; Test test = (Test) object;
Utils_.forceDeleteWithCheck(test.getServerPath()); Utils_.forceDeleteWithCheck(test.getServerPath());
db.DeleteTestFiles(test);
//-- //--
for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) { for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) {
if (dvmConfiguration.tryDeleteTest(test)) { if (dvmConfiguration.tryDeleteTest(test)) {
@@ -208,6 +214,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
for (Test group_test : groupTests.values()) { for (Test group_test : groupTests.values()) {
db.Delete(group_test); db.Delete(group_test);
Utils_.forceDeleteWithCheck(group_test.getServerPath()); Utils_.forceDeleteWithCheck(group_test.getServerPath());
db.DeleteTestFiles(group_test);
} }
//-- //--
} else if (object instanceof ServerSapfor) { } else if (object instanceof ServerSapfor) {
@@ -276,6 +283,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
int max_installed_version = db.getInstalledSapforMaxVersion(); int max_installed_version = db.getInstalledSapforMaxVersion();
if (max_installed_version == current_version) if (max_installed_version == current_version)
throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена"); throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена");
ServerSapfor serverSapfor = (ServerSapfor) object;
serverSapfor.version = String.valueOf(current_version);
} }
} }
@Override @Override
@@ -301,7 +310,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
} }
ServerSapfor sapfor = db.serverSapfors.get(sapforId); ServerSapfor sapfor = db.serverSapfors.get(sapforId);
TextLog Log = new TextLog(); TextLog Log = new TextLog();
SapforPackage autoPackage = tryAutoSapforTesting(sapfor,Log); SapforPackage autoPackage = tryAutoSapforTesting(sapfor, Log);
EmailMessage message = Log.isEmpty() ? EmailMessage message = Log.isEmpty() ?
new EmailMessage( new EmailMessage(
"Запущено автоматическое тестирование версии " + sapfor.version + " системы SAPFOR", "Запущено автоматическое тестирование версии " + sapfor.version + " системы SAPFOR",
@@ -478,34 +487,30 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
else else
throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id); throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id);
} }
void ReplaceTestCode() throws Exception { void replaceTestCode(Test test, ServerSapfor serverSapfor) throws Exception {
Test test = (Test) request.object;
if (!test.unpackProjectOnServer()) {
db.Delete(test);
throw new RepositoryRefuseException(
"Не удалось прикрепить проект к тесту с id " + test.id
+ "\nТест будет удален"
);
} else {
db.Update(test);
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
}
}
void ReplaceTestsCodes() throws Exception {
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
Vector<Test> tests = (Vector<Test>) request.object;
for (Test test : tests) {
if (!test.unpackProjectOnServer()) { if (!test.unpackProjectOnServer()) {
db.Delete(test); db.Delete(test);
db.DeleteTestFiles(test);
throw new RepositoryRefuseException( throw new RepositoryRefuseException(
"Не удалось прикрепить проект к тесту с id " + test.id "Не удалось прикрепить проект к тесту с id " + test.id
+ "\nТест будет удален" + "\nТест будет удален"
); );
} else { } else {
db.Update(test); db.Update(test);
//--
db.DeleteTestFiles(test);
db.saveTestFiles(test);
//--
db.DetectTestMinMaxDim(serverSapfor, db.groups.get(test.group_id), test); db.DetectTestMinMaxDim(serverSapfor, db.groups.get(test.group_id), test);
} }
} }
void ReplaceTestCode() throws Exception {
replaceTestCode((Test) request.object, db.serverSapfors.getLastDoneVersion());
}
void ReplaceTestsCodes() throws Exception {
ServerSapfor serverSapfor = db.serverSapfors.getLastDoneVersion();
for (Test test : (Vector<Test>) request.object)
replaceTestCode(test, serverSapfor);
} }
void GetServerName() throws Exception { void GetServerName() throws Exception {
response.object = name; response.object = name;
@@ -592,7 +597,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
void GetSapforForCompilation() throws Exception { void GetSapforForCompilation() throws Exception {
//1. Проверить наличие заказов от пользователя //1. Проверить наличие заказов от пользователя
ServerSapfor serverSapfor = db.getSapforCopyForCompilation(); ServerSapfor serverSapfor = db.getSapforCopyForCompilation();
if (serverSapfor == null) { if (serverSapfor == null) {
//2 если нет. проверить есть ли свежие версии. //2 если нет. проверить есть ли свежие версии.
int max_version = db.getInstalledSapforMaxVersion(); int max_version = db.getInstalledSapforMaxVersion();
@@ -716,12 +720,19 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
Test test = new Test(); Test test = new Test();
test.group_id = group.id; test.group_id = group.id;
test.description = name; test.description = name;
test.packedFilesJson = Utils_.gson.toJson(filesJson);
test.sender_address = group.sender_address; test.sender_address = group.sender_address;
test.sender_name = group.sender_name; test.sender_name = group.sender_name;
test.extended_description = descriptions.get(name); test.extended_description = descriptions.get(name);
db.Insert(test); db.Insert(test);
//--- //---
Vector<TestFile> testFiles = new Vector<>();
for (File file : files)
testFiles.add(new TestFile(test, file));
db.BeginTransaction();
for (TestFile testFile : testFiles)
db.Insert(testFile);
db.Commit();
//---
File testProject = new File(Global.TestsDirectory, String.valueOf(test.id)); File testProject = new File(Global.TestsDirectory, String.valueOf(test.id));
//--- //---
if (testProject.exists()) if (testProject.exists())

View File

@@ -7,16 +7,15 @@ import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
import _VisualDVM.Constants; import _VisualDVM.Constants;
import _VisualDVM.Global; import _VisualDVM.Global;
import _VisualDVM.Passes.PassCode; import _VisualDVM.Passes.PassCode;
import _VisualDVM.ProjectData.Files.ProjectFile;
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
import _VisualDVM.ServerObjectsCache.VisualCaches; import _VisualDVM.ServerObjectsCache.VisualCaches;
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
import _VisualDVM.TestingSystem.Common.Group.Group; import _VisualDVM.TestingSystem.Common.Group.Group;
import _VisualDVM.TestingSystem.Common.Group.GroupsDBTable; import _VisualDVM.TestingSystem.Common.Group.GroupsDBTable;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson; import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson; import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
import _VisualDVM.TestingSystem.Common.Test.Test; import _VisualDVM.TestingSystem.Common.Test.Test;
import _VisualDVM.TestingSystem.Common.Test.TestDBTable; import _VisualDVM.TestingSystem.Common.Test.TestDBTable;
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
import _VisualDVM.TestingSystem.Common.TestFile.TestFilesDBTable;
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable; import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration; import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfigurationDBTable; import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfigurationDBTable;
@@ -44,6 +43,7 @@ import java.util.Vector;
public class TestsDatabase extends SQLiteDatabase { public class TestsDatabase extends SQLiteDatabase {
public DVMConfigurationDBTable dvmConfigurations; public DVMConfigurationDBTable dvmConfigurations;
public TestDBTable tests; public TestDBTable tests;
public TestFilesDBTable testsFiles;
public GroupsDBTable groups; public GroupsDBTable groups;
public DVMPackageDBTable dvmPackages; public DVMPackageDBTable dvmPackages;
public SapforPackageDBTable sapforPackages; public SapforPackageDBTable sapforPackages;
@@ -67,6 +67,7 @@ public class TestsDatabase extends SQLiteDatabase {
addTable(dvmConfigurations = new DVMConfigurationDBTable()); addTable(dvmConfigurations = new DVMConfigurationDBTable());
addTable(groups = new GroupsDBTable()); addTable(groups = new GroupsDBTable());
addTable(tests = new TestDBTable()); addTable(tests = new TestDBTable());
addTable(testsFiles = new TestFilesDBTable());
addTable(dvmPackages = new DVMPackageDBTable()); addTable(dvmPackages = new DVMPackageDBTable());
addTable(sapforPackages = new SapforPackageDBTable()); addTable(sapforPackages = new SapforPackageDBTable());
addTable(testingPackagesToKill = new TestingPackagesToKillDBTable()); addTable(testingPackagesToKill = new TestingPackagesToKillDBTable());
@@ -189,28 +190,25 @@ public class TestsDatabase extends SQLiteDatabase {
break; break;
} }
} }
public void SaveTestFromSingleFile(ServerSapfor sapfor, Group group, Test test, File file) throws Exception { public void importTestFile(Test test, File file) throws Exception {
File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id)); File testDirectory = new File(Global.TestsDirectory, String.valueOf(test.id));
Utils_.CheckAndCleanDirectory(testDirectory); Utils_.CheckAndCleanDirectory(testDirectory);
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile(); File dst = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
FileUtils.copyFile(file, testFile); FileUtils.copyFile(file, dst);
//----
DetectTestMinMaxDim(sapfor, group, test);
} }
//---
//---
public void CreateTestFromSingleFile(UserAccount account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception { public void CreateTestFromSingleFile(UserAccount account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
Test test = new Test(); Test test = new Test();
test.description = testDescription; test.description = testDescription;
test.sender_name = account.name; test.sender_name = account.name;
test.sender_address = account.email; test.sender_address = account.email;
test.group_id = group.id; test.group_id = group.id;
TestFilesJson testFilesJson = new TestFilesJson();
testFilesJson.values.add(new TestFileJson(new ProjectFile(file)));
test.packedFilesJson = Utils_.gson.toJson(testFilesJson);
Insert(test); Insert(test);
//->> //->>
SaveTestFromSingleFile(sapfor, group, test, file); importTestFile(test, file);
TestFile testFile = new TestFile(test,file);
Insert(testFile);
//--
DetectTestMinMaxDim(sapfor, group, test);
} }
public void RefreshGroup(UserAccount account, ServerSapfor sapfor, Pair<Group, Vector<File>> groupData) throws Exception { public void RefreshGroup(UserAccount account, ServerSapfor sapfor, Pair<Group, Vector<File>> groupData) throws Exception {
Group group = groupData.getKey(); Group group = groupData.getKey();
@@ -226,11 +224,11 @@ public class TestsDatabase extends SQLiteDatabase {
} else { } else {
for (File file : files) { for (File file : files) {
String testDescription = Utils_.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile(); String testDescription = Utils_.getNameWithoutExtension(file.getName()) + "_" + group.language.getDVMCompile();
Test oldTest = tests.getTestByDescription(oldGroup.id, testDescription); Test oldTest = tests.getStandardTestByDescription(oldGroup.id, testDescription);
if (oldTest == null) { if (oldTest == null) {
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription); CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
} else { } else {
SaveTestFromSingleFile(sapfor, group, oldTest, file); importTestFile(oldTest, file);
} }
} }
} }
@@ -348,4 +346,41 @@ public class TestsDatabase extends SQLiteDatabase {
dvmSettings.ShowUI(); dvmSettings.ShowUI();
super.ResetUI(); super.ResetUI();
} }
public void saveTestFiles(Test test) throws Exception{
for (TestFile file : test.files) {
file.test_id = test.id;
Insert(file);
}
test.files = null;
}
public void DeleteTestFiles(Test test) throws Exception {
Vector<TestFile> files = getVectorByFK(test, TestFile.class);
for (TestFile file : files)
Delete(file);
}
public void Patch() throws Exception{
//файлы тестов.
/*
Vector<TestFile> testFiles = new Vector<>();
for (Test test:tests.Data.values()){
TestFilesJson json = Utils_.gson.fromJson(test.packedFilesJson, TestFilesJson.class);
for (TestFileJson testFileJson: json.values){
TestFile testFile = new TestFile();
//-
testFile.test_id = test.id;
testFile.name = testFileJson.name;
testFile.style = testFileJson.style;
testFile.languageName = testFileJson.language;
testFile.fileType= testFileJson.type;
//--
testFiles.add(testFile);
}
}
BeginTransaction();
for (TestFile testFile: testFiles){
Insert(testFile);
}
Commit();
*/
}
} }

View File

@@ -1,84 +0,0 @@
package _VisualDVM.TestingSystem.DVM;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
public class LocalDVMTestingPlanner extends DVMTestingPlanner {
public LocalDVMTestingPlanner(String[] args) {
super(args);
}
@Override
protected boolean CheckModules() throws Exception {
/*
File modulesDirectory = Paths.get(user.workspace, "modules").toFile();
File version = new File(modulesDirectory,"version.h");
int current_version = Constants.Nan;
int actual_version = Constants.planner_version;
///--
if (version.exists()) {
try {
current_version = Integer.parseInt(FileUtils.readFileToString(version));
} catch (Exception ex) {
ex.printStackTrace();
}
}
else {
}
if (current_version < actual_version) {
Print("Закачка кода модулей...");
for (String resource_name : Constants.resourses_names) {
Print(resource_name);
File src = Utils.CreateTempResourceFile(resource_name);
File dst = new File(modulesDirectory, resource_name);
FileUtils.copyFile(src, dst);
}
//--
Print("Сборка модулей...");
String modules_log = user.connection.compileModules(modulesDirectory);
if (!modules_log.isEmpty()) {
testingPackage.description = modules_log;
testingPackage.state = TasksPackageState.Aborted;
return false;
}
}
*/
return true;
}
@Override
public String packageDescription() {
return "DVM";
}
@Override
protected void TestsSynchronize() throws Exception {
testingPackage.readJson();
LinkedHashMap<Integer, File> tests = getTestsFromJson();
//синхронизировать их.
for (int test_id : tests.keySet()) {
File test = tests.get(test_id);
File testDst = Paths.get(testingPackage.user_workspace, "projects", String.valueOf(test_id)).toFile();
Print(testDst.getAbsolutePath());
FileUtils.copyDirectory(test, testDst);
}
Finalize("+");
}
@Override
protected void PackageWorkspaceCreation() throws Exception {
}
@Override
protected void AnalyseResults() throws Exception {
}
@Override
protected void PackageStart() throws Exception {
}
@Override
protected boolean CheckNextState() throws Exception {
return false;
}
@Override
protected void DownloadResults() throws Exception {
}
@Override
protected void Kill() throws Exception {
}
}