Skip to end of metadata
Go to start of metadata

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. SystemProperties - 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. SystemParameterFinder - a service (finder) that allows searching for parameters in the system
  3. SystemParameterService - a service that allows direct change/creation/deletion of parameters in the database
  4. DefinedSystemParameter - 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

  • No labels