commit b439853d7da25f09b99794c980e702091f49211d
Author: mlinha <mlinha@students.zcu.cz>
Date:   Fri Apr 24 13:02:05 2020 +0200

    re #7881 ability to create or edit a user configuration and set or edit its basic attributes, operator value and configuration name are validated, if operator value is wrong user is redirected to main page, auto increment functionality changed to IDENTITY

diff --git a/src/main/java/vldc/aswi/dao/FunctionRepository.java b/src/main/java/vldc/aswi/dao/FunctionRepository.java
index c1423e0b..1978462c 100644
--- a/src/main/java/vldc/aswi/dao/FunctionRepository.java
+++ b/src/main/java/vldc/aswi/dao/FunctionRepository.java
@@ -16,4 +16,11 @@ public interface FunctionRepository extends CrudRepository<Function, Long> {
      * @return Function if ID is present in database.
      */
     Function getById(Long Id);
+
+    /**
+     * Find function by its name.
+     * @param name - function name.
+     * @return function if name is present in database.
+     */
+    Function getByName(String name);
 }
diff --git a/src/main/java/vldc/aswi/dao/LocationRepository.java b/src/main/java/vldc/aswi/dao/LocationRepository.java
index 69145ae1..97cf56ab 100644
--- a/src/main/java/vldc/aswi/dao/LocationRepository.java
+++ b/src/main/java/vldc/aswi/dao/LocationRepository.java
@@ -16,4 +16,11 @@ public interface LocationRepository extends CrudRepository<Location, Long> {
      * @return Location if ID is present in database.
      */
     Location getById(Long Id);
+
+    /**
+     * Find Location by its name.
+     * @param name - Location name.
+     * @return Location if name is present in database.
+     */
+    Location getByName(String name);
 }
diff --git a/src/main/java/vldc/aswi/dao/OperatorRepository.java b/src/main/java/vldc/aswi/dao/OperatorRepository.java
index 07d34412..438b6acf 100644
--- a/src/main/java/vldc/aswi/dao/OperatorRepository.java
+++ b/src/main/java/vldc/aswi/dao/OperatorRepository.java
@@ -16,4 +16,11 @@ public interface OperatorRepository extends CrudRepository<Operator, Long> {
      * @return Operator if ID is present in database.
      */
     Operator getById(Long Id);
+
+    /**
+     * Find Operator by its name.
+     * @param name - Operator name.
+     * @return Operator if name is present in database.
+     */
+    Operator getByName(String name);
 }
diff --git a/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java b/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
index 819b2799..50558cc8 100644
--- a/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
+++ b/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
@@ -16,4 +16,11 @@ public interface ParameterTypeRepository extends CrudRepository<ParameterType, L
      * @return ParameterType if ID is present in database.
      */
     ParameterType getById(Long Id);
+
+    /**
+     * Find ParameterType by its name.
+     * @param name - ParameterType name.
+     * @return ParameterType if name is present in database.
+     */
+    ParameterType getByName(String name);
 }
diff --git a/src/main/java/vldc/aswi/domain/Configuration.java b/src/main/java/vldc/aswi/domain/Configuration.java
index 760c989b..d3e74615 100644
--- a/src/main/java/vldc/aswi/domain/Configuration.java
+++ b/src/main/java/vldc/aswi/domain/Configuration.java
@@ -4,8 +4,11 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import vldc.aswi.domain.parameter.ParameterInConfiguration;
+import vldc.aswi.utils.validator.OperatorValueConstraint;
 
 import javax.persistence.*;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
 import java.util.List;
 
 /**
@@ -37,6 +40,7 @@ public class Configuration extends EntityParent {
 
     /** List of parametersInConfiguration, which is part of this configuration. */
     @OneToMany(mappedBy = "configuration")
+    @Valid
     private List<ParameterInConfiguration> parametersInConfiguration;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/EntityParent.java b/src/main/java/vldc/aswi/domain/EntityParent.java
