commit 2cdd3adce420bcaea93c3e508169dd7fadf46950
Author: mlinha <mlinha@students.zcu.cz>
Date:   Fri Apr 24 15:42:19 2020 +0200

    re #7881 loading and editing parameters in configuration in their locations, ability to set user name of parameter

diff --git a/src/main/java/vldc/aswi/domain/Assembly.java b/src/main/java/vldc/aswi/domain/Assembly.java
index 54c965f7..0474383d 100644
--- a/src/main/java/vldc/aswi/domain/Assembly.java
+++ b/src/main/java/vldc/aswi/domain/Assembly.java
@@ -64,4 +64,9 @@ public class Assembly extends EntityParent {
         this.setOrder(order);
         this.setIsPublic(isPublic);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Configuration.java b/src/main/java/vldc/aswi/domain/Configuration.java
index d3e74615..58f68216 100644
--- a/src/main/java/vldc/aswi/domain/Configuration.java
+++ b/src/main/java/vldc/aswi/domain/Configuration.java
@@ -29,12 +29,12 @@ public class Configuration extends EntityParent {
     private String tableName;
 
     /** Specific user, which created this configuration. */
-    @ManyToOne(fetch= FetchType.LAZY)
+    @ManyToOne(fetch= FetchType.EAGER)
     @JoinColumn(name = "uzivatel_id")
     private User user;
 
     /** Used assembly as template in configuration. */
-    @ManyToOne(fetch= FetchType.LAZY)
+    @ManyToOne(fetch= FetchType.EAGER)
     @JoinColumn(name = "sestava_id")
     private Assembly assembly;
 
@@ -52,4 +52,9 @@ public class Configuration extends EntityParent {
         this.setName(name);
         this.setTableName(tableName);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/EntityParent.java b/src/main/java/vldc/aswi/domain/EntityParent.java
index 4cdd38bb..3bf8cc0e 100644
--- a/src/main/java/vldc/aswi/domain/EntityParent.java
+++ b/src/main/java/vldc/aswi/domain/EntityParent.java
@@ -18,4 +18,9 @@ public class EntityParent {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Function.java b/src/main/java/vldc/aswi/domain/Function.java
index cf3f4544..78aadc1d 100644
--- a/src/main/java/vldc/aswi/domain/Function.java
+++ b/src/main/java/vldc/aswi/domain/Function.java
@@ -39,4 +39,9 @@ public class Function extends EntityParent {
     public Function(String name) {
         this.setName(name);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Location.java b/src/main/java/vldc/aswi/domain/Location.java
index 3c59687c..d26a9a20 100644
--- a/src/main/java/vldc/aswi/domain/Location.java
+++ b/src/main/java/vldc/aswi/domain/Location.java
@@ -40,4 +40,9 @@ public class Location extends EntityParent {
     public Location(String name) {
         this.setName(name);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Operator.java b/src/main/java/vldc/aswi/domain/Operator.java
index 5320f5c5..409defa4 100644
--- a/src/main/java/vldc/aswi/domain/Operator.java
+++ b/src/main/java/vldc/aswi/domain/Operator.java
@@ -40,4 +40,9 @@ public class Operator extends EntityParent {
     public Operator(String name) {
         this.setName(name);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Role.java b/src/main/java/vldc/aswi/domain/Role.java
index 9c1e3fb4..53abf8fb 100644
--- a/src/main/java/vldc/aswi/domain/Role.java
+++ b/src/main/java/vldc/aswi/domain/Role.java
@@ -39,4 +39,9 @@ public class Role extends EntityParent {
         this.setName(name);
     }
 
+    @Override
+    public String toString() {
+        return "";
+    }
+
 }
diff --git a/src/main/java/vldc/aswi/domain/User.java b/src/main/java/vldc/aswi/domain/User.java
index 15c191d9..f4e4e41d 100644
--- a/src/main/java/vldc/aswi/domain/User.java
+++ b/src/main/java/vldc/aswi/domain/User.java
@@ -44,4 +44,9 @@ public class User extends EntityParent {
         this.setUsername(username);
         this.setPassword(password);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
\ No newline at end of file
diff --git a/src/main/java/vldc/aswi/domain/parameter/Parameter.java b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
index 8fd1a45e..fff45147 100644
--- a/src/main/java/vldc/aswi/domain/parameter/Parameter.java
+++ b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
@@ -93,4 +93,9 @@ public class Parameter extends EntityParent {
         this.setNameOfSelect(nameOfSelect);
         this.setDefaultValue(defaultValue);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
index a2f707eb..eb6eabd3 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
@@ -25,7 +25,7 @@ public class ParameterInConfiguration extends EntityParent {
     private Configuration configuration;
 
     /** Specific parameter of configuration, which is used as template. */
-    @ManyToOne(fetch=FetchType.LAZY)
+    @ManyToOne(fetch=FetchType.EAGER)
     @JoinColumn(name = "parametr_id")
     private Parameter parameter;
 
@@ -68,4 +68,9 @@ public class ParameterInConfiguration extends EntityParent {
         this.setOperatorValue(operatorValue);
         this.setColumnName(columnName);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
index 947b2773..699511f9 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
@@ -34,4 +34,9 @@ public class ParameterType extends EntityParent {
     public ParameterType(String name) {
         this.setName(name);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
index 6fd29f74..e7526111 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
@@ -32,4 +32,9 @@ public class ParameterValue extends EntityParent {
     public ParameterValue(String value) {
         this.setValue(value);
     }
+
+    @Override
+    public String toString() {
+        return "";
+    }
 }
diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 71ea2a07..5867242f 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -92,14 +92,7 @@ public class AssemblyController {
 
         Configuration configuration = configurationManager.getConfigurationById(Long.parseLong(id));
 
-        for(ParameterInConfiguration parameterInConfiguration : configuration.getParametersInConfiguration()) {
-            if(parameterInConfiguration.getLocation() == null) {
-                parameterInConfiguration.setLocation(new Location());
-            }
-            if(parameterInConfiguration.getOperator() == null) {
-                parameterInConfiguration.setOperator(new Operator());
-            }
-        }
+        initializeFields(configuration);
 
         modelMap.addAttribute("configuration", configuration);
         modelMap.addAttribute("isAssembly", "0");
@@ -127,21 +120,13 @@ public class AssemblyController {
 
         Configuration configuration = configurationManager.saveConfiguration(newConfiguration, id);
 
-        for(ParameterInConfiguration parameterInConfiguration : configuration.getParametersInConfiguration()) {
-            if(parameterInConfiguration.getLocation() == null) {
-                parameterInConfiguration.setLocation(new Location());
-            }
-            if(parameterInConfiguration.getOperator() == null) {
-                parameterInConfiguration.setOperator(new Operator());
-            }
-        }
+        initializeFields(configuration);
 
         modelAndView.setViewName("redirect:/configuration?configurationID=" + configuration.getId());
 
         return modelAndView;
     }
 
-
     @PostMapping("/assembly")
     public ModelAndView indexPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) {
         ModelAndView modelAndView = new ModelAndView();
@@ -173,4 +158,22 @@ public class AssemblyController {
 
         return modelAndView;
     }
+
+    /**
+     * Initializes fields of a given configuration
+     * @param configuration configuration which fields should be initialized
+     */
+    private void initializeFields(Configuration configuration) {
+        for(ParameterInConfiguration parameterInConfiguration : configuration.getParametersInConfiguration()) {
+            if(parameterInConfiguration.getLocation() == null) {
+                parameterInConfiguration.setLocation(new Location());
+            }
+            if(parameterInConfiguration.getOperator() == null) {
+                parameterInConfiguration.setOperator(new Operator());
+            }
+            if(parameterInConfiguration.getFunctions() == null) {
+                parameterInConfiguration.setFunctions(new ArrayList<>());
+            }
+        }
+    }
 }
diff --git a/src/main/webapp/WEB-INF/templates/assembly.html b/src/main/webapp/WEB-INF/templates/assembly.html
index 3d1ae671..4562ae07 100644
--- a/src/main/webapp/WEB-INF/templates/assembly.html
+++ b/src/main/webapp/WEB-INF/templates/assembly.html
@@ -1,4 +1,5 @@
-<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"><head>
+<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
+<head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
     <meta name="description" content="">
@@ -14,7 +15,9 @@
     <link href="css/fontawesome.min.css" rel="stylesheet">
     <link href="css/style.css" rel="stylesheet">
 
-    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
+            integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
+            crossorigin="anonymous"></script>
     <script type="text/javascript" src="js/jquery.js"></script>
     <script type="text/javascript" src="js/bootstrap.min.js"></script>
     <script type="text/javascript" src="js/bootstrap-select.min.js"></script>
@@ -30,12 +33,13 @@
     </div>
 
     <form th:object="${configuration}" method="post" th:action="@{/configuration(configurationID=${configuration.id})}">
-        <input type="hidden" th:field="*{assembly.id}" th:value="${configuration.assembly?.getId()}" />
+        <input type="hidden" th:field="*{assembly.id}" th:value="${configuration.assembly?.getId()}"/>
         <div class="container box">
             <div class="col-md-12">
                 <div class="col-md-12 form-group row">
                     <label for="exampleFormControlSelect1" class="name-input-label">Titulek tabulky:</label>
-                    <input type="text" class="form-control name-input" th:field="*{tableName}" th:value="${configuration?.tableName}">
+                    <input type="text" class="form-control name-input" th:field="*{tableName}"
+                           th:value="${configuration?.tableName}">
                 </div>
 
                 <span>Parametry:</span>
@@ -51,28 +55,38 @@
                         <tbody>
                         <tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}">
                             <td>
-                                <span class="select-text-padding" th:text="${parameterInConfiguration.parameter.name}"></span>
+                                <span class="select-text-padding"
+                                      th:text="${parameterInConfiguration.parameter.name}"></span>
                             </td>
                             <td>
                                 <optional th:each="location : ${parameterInConfiguration.parameter.locations}">
-                                <span th:if="${location.name.equals('Sloupec')}" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" class="select-action-padding select-action-button select-input-action-margin-collapse">
+                                <span th:if="${location.name.equals('Sloupec')}"
+                                      th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}"
+                                      class="select-action-padding select-action-button select-input-action-margin-collapse">
                                   <i class="fas fa-align-justify"></i>
                                 </span>
-                                <span th:if="${location.name.equals('Řádek')}" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" class="select-action-padding select-action-button select-input-action-margin-collapse">
+                                    <span th:if="${location.name.equals('Řádek')}"
+                                          th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}"
+                                          class="select-action-padding select-action-button select-input-action-margin-collapse">
                                   <i class="fas fa-align-justify transform"></i>
                                 </span>
-                                <span th:if="${location.name.equals('Hodnota')}" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}" class="select-action-padding select-action-button select-input-action-margin-collapse">
+                                    <span th:if="${location.name.equals('Hodnota')}"
+                                          th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].location.name}"
+                                          class="select-action-padding select-action-button select-input-action-margin-collapse">
                                     <i class="fas fa-heading"></i>
                                 </span>
                                 </optional>
                             </td>
                             <td class="s">
                                 <div class="col select-filter">
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].operator.name}">
-                                        <option th:value="zadny" selected value> -- Zvolte operátor -- </option>
-                                        <option th:each="operator : ${parameterInConfiguration.parameter.operators}" th:text="${operator.name}" th:value="${operator.name}"></option>
+                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1"
+                                            th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].operator.name}">
+                                        <option th:value="zadny" selected value> -- Zvolte operátor --</option>
+                                        <option th:each="operator : ${parameterInConfiguration.parameter.operators}"
+                                                th:text="${operator.name}" th:value="${operator.name}"></option>
                                     </select>
-                                    <input type="text" class="form-control select-filter-input" id="name" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].operatorValue}">
+                                    <input type="text" class="form-control select-filter-input" id="name"
+                                           th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].operatorValue}">
                                 </div>
                             </td>
                         </tr>
@@ -94,23 +108,13 @@
                             </tr>
                             </thead>
                             <tbody>
-                            <tr>
+                            <tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Řádek')}">
                                 <td>
-                                    <span>Fakulta</span>
+                                    <span th:text="${parameterInConfiguration.parameter.name}"></span>
                                 </td>
                                 <td>
-                                    <input type="text" class="form-control select-filter-input" id="name">
-                                </td>
-                                <td>
-                                    <span><i class="fas fa-sort"></i></span>
-                                </td>
-                            </tr>
-                            <tr>
-                                <td>
-                                    <span>Typ studia</span>
-                                </td>
-                                <td>
-                                    <input type="text" class="form-control select-filter-input" id="name">
+                                    <input th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].columnName}"
+                                           type="text" class="form-control select-filter-input" id="name">
                                 </td>
                                 <td>
                                     <span><i class="fas fa-sort"></i></span>
