смена имен бд тестов на актуальные. удаление старых при запуске

This commit is contained in:
2023-11-14 20:08:19 +03:00
parent 9c5414f477
commit c1c56621c2
9 changed files with 49 additions and 20 deletions

11
.idea/workspace.xml generated
View File

@@ -6,7 +6,16 @@
</artifacts-to-build>
</component>
<component name="ChangeListManager">
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="" />
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/src/Common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Constants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Common/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Common/Global.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Repository/Component/Component.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Repository/Component/Component.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TasksDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TasksDatabase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingPlanner.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingPlanner.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestingServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/TestingSystem/TestsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/TestingSystem/TestsDatabase.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/RepositoryPass.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Visual_DVM_2021/Passes/RepositoryPass.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />

View File

@@ -58,7 +58,18 @@ public class Constants {
public static final String attachments = "attachments";
public static final String statistic = "statistic";
public static final String unknown_metric = "";
public static final String old_tests_db_name = "tests2023";
public static final String tests_db_name = "tests2024";
public static final String dateNaN = "NaN";
//пробный коммит. изменение комментария.++
//кронтаб и перезагрузка
//https://snipp.ru/raznoe/crontab
// /var/spool/cron/crontabs/testuser что менять
//https://saribzhanov.ru/tehno/perezagruzka-ubuntu-po-cron/ //раз в сутки
//testuser ALL=NOPASSWD:/sbin/reboot
//0 2 2,15 * * reboot &>/var/log/reboot.log
//https://unix.stackexchange.com/questions/117148/how-can-i-run-reboot-as-a-normal-user-without-needing-to-enter-a-password
public static final String ServerAddress = "alex-freenas.ddns.net";
//--
//https://losst.ru/komandy-terminala-linux
public static String[] linux_system_commands = new String[]{

View File

@@ -25,16 +25,6 @@ import java.io.File;
import java.nio.file.Paths;
import java.util.Vector;
public class Global {
//пробный коммит. изменение комментария.++
//кронтаб и перезагрузка
//https://snipp.ru/raznoe/crontab
// /var/spool/cron/crontabs/testuser что менять
//https://saribzhanov.ru/tehno/perezagruzka-ubuntu-po-cron/ //раз в сутки
//testuser ALL=NOPASSWD:/sbin/reboot
//0 2 2,15 * * reboot &>/var/log/reboot.log
//https://unix.stackexchange.com/questions/117148/how-can-i-run-reboot-as-a-normal-user-without-needing-to-enter-a-password
public static final String ServerAddress = "alex-freenas.ddns.net";
public static final String dateNaN = "NaN";
//--------------------------------------------------
//текущая папка системы. в отличие от шарпа никогда не должна меняться.
public static final String components = "Components";
@@ -248,8 +238,25 @@ public class Global {
return String.join("|", res_);
}
//--
public static void removeOldDatabases() {
File data = Paths.get(System.getProperty("user.dir"), "Data").toFile();
File[] files = data.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().contains(Constants.old_tests_db_name)) {
System.out.println("found "+Utils.Brackets(file.getAbsolutePath()));
try {
Utils.forceDeleteWithCheck(file);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
public static void NormalMode(int port) throws Exception {
isWindows = System.getProperty("os.name").startsWith("Windows");
removeOldDatabases();
CheckVisualiserDirectories();
CreateLog();
//-

View File

@@ -13,7 +13,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
public abstract class Component extends DBObject implements Loggable {
public String date_text = Global.dateNaN;
public String date_text = Constants.dateNaN;
public long version = Constants.Nan;
public long actual_version = Constants.Nan;
public long minimal_version = Constants.Nan;

View File

@@ -1,4 +1,5 @@
package TestingSystem;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import Common.Global;
import GlobalData.Settings.SettingName;
@@ -23,7 +24,6 @@ import java.sql.PreparedStatement;
import java.util.LinkedHashMap;
import java.util.Vector;
public class TasksDatabase extends SQLiteDatabase {
public static final String tests_db_name = "tests2023";
public TSettingsDBTable settings;
public TasksPackageDBTable packages;
public TasksPackageToKillDBTable packagesToKill;
@@ -35,13 +35,13 @@ public class TasksDatabase extends SQLiteDatabase {
public SapforTasksDBTable sapforTasks;
//---------
public TasksDatabase(String email) {
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + tests_db_name + ".sqlite").toFile());
super(Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + Constants.tests_db_name + ".sqlite").toFile());
}
public TasksDatabase(File file_in) {
super(file_in);
}
public void setFile(String email) {
file = Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + tests_db_name + ".sqlite").toFile();
file = Paths.get(Global.DataDirectory.getAbsolutePath(), email + "_" + Constants.tests_db_name + ".sqlite").toFile();
}
@Override
protected void initAllTables() throws Exception {

View File

@@ -25,7 +25,7 @@ import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Vector;
import static TestingSystem.TasksDatabase.tests_db_name;
import static Common.Constants.tests_db_name;
public class TestingPlanner {
public String email;
TasksPackage tasksPackage;

View File

@@ -46,7 +46,7 @@ import java.util.LinkedHashMap;
import java.util.Vector;
import java.util.stream.Collectors;
import static TestingSystem.TasksDatabase.tests_db_name;
import static Common.Constants.tests_db_name;
public class TestingServer extends RepositoryServer<TestsDatabase> {
LinkedHashMap<String, TasksDatabase> accountsBases = new LinkedHashMap<>();
//--------------------------------->>>

View File

@@ -1,4 +1,5 @@
package TestingSystem;
import Common.Constants;
import Common.Database.SQLITE.SQLiteDatabase;
import GlobalData.Settings.SettingName;
import SapforTestingSystem.SapforConfiguration.SapforConfigurationDBTable;
@@ -22,7 +23,7 @@ public class TestsDatabase extends SQLiteDatabase {
//----
public ServerSapforsDBTable serverSapfors;
public TestsDatabase() {
super(Paths.get(System.getProperty("user.dir"), "Data", TasksDatabase.tests_db_name + ".sqlite").toFile());
super(Paths.get(System.getProperty("user.dir"), "Data", Constants.tests_db_name + ".sqlite").toFile());
}
@Override
protected void initAllTables() throws Exception {

View File

@@ -1,4 +1,5 @@
package Visual_DVM_2021.Passes;
import Common.Constants;
import Common.Global;
import Common.Utils.Utils;
import Repository.RepositoryRefuseException;
@@ -33,7 +34,7 @@ public abstract class RepositoryPass<S extends RepositoryServer, T> extends Pass
}
//-
protected void connect() throws Exception {
clientSocket = Utils.createClientSocket(InetAddress.getByName(Global.ServerAddress),
clientSocket = Utils.createClientSocket(InetAddress.getByName(Constants.ServerAddress),
server.getPort(),
getTimeout()
);