index 75da5bc9..4cdd38bb 100644
--- a/src/main/java/vldc/aswi/domain/EntityParent.java
+++ b/src/main/java/vldc/aswi/domain/EntityParent.java
@@ -16,6 +16,6 @@ public class EntityParent {
 
     /** Specific identificator for every table. */
     @Id
-    @GeneratedValue(strategy = GenerationType.AUTO)
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/Parameter.java b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
index 72384e42..8fd1a45e 100644
--- a/src/main/java/vldc/aswi/domain/parameter/Parameter.java
+++ b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
@@ -33,6 +33,11 @@ public class Parameter extends EntityParent {
     @Column(name = "default_hodnota")
     private String defaultValue;
 
+    /** Specific type of parameter, which represents type of entry. */
+    @ManyToOne(fetch=FetchType.LAZY)
+    @JoinColumn(name = "parametr_typ_id")
+    private ParameterType parameterType;
+
     /** List of parametersInConfiguration, which using this parameter. */
     @OneToMany(mappedBy = "parameter")
     private List<ParameterInConfiguration> parametersInConfiguration;
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
index 0963fdb6..a2f707eb 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
@@ -4,6 +4,8 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
 import vldc.aswi.domain.*;
+import vldc.aswi.utils.validator.OperatorValueConstraint;
+
 import javax.persistence.*;
 import java.util.List;
 
@@ -14,6 +16,7 @@ import java.util.List;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @NoArgsConstructor
+@OperatorValueConstraint
 public class ParameterInConfiguration extends EntityParent {
 
     /** Specific configuration in which is this parameterConfiguration presented. */
@@ -30,11 +33,6 @@ public class ParameterInConfiguration extends EntityParent {
     @Column(name = "hodnota_operatoru")
     private String operatorValue;
 
-    /** Specific type of parameter, which represents type of entry. */
-    @ManyToOne(fetch=FetchType.LAZY)
-    @JoinColumn(name = "parametr_typ_id")
-    private ParameterType parameterType;
-
     /** Specific location in which this parameterConfiguration will be used. */
     @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name = "umisteni_id")
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
index aa78c5f7..947b2773 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
@@ -25,7 +25,7 @@ public class ParameterType extends EntityParent {
 
     /** List of parameterInConfigurations, which using this parameter type. */
     @OneToMany(mappedBy = "parameterType")
-    private List<ParameterInConfiguration> parametersInConfiguration;
+    private List<Parameter> parameters;
 
     /**
      * Constructor.
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
index 397b4736..6fd29f74 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
@@ -3,7 +3,6 @@ package vldc.aswi.domain.parameter;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
-import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.EntityParent;
 
 import javax.persistence.*;
diff --git a/src/main/java/vldc/aswi/service/ConfigurationManager.java b/src/main/java/vldc/aswi/service/ConfigurationManager.java
index 4f83cebe..c3b1d450 100644
--- a/src/main/java/vldc/aswi/service/ConfigurationManager.java
+++ b/src/main/java/vldc/aswi/service/ConfigurationManager.java
@@ -16,5 +16,18 @@ public interface ConfigurationManager {
      */
     List<Configuration> getConfigurations();
 
+    /**
+     * Gets configuration according to its ID
+     * @param id ID of configuration
+     * @return configuration by ID
+     */
     Configuration getConfigurationById(Long id);
+
+    /**
+     * Saves configuration and its contents into database
+     * @param newConfiguration configuration to save
+     * @param id id of configuration, if not empty configuration is updated
+     * @return saved configuration
+     */
+    Configuration saveConfiguration(Configuration newConfiguration, String id);
 }
diff --git a/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java b/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
index 7280fc7f..85309626 100644
--- a/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
@@ -6,11 +6,16 @@ import org.springframework.context.event.ContextRefreshedEvent;
 import org.springframework.context.event.EventListener;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Service;
-import vldc.aswi.dao.ConfigurationRepository;
+import vldc.aswi.dao.*;
+import vldc.aswi.dao.parameter.ParameterInConfigurationRepository;
+import vldc.aswi.dao.parameter.ParameterTypeRepository;
 import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.Configuration;
+import vldc.aswi.domain.Function;
+import vldc.aswi.domain.parameter.ParameterInConfiguration;
 
 import javax.transaction.Transactional;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -22,6 +27,34 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
     @Autowired
     private ConfigurationRepository configurationRepository;
 
+    /** Autowired assembly repository. */
+    @Autowired
+    private AssemblyRepository assemblyRepository;
+
+    /** Autowired parameterInConfiguration repository. */
+    @Autowired
+    private ParameterInConfigurationRepository parameterInConfigurationRepository;
+
+    /** Autowired operator repository. */
+    @Autowired
+    private OperatorRepository operatorRepository;
+
+    /** Autowired location repository. */
+    @Autowired
+    private LocationRepository locationRepository;
+
+    /** Autowired parameter type repository. */
+    @Autowired
+    private ParameterTypeRepository parameterTypeRepository;
+
+    /** Autowired function repository. */
+    @Autowired
+    private FunctionRepository functionRepository;
+
+    /** Autowired user repository. */
+    @Autowired
+    private UserRepository userRepository;
+
     /**
      * Initialization setup for configuration manager. Check if configuration repository contains
      * records and if not, initialize default values.
@@ -49,8 +82,111 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
         return retVal;
     }
 
+    /**
+     * Gets configuration according to its ID
+     * @param id ID of configuration
+     * @return configuration by ID
+     */
     @Override
     public Configuration getConfigurationById(Long id) {
         return configurationRepository.getById(id);
     }
+
+    /**
+     * Saves configuration and its contents into database
+     * @param newConfiguration configuration to save
+     * @param id id of configuration, if not empty configuration is updated
+     * @return saved configuration
+     */
+    @Override
+    public Configuration saveConfiguration(Configuration newConfiguration, String id) {
+        if(id.equals("")) {
+            return addConfiguration(newConfiguration);
+        }
+        else {
+            return editConfiguration(newConfiguration, Long.valueOf(id));
+        }
+    }
+
+    /**
+     * Saves new configuration into database
+     * @param newConfiguration container with data for a new configuration
+     * @return saved configuration
+     */
+    private Configuration addConfiguration(Configuration newConfiguration) {
+        Configuration configuration = new Configuration();
+        Assembly assembly = assemblyRepository.getById(newConfiguration.getAssembly().getId());
+        configuration.setAssembly(assembly);
+        configuration.setName(newConfiguration.getName());
+        configuration.setTableName(newConfiguration.getTableName());
+        configuration.setUser(userRepository.getById((long) 1));
+        Configuration savedConfiguration = configurationRepository.save(configuration);
+
+        savedConfiguration.setParametersInConfiguration(new ArrayList<>());
+        for(int i = 0; i < newConfiguration.getParametersInConfiguration().size(); i++) {
+            ParameterInConfiguration parameterInConfiguration = new ParameterInConfiguration();
+            parameterInConfiguration.setParameter(assembly.getParameters().get(i));
+            parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName());
+            parameterInConfiguration.setConfiguration(savedConfiguration);
+            parameterInConfiguration.setOperatorValue(newConfiguration.getParametersInConfiguration().get(i).getOperatorValue());
+            parameterInConfiguration.setColumnName(assembly.getParameters().get(i).getName());
+            if(newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) {
+                parameterInConfiguration.setLocation(locationRepository.getByName(
+                        newConfiguration.getParametersInConfiguration().get(i).getLocation().getName()));
+            }
+            if(newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) {
+                parameterInConfiguration.setOperator(operatorRepository.getByName(
+                        newConfiguration.getParametersInConfiguration().get(i).getOperator().getName()));
+            }
+            if(newConfiguration.getParametersInConfiguration().get(i).getFunctions() != null) {
+                parameterInConfiguration.setFunctions(new ArrayList<>());
+                for (Function function : newConfiguration.getParametersInConfiguration().get(i).getFunctions()) {
+                    parameterInConfiguration.getFunctions().add(functionRepository.getByName(function.getName()));
+                }
+            }
+            ParameterInConfiguration savedParameterInConfiguration = parameterInConfigurationRepository.save(
+                    parameterInConfiguration);
+            savedConfiguration.getParametersInConfiguration().add(savedParameterInConfiguration);
+        }
+        savedConfiguration = configurationRepository.save(savedConfiguration);
+
+        return savedConfiguration;
+    }
+
+    /**
+     * Saves edited configuration with given ID
+     * @param newConfiguration container with data for edited configuration
+     * @param id ID of edited configuration
+     * @return saved configuration
+     */
+    private Configuration editConfiguration(Configuration newConfiguration, Long id) {
+        Configuration configuration = configurationRepository.getById(id);
+        configuration.setName(newConfiguration.getName());
+        configuration.setTableName(newConfiguration.getTableName());
+
+        for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) {
+            ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i);
+            parameterInConfiguration.setOperatorValue(newConfiguration.getParametersInConfiguration().get(i).getOperatorValue());
+            if(newConfiguration.getParametersInConfiguration().get(i).getColumnName() != null) {
+                parameterInConfiguration.setColumnName(newConfiguration.getParametersInConfiguration().get(i).getColumnName());
+            }
+            if(newConfiguration.getParametersInConfiguration().get(i).getLocation() != null) {
+                parameterInConfiguration.setLocation(locationRepository.getByName(
+                        newConfiguration.getParametersInConfiguration().get(i).getLocation().getName()));
+            }
+            if(newConfiguration.getParametersInConfiguration().get(i).getOperator() != null) {
+                parameterInConfiguration.setOperator(operatorRepository.getByName(
+                        newConfiguration.getParametersInConfiguration().get(i).getOperator().getName()));
+            }
+            if(newConfiguration.getParametersInConfiguration().get(i).getFunctions() != null) {
+                parameterInConfiguration.setFunctions(new ArrayList<>());
+                for (Function function : newConfiguration.getParametersInConfiguration().get(i).getFunctions()) {
+                    parameterInConfiguration.getFunctions().add(functionRepository.getByName(function.getName()));
+                }
+            }
+            parameterInConfigurationRepository.save(parameterInConfiguration);
+        }
+
+        return configurationRepository.save(configuration);
+    }
 }
