commit 74a73b3bd2c9d25235f4d6649a7af12274f7f40d
Author: Vojtěch Danišík <32537562+danisik@users.noreply.github.com>
Date:   Mon Apr 27 19:53:13 2020 +0200

    re #7887 Deleting configurations and assemblies, Minor restructuralization.

diff --git a/src/main/java/vldc/aswi/dao/AssemblyRepository.java b/src/main/java/vldc/aswi/dao/AssemblyRepository.java
index cccfb01e..e3661ae4 100644
--- a/src/main/java/vldc/aswi/dao/AssemblyRepository.java
+++ b/src/main/java/vldc/aswi/dao/AssemblyRepository.java
@@ -22,6 +22,5 @@ public interface AssemblyRepository extends CrudRepository<Assembly, Long> {
      * Find record with highest order.
      * @return Assembly with highest order.
      */
-    // TODO: test it.
     Assembly findFirst1ByOrderByAssemblyOrder();
 }
diff --git a/src/main/java/vldc/aswi/dao/ConfigurationRepository.java b/src/main/java/vldc/aswi/dao/ConfigurationRepository.java
index 8dddb0c1..5560e0c9 100644
--- a/src/main/java/vldc/aswi/dao/ConfigurationRepository.java
+++ b/src/main/java/vldc/aswi/dao/ConfigurationRepository.java
@@ -2,8 +2,11 @@ package vldc.aswi.dao;
 
 import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
+import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.Configuration;
 
+import java.util.List;
+
 /**
  * Repository for domain Configuration.
  */
@@ -16,4 +19,11 @@ public interface ConfigurationRepository extends CrudRepository<Configuration, L
      * @return Configuration if ID is present in database.
      */
     Configuration getById(Long Id);
+
+    /**
+     * Get list of configurations by assembly id.
+     * @param assemblyId - ID of assembly.
+     * @return List of configurations.
+     */
+    List<Configuration> getByAssemblyId(Long assemblyId);
 }
diff --git a/src/main/java/vldc/aswi/dao/parameter/ParameterInConfigurationRepository.java b/src/main/java/vldc/aswi/dao/parameter/ParameterInConfigurationRepository.java
index 0b399b0f..b85058db 100644
--- a/src/main/java/vldc/aswi/dao/parameter/ParameterInConfigurationRepository.java
+++ b/src/main/java/vldc/aswi/dao/parameter/ParameterInConfigurationRepository.java
@@ -4,6 +4,8 @@ import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
 import vldc.aswi.domain.parameter.ParameterInConfiguration;
 
+import java.util.List;
+
 /**
  * Repository for domain ParameterInConfiguration.
  */
@@ -16,4 +18,18 @@ public interface ParameterInConfigurationRepository extends CrudRepository<Param
      * @return ParameterInConfiguration if ID is present in database.
      */
     ParameterInConfiguration getById(Long Id);
+
+    /**
+     * Get all parameters in configuration by configuration id.
+     * @param configurationId - ID of configuration.
+     * @return List of parameters in configuration.
+     */
+    List<ParameterInConfiguration> getAllByConfigurationId(Long configurationId);
+
+    /**
+     * Delete all parameters in configuration by configuration id.
+     * @param configurationId - ID of configuration.
+     * @return List of deleted parameter in configuration.
+     */
+    List<ParameterInConfiguration> deleteAllByConfigurationId(Long configurationId);
 }
diff --git a/src/main/java/vldc/aswi/dao/parameter/ParameterRepository.java b/src/main/java/vldc/aswi/dao/parameter/ParameterRepository.java
index 5d028729..0d804658 100644
--- a/src/main/java/vldc/aswi/dao/parameter/ParameterRepository.java
+++ b/src/main/java/vldc/aswi/dao/parameter/ParameterRepository.java
@@ -3,6 +3,9 @@ package vldc.aswi.dao.parameter;
 import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
 import vldc.aswi.domain.parameter.Parameter;
+import vldc.aswi.domain.parameter.ParameterValue;
+
+import java.util.List;
 
 /**
  * Repository for domain Parameter.
@@ -16,4 +19,11 @@ public interface ParameterRepository extends CrudRepository<Parameter, Long> {
      * @return Parameter if ID is present in database.
      */
     Parameter getById(Long Id);
+
+    /**
+     * Get all parameter values by assembly id.
+     * @param assemblyId - ID of assembly.
+     * @return List of parameters.
+     */
+    List<Parameter> getByAssemblyId(Long assemblyId);
 }
diff --git a/src/main/java/vldc/aswi/dao/parameter/ParameterValueRepository.java b/src/main/java/vldc/aswi/dao/parameter/ParameterValueRepository.java
index 325fea49..1a800a30 100644
--- a/src/main/java/vldc/aswi/dao/parameter/ParameterValueRepository.java
+++ b/src/main/java/vldc/aswi/dao/parameter/ParameterValueRepository.java
@@ -4,6 +4,8 @@ import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
 import vldc.aswi.domain.parameter.ParameterValue;
 
+import java.util.List;
+
 /**
  * Repository for domain ParameterValue.
  */
@@ -16,4 +18,11 @@ public interface ParameterValueRepository extends CrudRepository<ParameterValue,
      * @return ParameterValue if ID is present in database.
      */
     ParameterValue getById(Long Id);
+
+    /**
+     * Delete all parameter values by parameter id.
+     * @param parameterId - ID of parameter.
+     * @return List of deleted parameter values.
+     */
+    List<ParameterValue> deleteByParameterId(Long parameterId);
 }
