Wstęp

Parametry systemu pozwalają na zmianę specyficznych zachowań systemu (zależnie od wybranego parametru) oraz tworzeniu nowych własnych parametrów możliwych do podglądu i zmiany z poziomu Java API lub interfejsu użytkownika. Zapisywane są w bazie danych i są docelowym miejscem przeniesienia parametrów aktualnie konfigurowanych w pliku systemowym. Ze względu na to iż system często wymaga pobrania parametrów, przetrzymywane są one w cache'u. Niewskazane jest więc zmienianie parametrów bezpośrednio w bazie danych.

Każdy z parametrów posiada własny typ. Możliwe typy to:

  • datowy - przechowywany w bazie jako typ datowy. Jeżeli nie istnieje w bazie, odczytywany z pliku w formacie yyyy-MM-dd
  • tekstowy - tekst do 4000 znaków
  • całkowity - odpowiednik typu Long
  • zmiennoprzecinkowy - odpowiednik typu Double
  • logicznytrue lub false
  • combobox - wiele wartości tekstowych możliwych do pobrania
  • hasło - zaszyfrowany w bazie tekst. Jeżeli parametr nie istnieje w bazie, odczytywany jest jako zwykły tekst z pliku

Parametry w GUI mogą mieć własne tłumaczenia. Graficznie dla kategorii parametru jest to tekst umieszczony obok klucza kategorii. Dla parametru jest to tekst w tooltipie wyświetlanym przy najechaniu kursorem na klucz parametru. Aby ustawić własne tłumaczenie parametru lub kategorii, należy w jakimkolwiek translatorze wdrożeniowym dodać wpis, gdzie klucz tłumaczenia jest identyczny do klucza kategorii lub parametru.

Powiązane klasy

  1.  - klasa umożliwiająca szybkie pobieranie parametrów systemowych. Jeżeli parametr nie istnieje w bazie danych, zostanie zwrócona jego wartość z pliku konfiguracyjnego systemu
  2.  - serwis (finder) umożliwiający wyszukiwanie parametrów w systemie
  3.  - serwis umożliwiający bezpośrednią zmianę/tworzenie/usuwanie parametrów w bazie danych
  4.  - enum, w którym zawarte są wszystkie parametry przeniesione z pliku konfiguracyjnego do bazy

Przykłady użycia

Klasa ta została stworzona, aby nie korzystać bezpośrednio z propertiesów udostępnionych przez Sharka. Poniżej przykłady użycia

// "Dawne" pobieranie parametrów z pliku Sharka
String value = Shark.getInstance().getProperties().getProperty( key );
  
// "Nowe" pobieranie parametrów
// Jeżeli parametr nie istnieje w bazie, zadziała identycznie, jak powyższy kod. Jeżeli parametr istnieje w bazie, zostanie z niej pobrany.
String value = SystemProperties.getString( key ); // możliwe podanie typów: String (dla typu tekstowego, comboboxa oraz hasła), Date (format yyyy-MM-dd), Long, Boolean
Date dateValue = SystemProperties.getDate( key ); // pobranie parametru datowego, format yyyy-MM-dd
String decryptedPassword = SystemProperties.getPassword( key ); // pobranie parametru hasłowego (parametr jest zaszyfrowany w bazie)
  
// Pobranie parametru podając wartość domyślną
String value = SystemProperties.getString( key, "wartoscDomyslna");
Boolean booleanParam = SystemProperties.getBoolean( key, false );
  
// Pobranie parametru przeniesionego z pliku konfiguracyjnego do bazy
String value = SystemProperties.getString( DefinedSystemParameter.UNIVERSAL_PASSWORD ); // Jeżeli istnieje w bazie, zostanie z niej pobrany. Jeżeli nie - zostanie pobrany z pliku konfiguracyjnego.
                                                                                        // Jeżeli nie istnieje w pliku, zwrócona zostanie wartość domyślna (taka, jak w domyślnym pliku konfiguracyjnym).

Finder stworzony do wyszukiwania wszystkich parametrów, wszystkich kategorii, wszystkich parametrów w kategorii oraz parametrów według filtrów. Przykłady użycia:

SystemParameterFinder finder = FinderFactory.getSystemParameterFinder();
List<Category> categories = finder.getAllCategories(); // wyszukanie wszystkich kategorii
 
List<SystemParameter> params = finder.findByCategory( "General" ); // wyszukanie wszystkich parametrów dla kategorii "General"