diff --git a/src/main/java/vldc/aswi/utils/validator/OperatorValueConstraint.java b/src/main/java/vldc/aswi/utils/validator/OperatorValueConstraint.java
new file mode 100644
index 00000000..68fe8cf1
--- /dev/null
+++ b/src/main/java/vldc/aswi/utils/validator/OperatorValueConstraint.java
@@ -0,0 +1,33 @@
+package vldc.aswi.utils.validator;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+import java.lang.annotation.*;
+
+/**
+ * Annotation used for validation of operator value
+ */
+@Documented
+@Constraint(validatedBy = OperatorValueValidator.class)
+@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface OperatorValueConstraint {
+
+    /**
+     * Message of operator value is invalid
+     * @return error message
+     */
+    String message() default "Neplatná hodnota filtru!";
+
+    /**
+     * Array of classes
+     * @return array of classes
+     */
+    Class<?>[] groups() default {};
+
+    /**
+     * Class payload
+     * @return class payload
+     */
+    Class<? extends Payload>[] payload() default {};
+}
diff --git a/src/main/java/vldc/aswi/utils/validator/OperatorValueValidator.java b/src/main/java/vldc/aswi/utils/validator/OperatorValueValidator.java
new file mode 100644
index 00000000..932c27dc
--- /dev/null
+++ b/src/main/java/vldc/aswi/utils/validator/OperatorValueValidator.java
@@ -0,0 +1,37 @@
+package vldc.aswi.utils.validator;
+
+import vldc.aswi.domain.parameter.ParameterInConfiguration;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * Validator class for validation operator value according to used operator
+ */
+public class OperatorValueValidator implements
+        ConstraintValidator<OperatorValueConstraint, Object> {
+
+    /**
+     * Initialize validator
+     * @param operatorValue operator value
+     */
+    @Override
+    public void initialize(OperatorValueConstraint operatorValue) {
+    }
+
+    /**
+     * Validation process of operator value
+     * @param o object to be validated
+     * @param constraintValidatorContext context
+     * @return true if operator value is valid
+     */
+    @Override
+    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
+        ParameterInConfiguration parameterInConfiguration = (ParameterInConfiguration) o;
+        if (parameterInConfiguration.getOperator() != null && parameterInConfiguration.getOperator().getName().equals("BETWEEN")) {
+            return parameterInConfiguration.getOperatorValue().matches(".;.");
+        }
+
+        return true;
+    }
+}
diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 58440da1..71ea2a07 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -7,28 +7,51 @@ import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.Configuration;
+import vldc.aswi.domain.Location;
+import vldc.aswi.domain.Operator;
+import vldc.aswi.domain.parameter.Parameter;
+import vldc.aswi.domain.parameter.ParameterInConfiguration;
 import vldc.aswi.service.AssemblyManager;
 import vldc.aswi.service.ConfigurationManager;
 import vldc.aswi.service.SqlQueryManager;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
 
