++
рефакторинг бд файлов тестов.
This commit is contained in:
@@ -318,6 +318,21 @@ public abstract class Database {
|
||||
prepareTablesStatements();
|
||||
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() {
|
||||
SaveLastSelections();
|
||||
}
|
||||
|
||||
@@ -35,18 +35,7 @@ public abstract class DeleteObjectPass<D extends DBObject> extends ObjectPass<D>
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
getDb().Delete(target);
|
||||
for (Class dep : getTable().getFKDependencies().keySet()) {
|
||||
switch (getTable().getFKDependencies().get(dep).data) {
|
||||
case NONE:
|
||||
break;
|
||||
case DROP:
|
||||
getDb().DropByFK(target, dep);
|
||||
break;
|
||||
case DELETE:
|
||||
getDb().DeleteByFK(target, dep);
|
||||
break;
|
||||
}
|
||||
}
|
||||
getDb().DeleteDependencies(target);
|
||||
}
|
||||
//тут именно на финише, чтобы в любом случае вся таблица всегда была видна.
|
||||
@Override
|
||||
|
||||
@@ -12,9 +12,8 @@ import _VisualDVM.Passes.Sapfor.SapforAnalysis;
|
||||
import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.Files.UI.Editor.SPFEditor;
|
||||
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.TestFile.TestFile;
|
||||
import _VisualDVM.Utils;
|
||||
import javafx.util.Pair;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@@ -393,15 +392,9 @@ public abstract class Sapfor extends OSDComponent {
|
||||
test.max_dim = res.getValue();
|
||||
}
|
||||
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 max_dim = 0;
|
||||
for (File file : files) {
|
||||
for (File file : test.getServerFiles()) {
|
||||
max_dim = Math.max(max_dim, getFileMaxDim_C(file));
|
||||
}
|
||||
test.min_dim = min_dim;
|
||||
|
||||
@@ -3,7 +3,7 @@ import Common.Utils.Vector_;
|
||||
|
||||
import java.util.Vector;
|
||||
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 testingMaxKernels = 64;
|
||||
//--
|
||||
|
||||
@@ -6,11 +6,9 @@ import Common.Visual.Windows.Dialog.VDirectoryChooser;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
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.TestFile.TestFile;
|
||||
import _VisualDVM.Utils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
@@ -23,7 +21,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
|
||||
boolean from_files_chooser = false;
|
||||
Vector<File> files = null;
|
||||
//--
|
||||
Vector<ProjectFile> project_files = new Vector<>();
|
||||
Vector<TestFile> testFiles = new Vector<>();
|
||||
@Override
|
||||
public String getIconPath() {
|
||||
return "/icons/OpenProject.png";
|
||||
@@ -106,7 +104,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
|
||||
return false;
|
||||
}
|
||||
//---
|
||||
project_files = new Vector<>();
|
||||
testFiles = new Vector<>();
|
||||
//--
|
||||
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())) {
|
||||
//если файл. все недопустимые файлы просто игнорируются.
|
||||
ProjectFile projectFile = new ProjectFile(file);
|
||||
if (isNotExcluded(projectFile)) {
|
||||
switch (projectFile.fileType) {
|
||||
TestFile testFile = new TestFile(file);
|
||||
if (isNotExcluded(testFile)) {
|
||||
switch (testFile.fileType) {
|
||||
case program:
|
||||
if (projectFile.languageName.equals(group.language)) {
|
||||
if (testFile.languageName.equals(group.language)) {
|
||||
active_programs++;
|
||||
project_files.add(projectFile);
|
||||
testFiles.add(testFile);
|
||||
} else
|
||||
other_project_files++;
|
||||
break;
|
||||
case header:
|
||||
headers++;
|
||||
project_files.add(projectFile);
|
||||
testFiles.add(testFile);
|
||||
break;
|
||||
case none:
|
||||
project_files.add(projectFile);
|
||||
testFiles.add(testFile);
|
||||
other_project_files++;
|
||||
break;
|
||||
default:
|
||||
@@ -153,7 +151,7 @@ public class CreateTestFromDirectory extends Pass<Test> {
|
||||
Log.Writeln_("Папка не содержит ни одной программы на языке " + group.language.getDescription() + ".");
|
||||
return false;
|
||||
}
|
||||
if (project_files.isEmpty()) {
|
||||
if (testFiles.isEmpty()) {
|
||||
Log.Writeln_("В папке не найдено файлов с допустимыми расширениями для языка " +
|
||||
group.language.getDescription() + "\n" +
|
||||
group.language.PrintExtensions()
|
||||
@@ -162,16 +160,10 @@ public class CreateTestFromDirectory extends Pass<Test> {
|
||||
//----
|
||||
if (!initTarget()) return false;
|
||||
//----
|
||||
TestFilesJson filesJson = new TestFilesJson();
|
||||
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);
|
||||
target.files = new Vector<>(testFiles);
|
||||
return true;
|
||||
}
|
||||
public boolean isNotExcluded(ProjectFile projectFile) {
|
||||
public boolean isNotExcluded(TestFile testFile) {
|
||||
return true;
|
||||
}
|
||||
//-
|
||||
@@ -183,10 +175,13 @@ public class CreateTestFromDirectory extends Pass<Test> {
|
||||
//- создать бд.
|
||||
FileUtils.forceMkdir(tempProject);
|
||||
//--
|
||||
for (ProjectFile projectFile : project_files) {
|
||||
File dst = new File(tempProject, projectFile.file.getName());
|
||||
FileUtils.copyFile(projectFile.file, dst);
|
||||
for (TestFile testFile : testFiles) {
|
||||
File src = new File(dir, testFile.name);
|
||||
File dst = new File(tempProject, testFile.name);
|
||||
FileUtils.copyFile(src, dst);
|
||||
}
|
||||
target.files = new Vector<>();
|
||||
target.files.addAll(testFiles);
|
||||
//---
|
||||
Utils.ClearProjectData(tempProject);
|
||||
//--
|
||||
|
||||
@@ -4,19 +4,19 @@ import Common.Passes.PassException;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.ProjectData.Files.FileType;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
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.TestFile.TestFile;
|
||||
import _VisualDVM.Utils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
public class CreateTestFromFile extends Pass<Test> {
|
||||
//----
|
||||
Group group;
|
||||
ProjectFile projectFile;
|
||||
TestFile testFile;
|
||||
File file;
|
||||
//----
|
||||
@Override
|
||||
protected boolean needsAnimation() {
|
||||
@@ -32,20 +32,20 @@ public class CreateTestFromFile extends Pass<Test> {
|
||||
}
|
||||
@Override
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
projectFile = null;
|
||||
File file_in = (File) args[0];
|
||||
testFile = null;
|
||||
file = (File) args[0];
|
||||
group = (Group) args[1];
|
||||
//--
|
||||
if (Utils_.ContainsCyrillic(file_in.getName()) || Utils_.ContainsForbiddenName(file_in.getName())) {
|
||||
Log.Writeln_("Имя файла " + Utils_.Brackets(file_in.getName())
|
||||
if (Utils_.ContainsCyrillic(file.getName()) || Utils_.ContainsForbiddenName(file.getName())) {
|
||||
Log.Writeln_("Имя файла " + Utils_.Brackets(file.getName())
|
||||
+ " содержит запрещённые символы " +
|
||||
Utils_.printAllForbiddenCharacters() + ", или кириллицу.");
|
||||
return false;
|
||||
}
|
||||
//--
|
||||
projectFile = new ProjectFile(file_in);
|
||||
if (!projectFile.fileType.equals(FileType.program) || !projectFile.languageName.equals(group.language)) {
|
||||
Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file_in.getName()) +
|
||||
testFile = new TestFile(file);
|
||||
if (!testFile.fileType.equals(FileType.program) || !testFile.languageName.equals(group.language)) {
|
||||
Log.Writeln_("Не удалось распознать файл " + Utils_.Brackets(file.getName()) +
|
||||
" как программу на языке " + group.language.getDescription());
|
||||
return false;
|
||||
}
|
||||
@@ -54,10 +54,10 @@ public class CreateTestFromFile extends Pass<Test> {
|
||||
target.sender_address = Global.mainModule.getAccount().email;
|
||||
target.sender_name = Global.mainModule.getAccount().name;
|
||||
target.group_id = group.id;
|
||||
target.description = Utils_.getNameWithoutExtension(file_in.getName());
|
||||
TestFilesJson filesJson = new TestFilesJson();
|
||||
filesJson.values.add(new TestFileJson(new ProjectFile(file_in)));
|
||||
target.packedFilesJson = Utils_.gson.toJson(filesJson);
|
||||
target.description = Utils_.getNameWithoutExtension(file.getName());
|
||||
target.files = new Vector<>();
|
||||
target.files.add(testFile);
|
||||
//--
|
||||
return true;
|
||||
}
|
||||
public File packTestCode() throws Exception {
|
||||
@@ -68,8 +68,8 @@ public class CreateTestFromFile extends Pass<Test> {
|
||||
//- создать бд.
|
||||
FileUtils.forceMkdir(tempProject);
|
||||
//--
|
||||
File dst = new File(tempProject, projectFile.file.getName());
|
||||
FileUtils.copyFile(projectFile.file, dst);
|
||||
File dst = new File(tempProject, testFile.name);
|
||||
FileUtils.copyFile(file, dst);
|
||||
//---
|
||||
Utils.ClearProjectData(tempProject);
|
||||
//--
|
||||
@@ -81,7 +81,7 @@ public class CreateTestFromFile extends Pass<Test> {
|
||||
}
|
||||
@Override
|
||||
protected void body() throws Exception {
|
||||
ShowMessage1(projectFile.file.getName());
|
||||
ShowMessage1(testFile.name);
|
||||
packTestCode();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ package _VisualDVM.Passes.All;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.ProjectData.Files.FileState;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.Project.db_project_info;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
//добавить в текущую группу новый тест из текущего проекта.
|
||||
public class CreateTestFromProject extends CreateTestFromDirectory {
|
||||
db_project_info project;
|
||||
@@ -37,8 +37,8 @@ public class CreateTestFromProject extends CreateTestFromDirectory {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isNotExcluded(ProjectFile projectFile) {
|
||||
return project.db.files.containsKey(projectFile.file.getName()) &&
|
||||
!project.db.files.get(projectFile.file.getName()).state.equals(FileState.Excluded);
|
||||
public boolean isNotExcluded(TestFile testFile) {
|
||||
return project.db.files.containsKey(testFile.name) &&
|
||||
!project.db.files.get(testFile.name).state.equals(FileState.Excluded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import _VisualDVM.Passes.Server.TestingServerPass;
|
||||
import _VisualDVM.Repository.Server.ServerCode;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
|
||||
import java.io.Serializable;
|
||||
//заменить текущий тест на текущий проект.
|
||||
@@ -27,6 +28,12 @@ public class ReplaceTestProject extends CreateTestFromProject {
|
||||
Global.mainModule.getPass(PassCode.SynchronizeTests).Do();
|
||||
}
|
||||
@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 {
|
||||
if (Global.testingServer.db.tests.getUI().CheckCurrent(Log)) {
|
||||
target = Global.testingServer.db.tests.getUI().getCurrent();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class DBProjectFile extends ProjectFile {
|
||||
Init(file_, father_);
|
||||
//имя относительно папки проекта.
|
||||
RefreshName();
|
||||
AutoDetectProperties();
|
||||
AutoDetectProperties(file_.getName());
|
||||
}
|
||||
public static Pair<Integer, String> decodeParserMessage(String S, String file_in) {
|
||||
Integer line = 1;
|
||||
|
||||
@@ -8,102 +8,24 @@ import _VisualDVM.ProjectData.LanguageName;
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
//возможно, в дальнейшем унаследовать от него DBProjectFile, но пока лучше не трогать то что работает.
|
||||
public class ProjectFile extends DBObject {
|
||||
public class ProjectFile extends projectFile_ {
|
||||
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 ProjectFile() {
|
||||
}
|
||||
public ProjectFile(File file_in) {
|
||||
super(file_in);
|
||||
file = file_in;
|
||||
AutoDetectProperties();
|
||||
}
|
||||
@Override
|
||||
public Object getPK() {
|
||||
return file.getName();
|
||||
}
|
||||
public void AutoDetectProperties() {
|
||||
AutoDetectProperties(file.getName());
|
||||
}
|
||||
@Override
|
||||
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 {
|
||||
state = FileState.Excluded;
|
||||
fileType = FileType.none;
|
||||
languageName = LanguageName.n;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//все остальное считаем исключенными из рассмотрения.
|
||||
//если юзеру надо сам их разблочит.
|
||||
state = FileState.Excluded;
|
||||
fileType = FileType.none;
|
||||
languageName = LanguageName.n;
|
||||
break;
|
||||
}
|
||||
super.AutoDetectProperties(name_in);
|
||||
if (fileType.equals(FileType.forbidden) || fileType.equals(FileType.none))
|
||||
state= FileState.Excluded;
|
||||
}
|
||||
public String ImageKey() {
|
||||
//icons/files/Excludeddata.png
|
||||
@@ -130,6 +52,7 @@ public class ProjectFile extends DBObject {
|
||||
}
|
||||
return new ImageIcon(imageUrl);
|
||||
}
|
||||
|
||||
public String getUnixName() {
|
||||
return Utils_.toU(file.getName());
|
||||
}
|
||||
@@ -137,23 +60,10 @@ public class ProjectFile extends DBObject {
|
||||
public String toString() {
|
||||
return file.getName();
|
||||
}
|
||||
|
||||
public String getQSourceName() {
|
||||
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() {
|
||||
return fileType.equals(FileType.program) && !languageName.equals(LanguageName.n) && !state.equals(FileState.Excluded);
|
||||
}
|
||||
|
||||
113
src/_VisualDVM/ProjectData/Files/projectFile_.java
Normal file
113
src/_VisualDVM/ProjectData/Files/projectFile_.java
Normal 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 "";
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,22 @@
|
||||
package _VisualDVM.ServerObjectsCache;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Test;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
|
||||
import java.util.Vector;
|
||||
public class TestCache extends VisualCache {
|
||||
public String srcNames = "";
|
||||
public TestCache(Test object) {
|
||||
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);
|
||||
for (TestFileJson testJson : json.values) {
|
||||
names.add(testJson.name);
|
||||
}
|
||||
*/
|
||||
srcNames = String.join(";", names);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,24 +86,4 @@ public class Group extends riDBObject {
|
||||
if (UI.isActive())
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,11 @@ import Common.Utils.Utils_;
|
||||
import Common.Visual.UI;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.All.UnzipFolderPass;
|
||||
import _VisualDVM.ProjectData.Files.FileType;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ProjectData.LanguageName;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestFileJson;
|
||||
import _VisualDVM.TestingSystem.Common.Test.Json.TestFilesJson;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class Test extends riDBObject {
|
||||
@Description("DEFAULT 0")
|
||||
@@ -28,13 +23,14 @@ public class Test extends riDBObject {
|
||||
public int group_id = CommonConstants.Nan;
|
||||
@Description("DEFAULT ''")
|
||||
public String extended_description = "";
|
||||
@Description("DEFAULT ''")
|
||||
public String packedFilesJson = "";
|
||||
//--------------------------------------------->>>
|
||||
//--для отправки при публикации---------------->>>
|
||||
@Description("IGNORE")
|
||||
public String temp_project_name = "";
|
||||
@Description("IGNORE")
|
||||
public byte[] project_archive_bytes = null;
|
||||
@Description("IGNORE")
|
||||
public Vector<TestFile> files = null;
|
||||
//public String packedFilesJson; //вывести!
|
||||
//--------------------------------------------->>>
|
||||
public Test(Test test) {
|
||||
this.SynchronizeFields(test);
|
||||
@@ -50,7 +46,6 @@ public class Test extends riDBObject {
|
||||
args = t.args;
|
||||
group_id = t.group_id;
|
||||
extended_description = t.extended_description;
|
||||
packedFilesJson = t.packedFilesJson;
|
||||
}
|
||||
@Override
|
||||
public void select(boolean flag) {
|
||||
@@ -99,21 +94,11 @@ public class Test extends riDBObject {
|
||||
//--
|
||||
return true;
|
||||
}
|
||||
//todo проджект файлы тут не нужны. сделать с учетом джсона
|
||||
public LinkedHashMap<LanguageName, Vector<ProjectFile>> getPrograms() {
|
||||
LinkedHashMap<LanguageName, Vector<ProjectFile>> res = new LinkedHashMap<>();
|
||||
//--
|
||||
res.put(LanguageName.fortran, new Vector<>());
|
||||
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)));
|
||||
}
|
||||
public Vector<File> getServerFiles(){
|
||||
File path = getServerPath();
|
||||
Vector<File> res = new Vector<>();
|
||||
for (TestFile testFile : Global.testingServer.db.getVectorByFK(this, TestFile.class))
|
||||
res.add(new File(path, testFile.name));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
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.Visual.DataSetControlForm;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Test.UI.TestsForm;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class TestDBTable extends iDBTable<Test> {
|
||||
public TestDBTable() {
|
||||
@@ -19,6 +26,12 @@ public class TestDBTable extends iDBTable<Test> {
|
||||
return "тесты";
|
||||
}
|
||||
@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) {
|
||||
return new TestsForm(this, mountPanel);
|
||||
}
|
||||
@@ -29,9 +42,9 @@ public class TestDBTable extends iDBTable<Test> {
|
||||
}
|
||||
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()) {
|
||||
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)))
|
||||
return test;
|
||||
}
|
||||
@@ -49,18 +62,4 @@ public class TestDBTable extends iDBTable<Test> {
|
||||
}
|
||||
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;
|
||||
}
|
||||
*/
|
||||
}
|
||||
45
src/_VisualDVM/TestingSystem/Common/TestFile/TestFile.java
Normal file
45
src/_VisualDVM/TestingSystem/Common/TestFile/TestFile.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ 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.TestType;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackageToKill;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
@@ -86,6 +87,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
@Override
|
||||
public void StartAction() throws Exception {
|
||||
try {
|
||||
//--
|
||||
// db.Patch();
|
||||
//--
|
||||
machines_db = new MachinesDatabase();
|
||||
machines_db.Activate();
|
||||
} catch (Exception ex) {
|
||||
@@ -107,6 +111,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
}
|
||||
db.saveTestFiles(test);
|
||||
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
|
||||
} else if (object instanceof DVMPackage) {
|
||||
DVMPackage dvmPackage = (DVMPackage) object;
|
||||
@@ -176,6 +181,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
if (object instanceof Test) {
|
||||
Test test = (Test) object;
|
||||
Utils_.forceDeleteWithCheck(test.getServerPath());
|
||||
db.DeleteTestFiles(test);
|
||||
//--
|
||||
for (DVMConfiguration dvmConfiguration : db.dvmConfigurations.Data.values()) {
|
||||
if (dvmConfiguration.tryDeleteTest(test)) {
|
||||
@@ -208,6 +214,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
for (Test group_test : groupTests.values()) {
|
||||
db.Delete(group_test);
|
||||
Utils_.forceDeleteWithCheck(group_test.getServerPath());
|
||||
db.DeleteTestFiles(group_test);
|
||||
}
|
||||
//--
|
||||
} else if (object instanceof ServerSapfor) {
|
||||
@@ -276,6 +283,8 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
int max_installed_version = db.getInstalledSapforMaxVersion();
|
||||
if (max_installed_version == current_version)
|
||||
throw new RepositoryRefuseException("Актуальная версия SAPFOR " + max_installed_version + " уже установлена");
|
||||
ServerSapfor serverSapfor = (ServerSapfor) object;
|
||||
serverSapfor.version = String.valueOf(current_version);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@@ -301,7 +310,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
}
|
||||
ServerSapfor sapfor = db.serverSapfors.get(sapforId);
|
||||
TextLog Log = new TextLog();
|
||||
SapforPackage autoPackage = tryAutoSapforTesting(sapfor,Log);
|
||||
SapforPackage autoPackage = tryAutoSapforTesting(sapfor, Log);
|
||||
EmailMessage message = Log.isEmpty() ?
|
||||
new EmailMessage(
|
||||
"Запущено автоматическое тестирование версии " + sapfor.version + " системы SAPFOR",
|
||||
@@ -478,34 +487,30 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
else
|
||||
throw new RepositoryRefuseException("Не удалось заархивировать пакет тестирования SAPFOR с ключом " + sapforPackage_id);
|
||||
}
|
||||
void ReplaceTestCode() throws Exception {
|
||||
Test test = (Test) request.object;
|
||||
void replaceTestCode(Test test, ServerSapfor serverSapfor) throws Exception {
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
db.DeleteTestFiles(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else {
|
||||
db.Update(test);
|
||||
db.DetectTestMinMaxDim(db.serverSapfors.getLastDoneVersion(), db.groups.get(test.group_id), test);
|
||||
//--
|
||||
db.DeleteTestFiles(test);
|
||||
db.saveTestFiles(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();
|
||||
Vector<Test> tests = (Vector<Test>) request.object;
|
||||
for (Test test : tests) {
|
||||
if (!test.unpackProjectOnServer()) {
|
||||
db.Delete(test);
|
||||
throw new RepositoryRefuseException(
|
||||
"Не удалось прикрепить проект к тесту с id " + test.id
|
||||
+ "\nТест будет удален"
|
||||
);
|
||||
} else {
|
||||
db.Update(test);
|
||||
db.DetectTestMinMaxDim(serverSapfor, db.groups.get(test.group_id), test);
|
||||
}
|
||||
}
|
||||
for (Test test : (Vector<Test>) request.object)
|
||||
replaceTestCode(test, serverSapfor);
|
||||
}
|
||||
void GetServerName() throws Exception {
|
||||
response.object = name;
|
||||
@@ -592,7 +597,6 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
void GetSapforForCompilation() throws Exception {
|
||||
//1. Проверить наличие заказов от пользователя
|
||||
ServerSapfor serverSapfor = db.getSapforCopyForCompilation();
|
||||
|
||||
if (serverSapfor == null) {
|
||||
//2 если нет. проверить есть ли свежие версии.
|
||||
int max_version = db.getInstalledSapforMaxVersion();
|
||||
@@ -716,12 +720,19 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
|
||||
Test test = new Test();
|
||||
test.group_id = group.id;
|
||||
test.description = name;
|
||||
test.packedFilesJson = Utils_.gson.toJson(filesJson);
|
||||
test.sender_address = group.sender_address;
|
||||
test.sender_name = group.sender_name;
|
||||
test.extended_description = descriptions.get(name);
|
||||
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));
|
||||
//---
|
||||
if (testProject.exists())
|
||||
|
||||
@@ -7,16 +7,15 @@ import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
import _VisualDVM.ProjectData.Files.ProjectFile;
|
||||
import _VisualDVM.ServerObjectsCache.ConfigurationCache;
|
||||
import _VisualDVM.ServerObjectsCache.VisualCaches;
|
||||
import _VisualDVM.TestingSystem.Common.Configuration.Configuration;
|
||||
import _VisualDVM.TestingSystem.Common.Group.Group;
|
||||
import _VisualDVM.TestingSystem.Common.Group.GroupsDBTable;
|
||||
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.TestDBTable;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFile;
|
||||
import _VisualDVM.TestingSystem.Common.TestFile.TestFilesDBTable;
|
||||
import _VisualDVM.TestingSystem.Common.TestingPackageToKill.TestingPackagesToKillDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfigurationDBTable;
|
||||
@@ -44,6 +43,7 @@ import java.util.Vector;
|
||||
public class TestsDatabase extends SQLiteDatabase {
|
||||
public DVMConfigurationDBTable dvmConfigurations;
|
||||
public TestDBTable tests;
|
||||
public TestFilesDBTable testsFiles;
|
||||
public GroupsDBTable groups;
|
||||
public DVMPackageDBTable dvmPackages;
|
||||
public SapforPackageDBTable sapforPackages;
|
||||
@@ -67,6 +67,7 @@ public class TestsDatabase extends SQLiteDatabase {
|
||||
addTable(dvmConfigurations = new DVMConfigurationDBTable());
|
||||
addTable(groups = new GroupsDBTable());
|
||||
addTable(tests = new TestDBTable());
|
||||
addTable(testsFiles = new TestFilesDBTable());
|
||||
addTable(dvmPackages = new DVMPackageDBTable());
|
||||
addTable(sapforPackages = new SapforPackageDBTable());
|
||||
addTable(testingPackagesToKill = new TestingPackagesToKillDBTable());
|
||||
@@ -189,28 +190,25 @@ public class TestsDatabase extends SQLiteDatabase {
|
||||
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));
|
||||
Utils_.CheckAndCleanDirectory(testDirectory);
|
||||
File testFile = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
|
||||
FileUtils.copyFile(file, testFile);
|
||||
//----
|
||||
DetectTestMinMaxDim(sapfor, group, test);
|
||||
File dst = Paths.get(testDirectory.getAbsolutePath(), file.getName()).toFile();
|
||||
FileUtils.copyFile(file, dst);
|
||||
}
|
||||
//---
|
||||
//---
|
||||
public void CreateTestFromSingleFile(UserAccount account, ServerSapfor sapfor, Group group, File file, String testDescription) throws Exception {
|
||||
Test test = new Test();
|
||||
test.description = testDescription;
|
||||
test.sender_name = account.name;
|
||||
test.sender_address = account.email;
|
||||
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);
|
||||
//->>
|
||||
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 {
|
||||
Group group = groupData.getKey();
|
||||
@@ -226,11 +224,11 @@ public class TestsDatabase extends SQLiteDatabase {
|
||||
} else {
|
||||
for (File file : files) {
|
||||
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) {
|
||||
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
|
||||
CreateTestFromSingleFile(account, sapfor, oldGroup, file, testDescription);
|
||||
} else {
|
||||
SaveTestFromSingleFile(sapfor, group, oldTest, file);
|
||||
importTestFile(oldTest, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,4 +346,41 @@ public class TestsDatabase extends SQLiteDatabase {
|
||||
dvmSettings.ShowUI();
|
||||
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();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user