@@ -134,12 +138,13 @@
                             </tr>
                             </thead>
                             <tbody>
-                            <tr>
+                            <tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Sloupec')}">
                                 <td>
-                                    <span>Ročník</span>
+                                    <span th:text="${parameterInConfiguration.parameter.name}"></span>
                                 </td>
                                 <td>
-                                    <input type="text" class="form-control select-filter-input" id="name">
+                                    <input th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].columnName}"
+                                           type="text" class="form-control select-filter-input" id="name">
                                 </td>
                                 <td>
                                     <span><i class="fas fa-sort"></i></span>
@@ -158,20 +163,21 @@
                             <thead>
                             <tr>
                                 <th class="col-1-p"></th>
-                                <th class="col-2-p">Vlastní název</th>
+                                <th class="col-2-p">Funkce</th>
                             </tr>
                             </thead>
                             <tbody>
-                            <tr>
+                            <tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" th:if="${parameterInConfiguration.location.name?.equals('Hodnota')}">
                                 <td>
-                                    <span>Počet</span>
+                                    <span th:text="${parameterInConfiguration.parameter.name}"></span>
                                 </td>
                                 <td>
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1">
-                                        <option>SUM</option>
-                                        <option>AVG</option>
-                                        <option>MIN</option>
-                                        <option>MAX</option>
+                                    <select class="form-control" style="{width:60px;}"
+                                            id="exampleFormControlSelect1"
+                                            th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].functions}"
+                                            multiple>
+                                        <option th:each="function : ${parameterInConfiguration.parameter.functions}"
+                                                th:text="${function.name}" th:value="${{function.id}}"></option>
                                     </select>
                                 </td>
 