Serwis stworzony do tworzenia, zmiany i usuwania parametrów na poziomie bazy danych. Przykłady użycia:

Category category = new Category( "ExampleCategory" ); // stworzenie encji kategorii
SystemParameter parameter = new SystemParameter( category, ParameterType.BOOLEAN, "ExampleKey" ); // stworzenie encji parametru
parameter.setValue( true ); // ustawienie wartości
        
SystemParameterService service = ServiceFactory.getSystemParameterService();
service.create( parameter ); // stworzneie parametru
parameter.setValue( false );
service.update( parameter ); // aktualizacja parametru
        
SystemParameter parameter2 = service.getParameter( "ExampleSecondParameterKey" ); // pobranie parametru
service.delete( parameter.getKey() ); // usunięcie parametru

Introduction

System parameters allow you to change specific system behavior (depending on the selected parameter) and create new custom parameters that can be viewed and changed from the Java API or user interface. They are stored in the database and are the destination for transferring parameters currently configured in the system file. Due to the fact that the system often requires downloading parameters, they are kept in the cache. So it is inadvisable to change parameters directly in the database.

Each parameter has its own type. Possible types are:

  • date - stored in the database as a date type. If it does not exist in the database, read from a file in the format yyyy-MM-dd

  • text - text up to 4000 characters

  • integer - equivalent to Long type

  • floating-point - equivalent to Double type

  • boolean - true or false

  • combobox - multiple text values possible to retrieve

  • password - text encrypted in the database. If the parameter does not exist in the database, it is read as plain text from a file

Parameters in the GUI can have their own translations. Graphically, for a parameter category, it is the text next to the category key. For a parameter, it is the text in the tooltip displayed when the cursor hovers over the parameter key. To set your own translation for a parameter or category, add an entry in any implementation translator where the translation key is identical to the category or parameter key.

Related classes

  1.  - a class that allows quick retrieval of system parameters. If the parameter does not exist in the database, its value will be returned from the system configuration file
  2.  - a service (finder) that allows searching for parameters in the system
  3.  - a service that allows direct change/creation/deletion of parameters in the database
  4.  - enum, which contains all parameters transferred from the configuration file to the database

Examples of use

This class was created to not directly use properties provided by Shark. Below are examples of usage

// "Old" parameter retrieval from Shark file
String value = Shark.getInstance().getProperties().getProperty( key );
  
// "NEW" parameter retrieval
// If the parameter does not exist in the database, it will work identically to the above code. If the parameter exists in the database, it will be retrieved from it.
String value = SystemProperties.getString( key ); // possible types specified: String (for text type, combobox and password), Date (format yyyy-MM-dd), Long, Boolean
Date dateValue = SystemProperties.getDate( key ); // pobranie parametru datowego, format yyyy-MM-dd
String decryptedPassword = SystemProperties.getPassword( key ); // retrieve date parameter, format yyyy-MM-dd
  
// Retrieve a parameter by specifying a default value
String value = SystemProperties.getString( key, "wartoscDomyslna");
Boolean booleanParam = SystemProperties.getBoolean( key, false );
  
// Retrieve the parameter transferred from the configuration file to the database
String value = SystemProperties.getString( DefinedSystemParameter.UNIVERSAL_PASSWORD ); // If there is in the database, it will be retrieved from it. If not, it will be retrieved from the configuration file.
                                                                                        // If it does not exist in the file, a default value will be returned (as in the default configuration file).

Finder created to search all parameters, all categories, all parameters in a category and parameters by filters. Examples of use:

SystemParameterFinder finder = FinderFactory.getSystemParameterFinder();
List<Category> categories = finder.getAllCategories(); // search for all categories
 
List<SystemParameter> params = finder.findByCategory( "General" ); // search for all parameters for the category "General"

A service created to create, change and delete parameters at the database level. Examples of use:

Category category = new Category( "ExampleCategory" ); // creation of category entities
SystemParameter parameter = new SystemParameter( category, ParameterType.BOOLEAN, "ExampleKey" ); // creation of parameter entities
parameter.setValue( true ); // values setting
        
SystemParameterService service = ServiceFactory.getSystemParameterService();
service.create( parameter ); // create parameter
parameter.setValue( false );
service.update( parameter ); // update parameter
        
SystemParameter parameter2 = service.getParameter( "ExampleSecondParameterKey" ); // get parameter
service.delete( parameter.getKey() ); // delete parameter