+/**
+ * Controller for assemblies and configurations
+ */
 @Controller
 public class AssemblyController {
 
+    /**
+     * Autowired SQL query manager
+     */
     @Autowired
     private SqlQueryManager sqlQueryManager;
 
+    /**
+     * Autowired assembly manager
+     */
     @Autowired
     private AssemblyManager assemblyManager;
 
+    /**
+     * Autowired configuration manager
+     */
     @Autowired
     private ConfigurationManager configurationManager;
 
+    /**
+     * Opens an configuration page after assembly name was clicked
+     * @param id ID of assembly
+     * @return modelAndView of page to be shown
+     */
     @GetMapping("/assembly")
     public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) {
         ModelAndView modelAndView = new ModelAndView("assembly");
@@ -40,27 +63,85 @@ public class AssemblyController {
         Configuration configuration = new Configuration();
 
         configuration.setAssembly(assembly);
+        configuration.setParametersInConfiguration(new ArrayList<>());
+        for(Parameter parameter : assembly.getParameters()) {
+            ParameterInConfiguration parameterInConfiguration = new ParameterInConfiguration();
+            parameterInConfiguration.setParameter(parameter);
+            parameterInConfiguration.setConfiguration(configuration);
+            parameterInConfiguration.setOperator(new Operator());
+            parameterInConfiguration.setLocation(new Location());
+            configuration.getParametersInConfiguration().add(parameterInConfiguration);
+        }
 
         modelMap.addAttribute("configuration", configuration);
-        modelMap.addAttribute("assemblyID", id);
+        modelMap.addAttribute("isAssembly", false);
 
         return modelAndView;
     }
 
-    @GetMapping("/assembly")
-    public ModelAndView configurationIndex(@Valid @ModelAttribute("assemblyID") String id) {
+    /**
+     * Opens an configuration page after configuration name was clicked
+     * @param id ID of configuration
+     * @return modelAndView of page to be shown
+     */
+    @GetMapping("/configuration")
+    public ModelAndView configurationIndex(@Valid @ModelAttribute("configurationID") String id) {
         ModelAndView modelAndView = new ModelAndView("assembly");
 
         ModelMap modelMap = modelAndView.getModelMap();
 
         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());
+            }
+        }
+
         modelMap.addAttribute("configuration", configuration);