@@ -185,7 +191,8 @@
                 <div class="col-md-12 form-group row template-input">
                     <label for="exampleFormControlSelect1" class="template-input-label">Vlastní název šablony:</label>
                     <div class="">
-                        <input type="text" required="required" class="form-control select-filter-input" id="name" th:field="${configuration.name}">
+                        <input type="text" required="required" class="form-control select-filter-input" id="name"
+                               th:field="${configuration.name}">
                     </div>
 
                     <button type="submit" class="btn btn-success mb-2 template-input-submit">Uložit šablonu</button>
@@ -193,7 +200,8 @@
 
 
                 <div class="buttons-wrap">
-                    <button type="submit" class="btn btn-secondary mb-2 " name="generate-table">Vygenerovat tabulku</button>
+                    <button type="submit" class="btn btn-secondary mb-2 " name="generate-table">Vygenerovat tabulku
+                    </button>
                     <button type="submit" class="btn btn-secondary mb-2 " name="export-xls">Export do XLS</button>
                     <button type="submit" class="btn btn-secondary mb-2 " name="export-pdf">Export do PDF</button>
                 </div>
@@ -202,8 +210,6 @@
     </form>
 
 
-
-
     <div th:if="${contingencyTableRows}" class="container box">
         <div class="col-md-12">
 
