Class FWDatabaseFormComponentFiller

java.lang.Object
net.simplace.pipe.filler.FWAbstractFormComponentFiller
net.simplace.pipe.filler.FWDatabaseFormComponentFiller

public class FWDatabaseFormComponentFiller extends FWAbstractFormComponentFiller
Form component filler that reads data from a database. The content is the JDBC Connection, the key is an SQL statement ('' is replaced by '). It generates
  • form options (columns: label, value, optional image name); default statement SELECT DESC_<locale>,JUMP FROM INITIAL WHERE THEME = 'INITIAL'
  • charts; a chart style can be appended to the statement as &&<chart style>
  • objects (the result set positioned on the first row)
  • field lists for dynamic forms (columns TYPE, ID, NAME, REQUIRED, ENABLED, MINIMUM, MAXIMUM, DEFAULT, LIST)
Parameters: formFiller.localizationKeyPrefix (localises option labels), formFiller.jdbctranspose (false to not transpose category/XY datasets).
Author:
Andreas Enders
  • Field Details

    • iLocalizationKeyPrefix

      protected String iLocalizationKeyPrefix
      prefix of localisation keys for option labels (parameter formFiller.localizationKeyPrefix)
  • Constructor Details

    • FWDatabaseFormComponentFiller

      public FWDatabaseFormComponentFiller()
  • Method Details

    • initialize

      public void initialize(Object aContent, Map<String,Object> aParameterMap, net.simplace.core.FWObservable aObservable, String aSystemID, org.jdom2.Element aConfiguration)
      Initialises the filler and reads the localisation key prefix; has to be called after instantiation by class name.
      Overrides:
      initialize in class FWAbstractFormComponentFiller
      Parameters:
      aContent - the JDBC connection
      aParameterMap - parameters configuring the filler
      aObservable - parameters of the functionality, used as fallback
      aSystemID - id of the system the form belongs to
      aConfiguration - optional configuration element, or null
    • generateFormOptions

      protected Vector<FWFormOption> generateFormOptions(String aKey)
      Creates options from the rows of the statement: column 1 = label, column 2 = value, optional column 3 = image name (images larger than 50 pixels are scaled down).
      Specified by:
      generateFormOptions in class FWAbstractFormComponentFiller
      Parameters:
      aKey - SQL statement, or null for the default statement
      Returns:
      the options; empty if the statement fails (only logged at debug level)
    • generateChart

      protected org.jfree.chart.JFreeChart generateChart(String aKey, ChartStyle aChartStyle)
      Creates a chart from the result of the statement.
      Specified by:
      generateChart in class FWAbstractFormComponentFiller
      Parameters:
      aKey - SQL statement, optionally followed by &&<chart style>
      aChartStyle - default style of the chart
      Returns:
      the chart, or null if no style or dataset is available (warning is logged)
    • generateObject

      protected Object generateObject(String aKey)
      Executes the statement.
      Specified by:
      generateObject in class FWAbstractFormComponentFiller
      Parameters:
      aKey - SQL statement
      Returns:
      the result set positioned on the first row (the caller has to close its statement, see FWAbstractFormComponentFiller.getObject(String, String)), or null if it is empty or the statement fails (error is logged)
    • generateFieldList

      protected List<org.jdom2.Element> generateFieldList(String aKey)
      Creates form field elements from the rows of the statement: TYPE INTEGER, DOUBLE, LIST/MULTILIST (options from the comma-separated column LIST) or text for other types; further columns ID, NAME, REQUIRED, ENABLED, MINIMUM, MAXIMUM, DEFAULT.
      Specified by:
      generateFieldList in class FWAbstractFormComponentFiller
      Parameters:
      aKey - SQL statement
      Returns:
      the field elements, or null if the statement fails (error is logged)