упразднение старого объекта аккаунта

This commit is contained in:
2025-02-18 20:14:14 +03:00
parent 794097f81f
commit 1b4b375f39
28 changed files with 135 additions and 193 deletions

View File

@@ -1,70 +0,0 @@
package _VisualDVM.GlobalData.Account;
import Common.Database.Objects.DBObject;
import Common.Utils.TextLog;
import _VisualDVM.ComponentsServer.BugReport.BugReport;
import _VisualDVM.Global;
import com.sun.org.glassfish.gmbal.Description;
public class Account extends DBObject {
@Description("PRIMARY KEY,NOT NULL")
public int id = 0;
public String name = "?";
public String email = "?";
//--
@Description("IGNORE")
public AccountRole role = AccountRole.Undefined; //роль незареганного пользователя
//--
public boolean CheckRegistered(TextLog Log) {
if (role.equals(AccountRole.Undefined)) {
if (Log != null) {
Log.Writeln("Пользователь не зарегистрирован");
if (Global.mainModule.getUI().hasMainWindow())
Global.mainModule.getUI().getMainWindow().FocusCallback();
}
return false;
}
return true;
}
public boolean isRegistered() {
return !role.equals(AccountRole.Undefined);
}
public boolean CheckAuthorship(String address_in, TextLog log) {
if (!isAdmin() && (!email.equals(address_in))) {
if (log != null)
log.Writeln_("Вы не являетесь автором или администратором");
return false;
}
return true;
}
public boolean CheckAccessRights(String address_in, TextLog log) {
return (CheckRegistered(log) && CheckAuthorship(address_in, log));
}
public boolean ExtendedCheckAccessRights(BugReport bugReport, TextLog log) {
if (CheckRegistered(log)) {
if (email.equals(bugReport.executor_address)) {
//метод вывести как нерабочий.когда будет изменена схема админства.
return true;
} else {
if (!isAdmin() && (!email.equals(bugReport.sender_address))) {
log.Writeln_("Вы не являетесь автором, исполнителем, или администратором");
return false;
} else return true;
}
}
return false;
}
public boolean isAdmin() {
return role.equals(AccountRole.Admin);
}
public boolean CheckAdmin(TextLog log) {
if (!isAdmin()) {
log.Writeln_("Вы не являетесь администратором!");
return false;
}
return true;
}
@Override
public Object getPK() {
return id;
}
}

View File

@@ -1,23 +0,0 @@
package _VisualDVM.GlobalData.Account;
import java.io.Serializable;
public enum AccountRole implements Serializable {
Undefined,
User,
Developer,
Admin;
public String getDescription() {
switch (this) {
case Undefined:
return "не зарегистрирован";
case User:
return "Пользователь";
case Developer:
return "Разработчик";
case Admin:
return "Администратор";
default:
break;
}
return "";
}
}

View File

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

View File

@@ -4,8 +4,6 @@ import Common.Database.VisualiserDatabase;
import Common.MainModule_;
import _VisualDVM.Current;
import _VisualDVM.Global;
import _VisualDVM.GlobalData.Account.Account;
import _VisualDVM.GlobalData.Account.AccountsDBTable;
import _VisualDVM.GlobalData.Compiler.Compiler;
import _VisualDVM.GlobalData.Compiler.CompilersDBTable;
import _VisualDVM.GlobalData.DBLastProject.LastProjectsDBTable;
@@ -43,7 +41,6 @@ public class GlobalDatabase extends VisualiserDatabase {
public DVMParameterDBTable dvmParameters;
//----- ДАННЫЕ ВИЗУАЛИЗАТОРА---------------------------------
public LastProjectsDBTable lastProjects;
public AccountsDBTable accounts;
//-
public SapforProfilesDBTable sapforProfiles = null;
//---------
@@ -65,7 +62,6 @@ public class GlobalDatabase extends VisualiserDatabase {
addTable(runConfigurations = new RunConfigurationsDBTable());
addTable(environmentValues = new EnvironmentValuesDBTable());
addTable(lastProjects = new LastProjectsDBTable());
addTable(accounts = new AccountsDBTable());
addTable(dvmParameters = new DVMParameterDBTable());
addTable(sapforProfiles = new SapforProfilesDBTable());
addTable(sapforProfilesSettings = new SapforProfileSettingsDBTable());
@@ -73,10 +69,6 @@ public class GlobalDatabase extends VisualiserDatabase {
//---------------------------------------------------------------------------------
@Override
public void Init() throws Exception {
Global.mainModule.set(Current.Account,
accounts.Data.isEmpty() ? Insert(new Account()) :
accounts.getFirstRecord()
);
//настройки компонент
runConfigurations.Patch();
//---