@@ -211,19 +217,18 @@
             <table class="tg table">
 
 
-                    <tr th:each="contingencyTableRow : ${contingencyTableRows}">
-                        <div class="tg-align" th:if="${contingencyTableRow.isHeader()}">
-                            <th class="tg-align" th:each="contingencyTableRowCell : ${contingencyTableRow.getCells()}">
-                                <span th:text="${contingencyTableRowCell.getValue()}"></span>
-                            </th>
-                        </div>
-                        <div th:unless="${contingencyTableRow.isHeader()}">
-                            <td class="tg-align" th:each="contingencyTableRowCell : ${contingencyTableRow.getCells()}">
-                                <span th:text="${contingencyTableRowCell.getValue()}"></span>
-                            </td>
-                        </div>
-                    </tr>
-
+                <tr th:each="contingencyTableRow : ${contingencyTableRows}">
+                    <div class="tg-align" th:if="${contingencyTableRow.isHeader()}">
+                        <th class="tg-align" th:each="contingencyTableRowCell : ${contingencyTableRow.getCells()}">
+                            <span th:text="${contingencyTableRowCell.getValue()}"></span>
+                        </th>
+                    </div>
+                    <div th:unless="${contingencyTableRow.isHeader()}">
+                        <td class="tg-align" th:each="contingencyTableRowCell : ${contingencyTableRow.getCells()}">
+                            <span th:text="${contingencyTableRowCell.getValue()}"></span>
+                        </td>
+                    </div>
+                </tr>
 
 
             </table>