-        modelMap.addAttribute("assemblyID", configuration.getAssembly().getId());
+        modelMap.addAttribute("isAssembly", "0");
 
         return modelAndView;
     }
 
+    /**
+     * Saves or edits configuration and redirects to the page with configuration
+     * @param newConfiguration contained with configuration data
+     * @param id ID of configuration, if empty new configuration is created
+     * @param bindingResult binding result
+     * @return modelAndView with redirection
+     */
+    @PostMapping("/configuration")
+    public ModelAndView saveConfiguration(@Valid Configuration newConfiguration, BindingResult bindingResult,
+                                          @RequestParam("configurationID") String id) {
+        ModelAndView modelAndView = new ModelAndView();
+
+        if (bindingResult.hasErrors()) {
+            modelAndView.setViewName("redirect:/");
+
+            return modelAndView;
+        }
+
+        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());
+            }
+        }
+
+        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();
@@ -68,7 +149,7 @@ public class AssemblyController {
         ModelMap modelMap = modelAndView.getModelMap();
 
         long assemblyID = assembly.getId();
-System.out.println(assemblyID);
+        System.out.println(assemblyID);
         Assembly assembly2 = assemblyManager.getAssemblyById(assemblyID);
 
 
diff --git a/src/main/java/vldc/aswi/web/controller/IndexController.java b/src/main/java/vldc/aswi/web/controller/IndexController.java
index 3288719e..fd85284e 100644
--- a/src/main/java/vldc/aswi/web/controller/IndexController.java
+++ b/src/main/java/vldc/aswi/web/controller/IndexController.java
@@ -7,31 +7,49 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.servlet.ModelAndView;
-import vldc.aswi.database.DatabaseInterface;
 import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.parameter.Parameter;
-import vldc.aswi.model.table.TableColumn;
-import vldc.aswi.model.table.contingencyTable.ContingencyTableRow;
-import vldc.aswi.model.table.contingencyTable.ContingencyTableRowCell;
 import vldc.aswi.service.AssemblyManager;
+import vldc.aswi.service.ConfigurationManager;
 import vldc.aswi.service.SqlQueryManager;
-import vldc.aswi.utils.Converter;
 
-import javax.sql.DataSource;
 import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
+/**
+ * Controller for index page
+ */
 @Controller
 public class IndexController {
 
+	/**
+	 * Length when attribute string generation stops after its exceeded
+	 */
+	private static final int ATTRIBUTES_LENGTH = 50;
+
+	/**
+	 * Autowired SQL query manager
+	 */
 	@Autowired
 	private SqlQueryManager sqlQueryManager;
 
+	/**
+	 * Autowired assembly manager
+	 */
 	@Autowired
 	private AssemblyManager assemblyManager;
 
+	/**
+	 * Autowired configuration manager
+	 */
+	@Autowired
+	private ConfigurationManager configurationManager;
+
+	/**
+	 * Shows index page
+	 * @return modelAndView with index page
+	 */
 	@GetMapping("/")
 	public ModelAndView index() {
 		ModelAndView modelAndView = new ModelAndView("index");
@@ -40,18 +58,40 @@ public class IndexController {
 
 		List<Assembly> assemblies = assemblyManager.getAssemblies();
 
+
+		modelMap.addAttribute("assemblies", assemblies);
+		modelMap.addAttribute("attributes", createAttributesString(assemblies));
+		modelMap.addAttribute("configurations", configurationManager.getConfigurations());
+
+		return modelAndView;
+	}
+
+	@PostMapping("/")
+	public ModelAndView indexPost(@Valid @ModelAttribute("assemblyID") String id) {
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.setViewName("redirect:/assembly");
+
+		return modelAndView;
+	}
+
+	/**
+	 * Generates list of strings with attributes for each assembly
+	 * @param assemblies list of assemblies
+	 * @return list of strings with attributes
+	 */
+	private List<String> createAttributesString(List<Assembly> assemblies) {
 		List<String> attributes = new ArrayList<>();
 		for(Assembly assembly : assemblies) {
 			int i = 0;
-			StringBuilder stringBuilder = new StringBuilder("");
+			StringBuilder stringBuilder = new StringBuilder();
 			for(Parameter parameter : assembly.getParameters()) {
 				stringBuilder.append(parameter.getName());
 				i++;
-				if(i == 3) {
-					stringBuilder.append(",...");
+				if (i == assembly.getParameters().size()) {
 					break;
 				}
-				else if(i == assembly.getParameters().size()) {
+				else if (stringBuilder.toString().length() > ATTRIBUTES_LENGTH) {
+					stringBuilder.append(",...");
 					break;
 				}
 				else {
@@ -61,18 +101,6 @@ public class IndexController {
 			attributes.add(stringBuilder.toString());
 		}
 
-		modelMap.addAttribute("assemblies", assemblies);
-		modelMap.addAttribute("attributes", attributes);
-
-		return modelAndView;
+		return attributes;
 	}
-
-	@PostMapping("/")
-	public ModelAndView indexPost(@Valid @ModelAttribute("assemblyID") String id) {
-		ModelAndView modelAndView = new ModelAndView();
-		modelAndView.setViewName("redirect:/assembly");
-
-		return modelAndView;
-	}
-
 }
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 6401b7ab..e24d0dd3 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,5 +1,5 @@
 # Tell hibernate to use oracle dialect.
-spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
+spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect
 
 # TNS format of connection to ORACLE 12c database.
 oracle.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=atreus-v.zcu.cz)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DEMO_SERVICE)))
diff --git a/src/main/webapp/WEB-INF/templates/assembly.html b/src/main/webapp/WEB-INF/templates/assembly.html
index d6cdfeb6..3d1ae671 100644
--- a/src/main/webapp/WEB-INF/templates/assembly.html
+++ b/src/main/webapp/WEB-INF/templates/assembly.html
@@ -29,13 +29,13 @@
         </h1>
     </div>
 
-    <form th:object="${configuration}" method="post" th:action="@{/assembly(assemblyID=${assemblyID})}">
-        <input type="hidden" th:field="*{id}" th:value="${assembly?.getId()}" />
+    <form th:object="${configuration}" method="post" th:action="@{/configuration(configurationID=${configuration.id})}">
+        <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="*{name}" th:value="${assembly?.name}">
+                    <input type="text" class="form-control name-input" th:field="*{tableName}" th:value="${configuration?.tableName}">
                 </div>
 
                 <span>Parametry:</span>
@@ -49,116 +49,30 @@
                         </tr>
                         </thead>
                         <tbody>
-                        <tr th:each="parameter, itemStat : ${configuration.parametersInConfiguration}">
-
-                        </tr>
-                        <tr>
-                            <td><span class="select-text-padding">Akademický rok</span></td>
+                        <tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}">
                             <td>
-                                <span class="select-action-padding select-action-button select-input-action-margin-collapse">
+                                <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">
                                   <i class="fas fa-align-justify"></i>
                                 </span>
-                                                <span 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">
+                                    <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">
-                                        <option>IN</option>
-                                        <option>GREATER</option>
-                                        <option>LESS</option>
-                                        <option>EQUAL</option>
-                                    </select>
-                                    <input type="text" class="form-control select-filter-input" id="name">
-                                </div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td><span class="select-text-padding">Fakulta</span></td>
-                            <td>
-                <span class="select-action-padding select-action-button select-input-action-margin-collapse select-action-headlight">
-                  <i class="fas fa-align-justify"></i>
-                </span>
-                                <span class="select-action-padding select-action-button select-input-action-margin-collapse ">
-                  <i class="fas fa-align-justify transform"></i>
-                </span>
-                            </td>
-                            <td class="s">
-                                <div class="col select-filter">
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1">
-                                        <option>IN</option>
-                                        <option>GREATER</option>
-                                        <option>LESS</option>
-                                        <option>EQUAL</option>
-                                    </select>
-                                    <input type="text" class="form-control select-filter-input" id="name">
-                                </div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td><span class="select-text-padding">Ročník</span></td>
-                            <td>
-                <span class="select-action-padding select-action-button select-input-action-margin-collapse">
-                  <i class="fas fa-align-justify"></i>
-                </span>
-                                <span class="select-action-padding select-action-button select-input-action-margin-collapse select-action-headlight">
-                  <i class="fas fa-align-justify transform"></i>
-                </span>
-                            </td>
-                            <td class="s">
-                                <div class="col select-filter">
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1">
-                                        <option>IN</option>
-                                        <option>GREATER</option>
-                                        <option>LESS</option>
-                                        <option>EQUAL</option>
-                                    </select>
-                                    <input type="text" class="form-control select-filter-input" id="name">
-                                </div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td><span class="select-text-padding">Typ strudia</span></td>
-                            <td>
-                <span class="select-action-padding select-action-button select-input-action-margin-collapse select-action-headlight">
-                  <i class="fas fa-align-justify"></i>
-                </span>
-                                <span class="select-action-padding select-action-button select-input-action-margin-collapse">
-                  <i class="fas fa-align-justify transform"></i>
-                </span>
-                                <span class="select-action-padding select-action-button select-input-action-margin-collapse">
-                  <i class="fas fa-heading"></i>
-                </span>
-                            </td>
-                            <td class="s">
-                                <div class="col select-filter">
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1">
-                                        <option>IN</option>
-                                        <option>GREATER</option>
-                                        <option>LESS</option>
-                                        <option>EQUAL</option>
-                                    </select>
-                                    <input type="text" class="form-control select-filter-input" id="name">
-                                </div>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td><span class="select-text-padding">Počet</span></td>
-                            <td>
-                <span class="select-action-padding select-action-button select-input-action-margin-collapse select-action-headlight">
-                  <i class="fas fa-heading"></i>
-                </span>
-                            </td>
-                            <td class="s">
-                                <div class="col select-filter">
-                                    <select class="form-control" style="{width:60px;}" id="exampleFormControlSelect1">
-                                        <option>IN</option>
-                                        <option>GREATER</option>
-                                        <option>LESS</option>
-                                        <option>EQUAL</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">
+                                    <input type="text" class="form-control select-filter-input" id="name" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].operatorValue}">
                                 </div>
                             </td>
                         </tr>
@@ -271,7 +185,7 @@
                 <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" class="form-control select-filter-input" id="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>
diff --git a/src/main/webapp/WEB-INF/templates/index.html b/src/main/webapp/WEB-INF/templates/index.html
index 39b5775e..c15e72e4 100644
--- a/src/main/webapp/WEB-INF/templates/index.html
+++ b/src/main/webapp/WEB-INF/templates/index.html
@@ -31,16 +31,8 @@
 				</div>
 				<table class="table table-bordered table-striped">
 					<tbody>
-					<tr>
-						<td><a href=#>Vlastní šablona 1</a></td>
-						<td class="center-cell">
-				  <span class="action-button">
-					<a href=# class="action-link far fa-trash-alt"></a>
-				  </span>
-						</td>
-					</tr>
-					<tr>
-						<td><a href=#>Vlastní šablona 2, Vlastní šablona 2, Vlastní šablona 2, Vlastní šablona 2</a></td>
+					<tr th:each="iconfiguration : ${configurations}">
+						<td><a th:href="@{/configuration(configurationID=${iconfiguration.id})}"><span th:text="${iconfiguration.name}"></span></a></td>
 						<td class="center-cell">
 				  <span class="action-button">
 					<a href=# class="action-link far fa-trash-alt"></a>