diff --git a/src/main/java/vldc/aswi/domain/Assembly.java b/src/main/java/vldc/aswi/domain/Assembly.java
index ec4527c0..7ac972fb 100644
--- a/src/main/java/vldc/aswi/domain/Assembly.java
+++ b/src/main/java/vldc/aswi/domain/Assembly.java
@@ -33,18 +33,18 @@ public class Assembly extends EntityParent {
     private int isPublic;
 
     /** List of configurations, which using this assembly. */
-    @OneToMany(mappedBy = "assembly", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "assembly", cascade = CascadeType.ALL)
     private List<Configuration> configurations;
 
     /** List of parameters, which using this assembly. */
-    @OneToMany(mappedBy = "assembly", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "assembly", cascade = CascadeType.ALL)
     private List<Parameter> parameters;
 
     /**
      * Creating new table with M:N relationship between Assembly and Role.
      * Every assembly can be used by 0 - every role.
      */
-    @ManyToMany(cascade = {CascadeType.ALL})
+    @ManyToMany
     @JoinTable(
             name = "Sestava_ma_Role",
             joinColumns = @JoinColumn(name = "sestava_id"),
@@ -83,4 +83,13 @@ public class Assembly extends EntityParent {
     public String toString() {
         return "Assembly[]";
     }
+
+    /**
+     * Remove role from assembly in 'Sestava_ma_Role' table.
+     * @param role - Role to be removed.
+     */
+    public void removeRole(Role role) {
+        roles.remove(role);
+        role.getAssemblies().remove(this);
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/Configuration.java b/src/main/java/vldc/aswi/domain/Configuration.java
index 6856f989..aba42a76 100644
--- a/src/main/java/vldc/aswi/domain/Configuration.java
+++ b/src/main/java/vldc/aswi/domain/Configuration.java
@@ -36,7 +36,7 @@ public class Configuration extends EntityParent {
     private Assembly assembly;
 
     /** List of parametersInConfiguration, which is part of this configuration. */
-    @OneToMany(mappedBy = "configuration", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "configuration", cascade = CascadeType.ALL)
     private List<ParameterInConfiguration> parametersInConfiguration;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/Function.java b/src/main/java/vldc/aswi/domain/Function.java
index 619399ac..e7f58502 100644
--- a/src/main/java/vldc/aswi/domain/Function.java
+++ b/src/main/java/vldc/aswi/domain/Function.java
@@ -26,11 +26,11 @@ public class Function extends EntityParent {
     private String name;
 
     /** List of parameters, which defined that this function can be used. */
-    @ManyToMany(mappedBy = "functions", cascade = {CascadeType.ALL})
+    @ManyToMany(mappedBy = "functions")
     private List<Parameter> parameters;
 
     /** List of parametersInConfigurations, which using this function. */
-    @ManyToMany(mappedBy = "functions", cascade = {CascadeType.ALL})
+    @ManyToMany(mappedBy = "functions")
     private List<ParameterInConfiguration> parametersInConfigurations;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/Location.java b/src/main/java/vldc/aswi/domain/Location.java
index 05bf1c38..a279e2e3 100644
--- a/src/main/java/vldc/aswi/domain/Location.java
+++ b/src/main/java/vldc/aswi/domain/Location.java
@@ -23,11 +23,11 @@ public class Location extends EntityParent {
     private String name;
 
     /** List of parameters which allows this location. */
-    @ManyToMany(mappedBy = "locations", cascade = {CascadeType.ALL})
+    @ManyToMany(mappedBy = "locations")
     private List<Parameter> parameters;
 
     /** List of parametersInConfiguration which using this location. */
-    @OneToMany(mappedBy = "location", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "location")
     private List<ParameterInConfiguration> parametersInConfiguration;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/Operator.java b/src/main/java/vldc/aswi/domain/Operator.java
index ff61fb1d..c0dfb66e 100644
--- a/src/main/java/vldc/aswi/domain/Operator.java
+++ b/src/main/java/vldc/aswi/domain/Operator.java
@@ -23,11 +23,11 @@ public class Operator extends EntityParent {
     private String name;
 
     /** List of parameters which allowing this operator to be used. */
-    @ManyToMany(mappedBy = "operators", cascade = {CascadeType.ALL})
+    @ManyToMany(mappedBy = "operators")
     private List<Parameter> parameters;
 
     /** List of parametersInConfiguration using this operator. */
-    @OneToMany(mappedBy = "operator", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "operator")
     private List<ParameterInConfiguration> parametersInConfiguration;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/Role.java b/src/main/java/vldc/aswi/domain/Role.java
index a20e2fb6..723ddce9 100644
--- a/src/main/java/vldc/aswi/domain/Role.java
+++ b/src/main/java/vldc/aswi/domain/Role.java
@@ -21,11 +21,11 @@ public class Role extends EntityParent {
     private String name;
 
     /** List of assemblies, which using this role. */
-    @ManyToMany(mappedBy = "roles", cascade = {CascadeType.ALL})
+    @ManyToMany(mappedBy = "roles")
     private List<Assembly> assemblies;
 
     /** List of users with this role. */
-    @OneToMany(mappedBy = "role", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "role")
     private List<User> users;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/User.java b/src/main/java/vldc/aswi/domain/User.java
index a959a04f..ffc4900d 100644
--- a/src/main/java/vldc/aswi/domain/User.java
+++ b/src/main/java/vldc/aswi/domain/User.java
@@ -27,12 +27,12 @@ public class User extends EntityParent {
     private String password;
 
     /** Role of user. */
-    @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name = "role_id")
     private Role role;
 
     /** List of user configurations. */
-    @OneToMany(mappedBy = "user", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "user")
     private List<Configuration> configurations;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/parameter/Parameter.java b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
index 5c8a206f..7cc74830 100644
--- a/src/main/java/vldc/aswi/domain/parameter/Parameter.java
+++ b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
@@ -25,12 +25,12 @@ public class Parameter extends EntityParent {
     private String nameOfSelect;
 
     /** Specific assembly, in which this parameter will be part of. */
-    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch = FetchType.LAZY)
     @JoinColumn(name = "sestava_id")
     private Assembly assembly;
 
     /** Specific type of parameter, which represents type of entry. */
-    @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name = "parametr_typ_id")
     private ParameterType parameterType;
 
@@ -39,18 +39,18 @@ public class Parameter extends EntityParent {
     private String defaultValue;
 
     /** List of parametersInConfiguration, which using this parameter. */
-    @OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "parameter", cascade = CascadeType.ALL)
     private List<ParameterInConfiguration> parametersInConfiguration;
 
     /** List of parametersInConfiguration, which using this parameter. */
-    @OneToMany(mappedBy = "parameter", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "parameter", cascade = CascadeType.ALL)
     private List<ParameterValue> parameterValues;
 
     /**
      * Creating new table with M:N relationship between Parameter and Location.
      * Specify which locations can be used for parameter.
      */
-    @ManyToMany(cascade = {CascadeType.ALL})
+    @ManyToMany(cascade = CascadeType.PERSIST)
     @JoinTable(
             name = "Parametr_ma_Umisteni",
             joinColumns = @JoinColumn(name = "parametr_id"),
@@ -62,7 +62,7 @@ public class Parameter extends EntityParent {
      * Creating new table with M:N relationship between Parameter and Function.
      * Specify which functions can be used for parameter.
      */
-    @ManyToMany(cascade = {CascadeType.ALL})
+    @ManyToMany(cascade = CascadeType.PERSIST)
     @JoinTable(
             name = "Parametr_ma_Funkce",
             joinColumns = @JoinColumn(name = "parametr_id"),
@@ -74,7 +74,7 @@ public class Parameter extends EntityParent {
      * Creating new table with M:N relationship between Parameter and Operator.
      * Specify which operators can be used for parameter.
      */
-    @ManyToMany(cascade = {CascadeType.ALL})
+    @ManyToMany(cascade = CascadeType.PERSIST)
     @JoinTable(
             name = "Parametr_ma_Operator",
             joinColumns = @JoinColumn(name = "parametr_id"),
@@ -112,4 +112,31 @@ public class Parameter extends EntityParent {
     public boolean equals(Object obj) {
         return super.equals(obj);
     }
+
+    /**
+     * Remove function from parameter in 'Parametr_ma_Funkce' table.
+     * @param function - Function to be removed.
+     */
+    public void removeFunction(Function function) {
+        functions.remove(function);
+        function.getParameters().remove(this);
+    }
+
+    /**
+     * Remove operator from parameter in 'Parametr_ma_Operator' table.
+     * @param operator - Operator to be removed.
+     */
+    public void removeOperator(Operator operator) {
+        operators.remove(operator);
+        operator.getParameters().remove(this);
+    }
+
+    /**
+     * Remove location from parameter in 'Parametr_ma_Umisteni' table.
+     * @param location - Location to be removed.
+     */
+    public void removeLocation(Location location) {
+        locations.remove(location);
+        location.getParameters().remove(this);
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
index 42a50a25..97807a81 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
@@ -20,7 +20,7 @@ import java.util.List;
 public class ParameterInConfiguration extends EntityParent {
 
     /** Specific configuration in which is this parameterConfiguration presented. */
-    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch = FetchType.LAZY)
     @JoinColumn(name = "konfigurace_id")
     private Configuration configuration;
 
@@ -34,7 +34,7 @@ public class ParameterInConfiguration extends EntityParent {
     private String operatorValue;
 
     /** Specific location in which this parameterConfiguration will be used. */
-    @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name = "umisteni_id")
     private Location location;
 
@@ -43,7 +43,7 @@ public class ParameterInConfiguration extends EntityParent {
     private String columnName;
 
     /** Specific operator which will be aplied onto data. */
-    @ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch=FetchType.LAZY)
     @JoinColumn(name = "operator_id")
     private Operator operator;
 
@@ -51,7 +51,7 @@ public class ParameterInConfiguration extends EntityParent {
      * Creating new table with M:N relationship between ParameterInConfiguration and Function.
      * On every ParameterInConfiguration can be applied 0 - every function.
      */
-    @ManyToMany(cascade = {CascadeType.ALL})
+    @ManyToMany(cascade = CascadeType.PERSIST)
     @JoinTable(
             name = "Parametr_konfigurace_ma_Funkce",
             joinColumns = @JoinColumn(name = "parametr_konfigurace_id"),
@@ -87,4 +87,13 @@ public class ParameterInConfiguration extends EntityParent {
     public String toString() {
         return "ParameterInConfiguration[]";
     }
+
+    /**
+     * Remove function from parameter in 'Parametr_Konfigurace_ma_Funkce' table.
+     * @param function - Function to be removed.
+     */
+    public void removeFunction(Function function) {
+        functions.remove(function);
+        function.getParametersInConfigurations().remove(this);
+    }
 }
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
index 966f42b3..38001caa 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 {
     private String name;
 
     /** List of parameterInConfigurations, which using this parameter type. */
-    @OneToMany(mappedBy = "parameterType", cascade = {CascadeType.ALL})
+    @OneToMany(mappedBy = "parameterType")
     private List<Parameter> parameters;
 
     /**
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
index d7920846..d7ecb820 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
@@ -17,7 +17,7 @@ import javax.persistence.*;
 public class ParameterValue extends EntityParent {
 
     /** Specific parameter which can use this value. */
-    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
+    @ManyToOne(fetch = FetchType.LAZY)
     @JoinColumn(name = "parametr_id")
     private Parameter parameter;
 
diff --git a/src/main/java/vldc/aswi/service/AssemblyManager.java b/src/main/java/vldc/aswi/service/AssemblyManager.java
index 010ec025..177522e0 100644
--- a/src/main/java/vldc/aswi/service/AssemblyManager.java
+++ b/src/main/java/vldc/aswi/service/AssemblyManager.java
@@ -44,4 +44,11 @@ public interface AssemblyManager {
      * @return ID of assembly.
      */
     Long createAssembly(Assembly assemblyValues);
+
+    /**
+     * Delete assembly with ID.
+     * @param id - ID of assembly.
+     * @return True if delete was successful, otherwise false.
+     */
+    boolean deleteAssembly(Long id);
 }
diff --git a/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java b/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
index 2b3f846e..fc241478 100644
--- a/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
@@ -10,8 +10,10 @@ import vldc.aswi.dao.AssemblyRepository;
 import vldc.aswi.dao.RoleRepository;
 import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.Role;
+import vldc.aswi.service.parameter.ParameterManager;
 
 import javax.transaction.Transactional;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -26,9 +28,18 @@ public class AssemblyManagerImpl implements AssemblyManager {
     @Autowired
     private AssemblyRepository assemblyRepository;
 
+    /** Autowired role repository. */
     @Autowired
     private RoleRepository roleRepository;
 
+    /** Autowired configuration manager. */
+    @Autowired
+    private ConfigurationManager configurationManager;
+
+    /** Autowired parameter manager. */
+    @Autowired
+    private ParameterManager parameterManager;
+
     /**
      * Initialization setup for assembly manager. Check if assembly repository contains
      * records and if not, initialize default values.
@@ -106,24 +117,26 @@ public class AssemblyManagerImpl implements AssemblyManager {
         Assembly assembly = getAssemblyById(id);
         List<Role> currentRoles = assembly.getRoles();
 
-        // Find new roles.
-        List<Role> currentRolesNew = new LinkedList<>(currentRoles);
-        List<Role> updatedRolesNew = new LinkedList<>(updatedRoles);
-        updatedRolesNew.removeAll(currentRolesNew);
+        if (updatedRoles != null) {
+            // Find new roles.
+            List<Role> currentRolesNew = new LinkedList<>(currentRoles);
+            List<Role> updatedRolesNew = new LinkedList<>(updatedRoles);
+            updatedRolesNew.removeAll(currentRolesNew);
 
-        // Find deleted roles.
-        List<Role> currentRolesDeleted = new LinkedList<>(currentRoles);
-        List<Role> updatedRolesDeleted = new LinkedList<>(updatedRoles);
-        currentRolesDeleted.removeAll(updatedRolesDeleted);
+            // Find deleted roles.
+            List<Role> currentRolesDeleted = new LinkedList<>(currentRoles);
+            List<Role> updatedRolesDeleted = new LinkedList<>(updatedRoles);
+            currentRolesDeleted.removeAll(updatedRolesDeleted);
 
-        // If no role has been deleted or added, then updating is unnecessary.
-        if (updatedRolesNew.size() == 0 && currentRolesDeleted.size() == 0) return;
+            // If no role has been deleted or added, then updating is unnecessary.
+            if (updatedRolesNew.size() == 0 && currentRolesDeleted.size() == 0) return;
 
-        // Add new roles and remove deleted roles.
-        for (Role newRole : updatedRolesNew) {
-            currentRoles.add(this.roleRepository.getById(newRole.getId()));
+            // Add new roles and remove deleted roles.
+            for (Role newRole : updatedRolesNew) {
+                currentRoles.add(this.roleRepository.getById(newRole.getId()));
+            }
+            currentRoles.removeAll(currentRolesDeleted);
         }
-        currentRoles.removeAll(currentRolesDeleted);
 
         // Save updates to database.
         this.assemblyRepository.save(assembly);
@@ -136,12 +149,19 @@ public class AssemblyManagerImpl implements AssemblyManager {
      */
     @Override
     public Long createAssembly(Assembly assemblyValues) {
-        // TODO: test it.
         // Create new assembly and assign values.
         Assembly assembly = new Assembly();
         assembly.setName(assemblyValues.getName());
         assembly.setSQLQuery(assemblyValues.getSQLQuery());
-        assembly.setAssemblyOrder(this.assemblyRepository.findFirst1ByOrderByAssemblyOrder().getAssemblyOrder() + 1);
+
+        Assembly lastAssembly = this.assemblyRepository.findFirst1ByOrderByAssemblyOrder();
+        int order = 1;
+
+        if (lastAssembly != null) {
+            order = lastAssembly.getAssemblyOrder() + 1;
+        }
+
+        assembly.setAssemblyOrder(order);
         assembly.setIsPublic(assemblyValues.getIsPublic());
         List<Role> roles = new LinkedList<>();
 
@@ -159,4 +179,35 @@ public class AssemblyManagerImpl implements AssemblyManager {
 
         return assembly.getId();
     }
+
+    /**
+     * Delete assembly with ID.
+     * @param id - ID of assembly.
+     * @return True if delete was successful, otherwise false.
+     */
+    @Override
+    public boolean deleteAssembly(Long id) {
+        try {
+            // Delete configurations, which using current assembly.
+            this.configurationManager.deleteConfigurations(id);
+
+            // Delete parameters in current assembly.
+            this.parameterManager.deleteParameters(id);
+
+            Assembly assembly = this.assemblyRepository.getById(id);
+
+            // Remove roles from 'Sestava_ma_Role' table.
+            List<Role> roleList = new ArrayList<>(assembly.getRoles());
+            for (Role role : roleList) {
+                assembly.removeRole(role);
+            }
+
+            // Delete assembly.
+            this.assemblyRepository.delete(assembly);
+            // TODO: Send message for all users using this assembly.
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
 }
diff --git a/src/main/java/vldc/aswi/service/ConfigurationManager.java b/src/main/java/vldc/aswi/service/ConfigurationManager.java
index c3b1d450..9399c0af 100644
--- a/src/main/java/vldc/aswi/service/ConfigurationManager.java
+++ b/src/main/java/vldc/aswi/service/ConfigurationManager.java
@@ -30,4 +30,18 @@ public interface ConfigurationManager {
      * @return saved configuration
      */
     Configuration saveConfiguration(Configuration newConfiguration, String id);
+
+    /**
+     * Delete single configuration by id.
+     * @param id - ID of configuration.
+     * @return True if deleting was successful, false if not.
+     */
+    boolean deleteConfiguration(Long id);
+
+    /**
+     * Delete all configurations by assembly id.
+     * @param assemblyId - ID of assembly.
+     * @return True if all configurations were successfully deleted, false if not.
+     */
+    boolean deleteConfigurations(Long assemblyId);
 }
diff --git a/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java b/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
index 85309626..9ff1df53 100644
--- a/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java
@@ -13,6 +13,8 @@ import vldc.aswi.domain.Assembly;
 import vldc.aswi.domain.Configuration;
 import vldc.aswi.domain.Function;
 import vldc.aswi.domain.parameter.ParameterInConfiguration;
+import vldc.aswi.service.parameter.ParameterInConfigurationManager;
+import vldc.aswi.service.parameter.ParameterTypeManager;
 
 import javax.transaction.Transactional;
 import java.util.ArrayList;
@@ -43,9 +45,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
     @Autowired
     private LocationRepository locationRepository;
 
-    /** Autowired parameter type repository. */
+    /** Autowired parameter type manager. */
     @Autowired
-    private ParameterTypeRepository parameterTypeRepository;
+    private ParameterTypeManager parameterTypeRepository;
 
     /** Autowired function repository. */
     @Autowired
@@ -55,6 +57,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
     @Autowired
     private UserRepository userRepository;
 
+    /** Autowired parameter in configuration manager. */
+    @Autowired
+    private ParameterInConfigurationManager parameterInConfigurationManager;
+
     /**
      * Initialization setup for configuration manager. Check if configuration repository contains
      * records and if not, initialize default values.
@@ -108,6 +114,44 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
         }
     }
 
+    /**
+     * Delete single configuration by id.
+     * @param id - ID of configuration.
+     * @return True if deleting was successful, false if not.
+     */
+    @Override
+    public boolean deleteConfiguration(Long id) {
+        try {
+            this.parameterInConfigurationManager.deleteParametersInConfiguration(id);
+            this.configurationRepository.deleteById(id);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    /**
+     * Delete all configurations by assembly id.
+     * @param assemblyId - ID of assembly.
+     * @return True if all configurations were successfully deleted, false if not.
+     */
+    @Override
+    public boolean deleteConfigurations(Long assemblyId) {
+        try {
+            // Delete parameters in current configuration.
+            List<Configuration> configurations = this.configurationRepository.getByAssemblyId(assemblyId);
+            for (Configuration configuration : configurations) {
+                this.parameterInConfigurationManager.deleteParametersInConfiguration(configuration.getId());
+            }
+
+            // Delete configuration.
+            this.configurationRepository.deleteAll(configurations);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
     /**
      * Saves new configuration into database
      * @param newConfiguration container with data for a new configuration
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManager.java b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManager.java
index 7417774d..aa507f59 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManager.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManager.java
@@ -11,7 +11,14 @@ public interface ParameterInConfigurationManager {
 
     /**
      * Get all parameter in configuration from database.
-     * @return List of parameter in configuration.
+     * @return List of parameters in configuration.
      */
     List<ParameterInConfiguration> getAllParameterInConfiguration();
+
+    /**
+     * Delete all parameters in configuration by configuration id.
+     * @param configurationID - ID of configuration.
+     * @return True if all parameters in configuration was deleted, false if not.
+     */
+    boolean deleteParametersInConfiguration(Long configurationID);
 }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
index 990bd5f1..261ee282 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
@@ -7,9 +7,11 @@ import org.springframework.context.event.EventListener;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Service;
 import vldc.aswi.dao.parameter.ParameterInConfigurationRepository;
+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;
 
@@ -50,4 +52,29 @@ public class ParameterInConfigurationManagerImpl implements ParameterInConfigura
         this.parameterInConfigurationRepository.findAll().forEach(retVal::add);
         return retVal;
     }
+
+    /**
+     * Delete all parameters in configuration by configuration id.
+     * @param configurationID - ID of configuration.
+     * @return List of deleted parameters in configuration.
+     */
+    public boolean deleteParametersInConfiguration(Long configurationID) {
+        try {
+            List<ParameterInConfiguration> parameterInConfigurations = this.parameterInConfigurationRepository.getAllByConfigurationId(configurationID);
+            for (ParameterInConfiguration parameterInConfiguration : parameterInConfigurations) {
+
+                // Delete all functions used in current parameter in table 'Parametr_Konfigurace_ma_Funkce'.
+                List<Function> functionList = new ArrayList<>(parameterInConfiguration.getFunctions());
+                for (Function function : functionList) {
+                    parameterInConfiguration.removeFunction(function);
+                }
+            }
+
+            // Delete all parameters in configuration.
+            this.parameterInConfigurationRepository.deleteAll(parameterInConfigurations);
+            return true;
+        } catch (Exception e) {
+            return  false;
+        }
+    }
 }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterManager.java b/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
index 1812fd40..a246090b 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
@@ -28,4 +28,11 @@ public interface ParameterManager {
      * @param newAssemblyParameters - List of parameters.
      */
     void updateParameters(Long assemblyId, List<Parameter> newAssemblyParameters);
+
+    /**
+     * Delete parameters by assembly id.
+     * @param assemblyId - ID of assembly.
+     * @return true if all parameters was successfully deleted, false if not.
+     */
+    boolean deleteParameters(Long assemblyId);
 }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
index f207e925..97817a0e 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
@@ -18,6 +18,7 @@ import vldc.aswi.domain.parameter.Parameter;
 import vldc.aswi.domain.parameter.ParameterValue;
 
 import javax.transaction.Transactional;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -157,40 +158,43 @@ public class ParameterManagerImpl implements ParameterManager {
         Assembly assembly = this.assemblyRepository.getById(assemblyId);
         List<Parameter> currentAssemblyParameters = assembly.getParameters();
 
-        // Find new parameters.
-        List<Parameter> currentAssemblyParametersNew = new LinkedList<>(currentAssemblyParameters);
-        List<Parameter> newAssemblyParametersNew = new LinkedList<>(newAssemblyParameters);
-        newAssemblyParametersNew.removeAll(currentAssemblyParametersNew);
-
-        // Find deleted parameters.
-        List<Parameter> currentAssemblyParametersDeleted = new LinkedList<>(currentAssemblyParameters);
-        List<Parameter> newAssemblyParametersDeleted = new LinkedList<>(newAssemblyParameters);
-        currentAssemblyParametersDeleted.removeAll(newAssemblyParametersDeleted);
-
-        // Find duplicate elements - for updating.
-        List<Parameter> currentAssemblyParametersUpdated = new LinkedList<>(currentAssemblyParameters);
-        List<Parameter> newAssemblyParametersUpdated = new LinkedList<>(newAssemblyParameters);
-        newAssemblyParametersUpdated.retainAll(currentAssemblyParametersUpdated);
-
-        // If no parameter has been deleted or added, then updating is unnecessary.
-        if (newAssemblyParametersNew.size() == 0 && currentAssemblyParametersDeleted.size() == 0 && newAssemblyParametersUpdated.size() == 0) return;
-
-        // Remove deleted parameters.
-        for (Parameter parameter : currentAssemblyParametersDeleted) {
-            for (ParameterValue parameterValue : parameter.getParameterValues()) {
-                // Remove parameters values.
-                this.parameterValueRepository.delete(parameterValue);
-            }
+        if (newAssemblyParameters != null) {
+            // Find new parameters.
+            List<Parameter> currentAssemblyParametersNew = new LinkedList<>(currentAssemblyParameters);
+            List<Parameter> newAssemblyParametersNew = new LinkedList<>(newAssemblyParameters);
+            newAssemblyParametersNew.removeAll(currentAssemblyParametersNew);
+
+            // Find deleted parameters.
+            List<Parameter> currentAssemblyParametersDeleted = new LinkedList<>(currentAssemblyParameters);
+            List<Parameter> newAssemblyParametersDeleted = new LinkedList<>(newAssemblyParameters);
+            currentAssemblyParametersDeleted.removeAll(newAssemblyParametersDeleted);
+
+            // Find duplicate elements - for updating.
+            List<Parameter> currentAssemblyParametersUpdated = new LinkedList<>(currentAssemblyParameters);
+            List<Parameter> newAssemblyParametersUpdated = new LinkedList<>(newAssemblyParameters);
+            newAssemblyParametersUpdated.retainAll(currentAssemblyParametersUpdated);
+
+            // If no parameter has been deleted or added, then updating is unnecessary.
+            if (newAssemblyParametersNew.size() == 0 && currentAssemblyParametersDeleted.size() == 0 && newAssemblyParametersUpdated.size() == 0)
+                return;
+
+            // Remove deleted parameters.
+            for (Parameter parameter : currentAssemblyParametersDeleted) {
+                for (ParameterValue parameterValue : parameter.getParameterValues()) {
+                    // Remove parameters values.
+                    this.parameterValueRepository.delete(parameterValue);
+                }
 
-            // Remove parameter.
-            this.parameterRepository.delete(parameter);
-        }
+                // Remove parameter.
+                this.parameterRepository.delete(parameter);
+            }
 
-        // Update rest parameters.
-        updateParameters(newAssemblyParametersUpdated);
+            // Update rest parameters.
+            updateParameters(newAssemblyParametersUpdated);
 
-        // Add new parameters
-        addParameters(assemblyId, newAssemblyParametersNew);
+            // Add new parameters
+            addParameters(assemblyId, newAssemblyParametersNew);
+        }
     }
 
     /**
@@ -391,4 +395,41 @@ public class ParameterManagerImpl implements ParameterManager {
             this.parameterValueRepository.save(parameterValue);
         }
     }
-}
+
+    /**
+     * Delete parameters by assembly id.
+     * @param assemblyId - ID of assembly.
+     */
+    @Override
+    public boolean deleteParameters(Long assemblyId) {
+        try {
+            List<Parameter> parameters = this.parameterRepository.getByAssemblyId(assemblyId);
+
+            for (Parameter parameter : parameters) {
+                // Delete all functions from parameter in table 'Parametr_ma_Funkce'.
+                List<Function> functionList = new ArrayList<>(parameter.getFunctions());
+                for (Function function : functionList) {
+                    parameter.removeFunction(function);
+                }
+
+                // Delete all operators from parameter in table 'Parametr_ma_Operator'.
+                List<Operator> operatorList = new ArrayList<>(parameter.getOperators());
+                for (Operator operator : operatorList) {
+                    parameter.removeOperator(operator);
+                }
+
+                // Delete all locations from parameter in table 'Parametr_ma_Umisteni'.
+                List<Location> locationList = new ArrayList<>(parameter.getLocations());
+                for (Location location : locationList) {
+                    parameter.removeLocation(location);
+                }
+            }
+
+            // Delete all parameters.
+            this.parameterRepository.deleteAll(parameters);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/vldc/aswi/utils/Utils.java b/src/main/java/vldc/aswi/utils/Utils.java
new file mode 100644
index 00000000..47e98416
--- /dev/null
+++ b/src/main/java/vldc/aswi/utils/Utils.java
@@ -0,0 +1,20 @@
+package vldc.aswi.utils;
+
+/**
+ * Class for utilites.
+ */
+public class Utils {
+
+    /**
+     * Try to parse Long from String.
+     * @param number - Number in string.
+     * @return Long value if parsing was successful, null in case of error.
+     */
+    public static Long tryParseLong(String number) {
+        try {
+            return Long.parseLong(number);
+        } catch (Exception e) {
+            return null;
+        }
+    }
+}
diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 0cc1fff5..c0317fdf 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -22,6 +22,7 @@ import vldc.aswi.service.*;
 import vldc.aswi.service.parameter.ParameterManager;
 import vldc.aswi.service.parameter.ParameterTypeManager;
 import vldc.aswi.validators.AssemblyValidator;
+import vldc.aswi.utils.Utils;
 
 import javax.validation.Valid;
 import java.util.ArrayList;
@@ -68,9 +69,6 @@ public class AssemblyController extends BasicController {
     @Autowired
     private AssemblyValidator assemblyValidator;
 
-    @Autowired
-    private ConfigurationManager configurationManager;
-
     /** Name of thymeleaf parameter, which will contain text in assembly form. */
     private String assemblyTitleName = "title";
 
@@ -92,8 +90,13 @@ public class AssemblyController extends BasicController {
         binder.addValidators(this.assemblyValidator);
     }
 
+    /**
+     * Get method for form, where configuration is created from assembly.
+     * @param id - ID of assembly.
+     * @return ModelAndView for assembly.
+     */
     @GetMapping("/assembly")
-    public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) {
+    public ModelAndView assemblyGet(@Valid @ModelAttribute("assemblyID") String id) {
         ModelAndView modelAndView = new ModelAndView("assembly");
 
         ModelMap modelMap = modelAndView.getModelMap();
@@ -119,56 +122,16 @@ public class AssemblyController extends BasicController {
         return modelAndView;
     }
 
-    /**
-     * 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));
-
-        initializeFields(configuration);
-
-        modelMap.addAttribute("configuration", configuration);
-        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
+     * Post method for form, where configuration is created from assembly.
+     * @param assembly - Assembly values.
+     * @param bindingResult - Error results from assembly validators.
+     * @param atts - Redirect attributes.
+     * @return ModelAndView for assembly.
      */
-    @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);
-
-        initializeFields(configuration);
-
-        modelAndView.setViewName("redirect:/configuration?configurationID=" + configuration.getId());
-
-        return modelAndView;
-    }
-
     @PostMapping("/assembly")
-    public ModelAndView indexPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) {
+    public ModelAndView assemblyPost(@Valid Assembly assembly, BindingResult bindingResult, RedirectAttributes atts) {
         ModelAndView modelAndView = new ModelAndView();
 
         ModelMap modelMap = modelAndView.getModelMap();
@@ -185,13 +148,33 @@ public class AssemblyController extends BasicController {
         return modelAndView;
     }
 
+    /**
+     * Get method for assembly delete.
+     * @param id - ID of assembly.
+     * @return ModelAndView for index.
+     */
+    @GetMapping("/assembly_delete")
+    public ModelAndView assemblyDeleteGet(@RequestParam("assemblyID") String id) {
+        ModelAndView modelAndView = new ModelAndView("redirect:/");
+
+        Long assemblyId = Utils.tryParseLong(id);
+
+        if (assemblyId == null) {
+            // TODO: print error in index.
+        }
+        boolean success = this.assemblyManager.deleteAssembly(assemblyId);
+        // TODO: check success.
+
+        return modelAndView;
+    }
+
     /**
      * Get method for assembly edit.
      * @param id - Id of assembly.
      * @return ModelAndView for assembly edit.
      */
     @GetMapping("/assembly_edit")
-    public ModelAndView assemblyEditIndex(@Valid @ModelAttribute("assemblyID") String id) {
+    public ModelAndView assemblyEditGet(@Valid @ModelAttribute("assemblyID") String id) {
         ModelAndView modelAndView = new ModelAndView("assembly_manage");
 
         ModelMap modelMap = modelAndView.getModelMap();
@@ -219,7 +202,7 @@ public class AssemblyController extends BasicController {
      * @return ModelAndView for assembly edit.
      */
     @PostMapping("/assembly_edit")
-    public ModelAndView assemblyEditPostIndex(@Valid @ModelAttribute("assembly") Assembly assembly, BindingResult result,
+    public ModelAndView assemblyEditPost(@Valid @ModelAttribute("assembly") Assembly assembly, BindingResult result,
                                               @Valid @ModelAttribute("checkboxPublic") String assemblyIsPublic) {
 
         ModelAndView modelAndView = new ModelAndView("assembly_manage");
@@ -258,7 +241,7 @@ public class AssemblyController extends BasicController {
      * @return ModelAndView for new assembly.
      */
     @GetMapping("/assembly_new")
-    public ModelAndView assemblyNewIndex() {
+    public ModelAndView assemblyNewGet() {
         ModelAndView modelAndView = new ModelAndView("assembly_manage");
 
         ModelMap modelMap = modelAndView.getModelMap();
@@ -283,51 +266,25 @@ public class AssemblyController extends BasicController {
      * @return
      */
     @PostMapping("/assembly_new")
-    public ModelAndView assemblyNewIndexPost(@Valid @ModelAttribute("assembly") Assembly assembly, BindingResult result) {
+    public ModelAndView assemblyNewPost(@Valid @ModelAttribute("assembly") Assembly assembly, BindingResult result) {
         ModelAndView modelAndView = new ModelAndView();
+        ModelMap modelMap = modelAndView.getModelMap();
 
         if (result.hasErrors()) {
-            ModelMap modelMap = modelAndView.getModelMap();
             modelAndView.setViewName("assembly_manage");
-
             modelMap.addAttribute("assembly", assembly);
 
-            modelMap.addAttribute(assemblyTitleName, assemblyNewTitleText);
             modelMap.addAttribute(assemblyErrorName, getFullErrorMessage(result));
-
-            modelMap.addAttribute("allRoles", this.roleManager.getRoles());
-            modelMap.addAttribute("allParameterTypes", this.parameterTypeManager.getParameterTypes());
-            modelMap.addAttribute("allFunctions", this.functionManager.getFunctions());
-            modelMap.addAttribute("allOperators", this.operatorManager.getOperators());
-            modelMap.addAttribute("allLocations", this.locationManager.getLocations());
+            modelMap.addAttribute(assemblyTitleName, assemblyNewTitleText);
         }
+        else {
+            // TODO: chybí získání default value.
+            Long assemblyId = this.assemblyManager.createAssembly(assembly);
+            this.parameterManager.addParameters(assemblyId, assembly.getParameters());
 
-        ModelMap modelMap = modelAndView.getModelMap();
-
-        // TODO: chybí získání default value.
-        Long assemblyId = this.assemblyManager.createAssembly(assembly);
-        this.parameterManager.addParameters(assemblyId, assembly.getParameters());
-
-        modelAndView.setViewName("redirect:/assembly_edit?assemblyID=" + assemblyId);
+            modelAndView.setViewName("redirect:/assembly_edit?assemblyID=" + assemblyId);
+        }
 
         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/java/vldc/aswi/web/controller/BasicController.java b/src/main/java/vldc/aswi/web/controller/BasicController.java
index c47c22c4..160b9584 100644
--- a/src/main/java/vldc/aswi/web/controller/BasicController.java
+++ b/src/main/java/vldc/aswi/web/controller/BasicController.java
@@ -20,14 +20,16 @@ public class BasicController {
             if (object instanceof FieldError) {
                 FieldError fieldError = (FieldError) object;
 
-                message += fieldError.getDefaultMessage() + ", ";
+                if (fieldError.getCode() == null) message += fieldError.getDefaultMessage() + ", ";
+                else message += fieldError.getCode() + ", ";
                 continue;
             }
 
             if (object instanceof ObjectError) {
                 ObjectError objectError = (ObjectError) object;
 
-                message += objectError.getDefaultMessage()  + ", ";
+                if (objectError.getCode() == null) message += objectError.getDefaultMessage() + ", ";
+                else message += objectError.getCode() + ", ";
                 continue;
             }
         }
diff --git a/src/main/java/vldc/aswi/web/controller/ConfigurationController.java b/src/main/java/vldc/aswi/web/controller/ConfigurationController.java
new file mode 100644
index 00000000..61219097
--- /dev/null
+++ b/src/main/java/vldc/aswi/web/controller/ConfigurationController.java
@@ -0,0 +1,118 @@
+package vldc.aswi.web.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+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 vldc.aswi.domain.Configuration;
+import vldc.aswi.domain.Location;
+import vldc.aswi.domain.Operator;
+import vldc.aswi.domain.parameter.ParameterInConfiguration;
+import vldc.aswi.service.ConfigurationManager;
+import vldc.aswi.utils.Utils;
+
+import javax.validation.Valid;
+import java.util.ArrayList;
+
+/**
+ * Manager for configuration.
+ */
+@Controller
+public class ConfigurationController extends BasicController{
+
+    /** Autowired configuration manager */
+    @Autowired
+    private ConfigurationManager configurationManager;
+
+    /**
+     * 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 configurationGet(@Valid @ModelAttribute("configurationID") String id) {
+        ModelAndView modelAndView = new ModelAndView("assembly");
+
+        ModelMap modelMap = modelAndView.getModelMap();
+
+        Configuration configuration = configurationManager.getConfigurationById(Long.parseLong(id));
+
+        initializeFields(configuration);
+
+        modelMap.addAttribute("configuration", configuration);
+        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 configurationPost(@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);
+
+        initializeFields(configuration);
+
+        modelAndView.setViewName("redirect:/configuration?configurationID=" + configuration.getId());
+
+        return modelAndView;
+    }
+
+    /**
+     * Get method for configuration delete.
+     * @param id - ID of configuration.
+     * @return ModelAndView for index.
+     */
+    @GetMapping("/configuration_delete")
+    public ModelAndView configurationDeleteGet(@RequestParam("configurationID") String id) {
+        ModelAndView modelAndView = new ModelAndView("redirect:/");
+
+        Long configurationId = Utils.tryParseLong(id);
+
+        if (configurationId == null) {
+            // TODO: print error in index.
+        }
+
+        boolean success = this.configurationManager.deleteConfiguration(configurationId);
+        // TODO: check success.
+
+        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_manage.html b/src/main/webapp/WEB-INF/templates/assembly_manage.html
index b799788b..2ef19597 100644
--- a/src/main/webapp/WEB-INF/templates/assembly_manage.html
+++ b/src/main/webapp/WEB-INF/templates/assembly_manage.html
@@ -169,7 +169,7 @@
     </div>
     <div th:each="roleWithAccess, i : ${assembly.roles}" class="input-action-box input-border-bottom">
       <input type="hidden" th:field="${assembly.roles[__${i.index}__].id}" th:value="${roleWithAccess.id}">
-      <input type="text" readonly class="form-control-plaintext" th:field="${assembly.roles[__${i.index}__].name}" th:id="selectedRole + ${roleWithAccess.name}" th:value="${roleWithAccess.name}">
+      <input type="text" readonly class="form-control-plaintext" th:field="${assembly.roles[__${i.index}__].name}" th:id="${roleWithAccess.name}" th:value="${roleWithAccess.name}">
 
       <span class="action-padding input-action-margin sort-icon">
       <i class="fas fa-sort"></i>
diff --git a/src/main/webapp/WEB-INF/templates/index.html b/src/main/webapp/WEB-INF/templates/index.html
index da839c76..fb151b13 100644
--- a/src/main/webapp/WEB-INF/templates/index.html
+++ b/src/main/webapp/WEB-INF/templates/index.html
@@ -42,7 +42,7 @@
 						<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>
+					<a th:href="@{/configuration_delete(configurationID=${iconfiguration.id})}" class="action-link far fa-trash-alt"></a>
 				  </span>
 						</td>
 					</tr>
@@ -80,7 +80,7 @@
 									  <a th:href="@{/assembly_edit(assemblyID=${iassembly.id})}" class="action-link far fa-edit"></a>
 									</span>
 									<span class="action-button">
-									  <a href=# class="action-link far fa-trash-alt"></a>
+									  <a th:href="@{/assembly_delete(assemblyID=${iassembly.id})}" class="action-link far fa-trash-alt"></a>
 									</span>
 
 									<i class="fas fa-sort"></i>
