commit ba8b306a0cbbb4525425f6b91d3c39375cf6aa06
Author: Vojtěch Danišík <32537562+danisik@users.noreply.github.com>
Date:   Fri Apr 24 00:53:04 2020 +0200

    re #7886 Assembly validator in progress (validating assembly SQLQuery + locations for existing assembly, not tested for new assembly).
    Added comments.
    Removing unused imports.

diff --git a/src/main/java/vldc/aswi/AswiJpa.java b/src/main/java/vldc/aswi/AswiJpa.java
index 5463d123..396d470d 100644
--- a/src/main/java/vldc/aswi/AswiJpa.java
+++ b/src/main/java/vldc/aswi/AswiJpa.java
@@ -7,6 +7,9 @@ import org.springframework.context.annotation.Import;
 import vldc.aswi.configuration.AppConfig;
 import vldc.aswi.configuration.DbConfig;
 
+/**
+ * Main class.
+ */
 @SpringBootApplication
 @Import({
 	AppConfig.class,
@@ -14,6 +17,10 @@ import vldc.aswi.configuration.DbConfig;
 })
 public class AswiJpa {
 
+	/**
+	 * Main method.
+	 * @param args - Input arguments.
+	 */
 	public static void main(String[] args) {
 		SpringApplication.run(AswiJpa.class, args);
 	}
diff --git a/src/main/java/vldc/aswi/configuration/AppConfig.java b/src/main/java/vldc/aswi/configuration/AppConfig.java
index d4cdc1d9..8082dc75 100644
--- a/src/main/java/vldc/aswi/configuration/AppConfig.java
+++ b/src/main/java/vldc/aswi/configuration/AppConfig.java
@@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@@ -14,7 +13,6 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.web.util.matcher.RegexRequestMatcher;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -24,6 +22,9 @@ import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver;
 import org.thymeleaf.spring5.view.ThymeleafViewResolver;
 import org.thymeleaf.templatemode.TemplateMode;
 
+/**
+ * Application configuration.
+ */
 @Configuration
 @ComponentScan
 @EnableWebMvc
diff --git a/src/main/java/vldc/aswi/configuration/DbConfig.java b/src/main/java/vldc/aswi/configuration/DbConfig.java
index a1da2062..020b09a4 100644
--- a/src/main/java/vldc/aswi/configuration/DbConfig.java
+++ b/src/main/java/vldc/aswi/configuration/DbConfig.java
@@ -5,39 +5,61 @@ import javax.sql.DataSource;
 import com.sun.istack.NotNull;
 import oracle.jdbc.pool.OracleDataSource;
 import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.jdbc.DataSourceBuilder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 
 import java.sql.SQLException;
 
+/**
+ * Connection configuration for database.
+ */
 @Configuration
 @EnableTransactionManagement
 @ConfigurationProperties(prefix = "oracle")
 public class DbConfig {
 
+	/** Username of logging user. */
 	@NotNull
 	private String username;
 
+	/** Password of logging user. */
 	@NotNull
 	private String password;
 
+	/** TNS url for connection into database. */
 	@NotNull
 	private String url;
 
+	/**
+	 * Set new username.
+	 * @param username - User's name.
+	 */
 	public void setUsername(String username) {
 		this.username = username;
 	}
 
+	/**
+	 * Set new password.
+	 * @param password - User's password.
+	 */
 	public void setPassword(String password) {
 		this.password = password;
 	}
 
+	/**
+	 * Set new url.
+	 * @param url - TNS url for connection into database.
+	 */
 	public void setUrl(String url) {
 		this.url = url;
 	}
 
+	/**
+	 * Create new datasource.
+	 * @return new Datasource of currently logged database.
+	 * @throws SQLException
+	 */
 	@Bean
 	DataSource dataSource() throws SQLException {
 		OracleDataSource dataSource = new OracleDataSource();
diff --git a/src/main/java/vldc/aswi/dao/AssemblyRepository.java b/src/main/java/vldc/aswi/dao/AssemblyRepository.java
index 5ebe47f3..cccfb01e 100644
--- a/src/main/java/vldc/aswi/dao/AssemblyRepository.java
+++ b/src/main/java/vldc/aswi/dao/AssemblyRepository.java
@@ -1,6 +1,5 @@
 package vldc.aswi.dao;
 
-import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.repository.CrudRepository;
 import org.springframework.stereotype.Repository;
 import vldc.aswi.domain.Assembly;
@@ -18,6 +17,11 @@ public interface AssemblyRepository extends CrudRepository<Assembly, Long> {
      */
     Assembly getById(Long Id);
 
-    // TODO
+
+    /**
+     * Find record with highest order.
+     * @return Assembly with highest order.
+     */
+    // TODO: test it.
     Assembly findFirst1ByOrderByAssemblyOrder();
 }
diff --git a/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java b/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
index f490e7bc..a088c2f0 100644
--- a/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
+++ b/src/main/java/vldc/aswi/dao/parameter/ParameterTypeRepository.java
@@ -17,5 +17,10 @@ public interface ParameterTypeRepository extends CrudRepository<ParameterType, L
      */
     ParameterType getById(Long Id);
 
+    /**
+     * Find ParameterType by its name.
+     * @param name - ParameterType name
+     * @return ParameterType if name is present in database.
+     */
     ParameterType findByName(String name);
 }
diff --git a/src/main/java/vldc/aswi/database/DatabaseInterface.java b/src/main/java/vldc/aswi/database/DatabaseInterface.java
index bb9ef89f..b3f78eff 100644
--- a/src/main/java/vldc/aswi/database/DatabaseInterface.java
+++ b/src/main/java/vldc/aswi/database/DatabaseInterface.java
@@ -1,10 +1,8 @@
 package vldc.aswi.database;
 
-import org.springframework.context.annotation.Bean;
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.ResultSetExtractor;
-import org.springframework.jdbc.core.RowMapper;
 import org.springframework.stereotype.Component;
 import vldc.aswi.model.table.TableColumn;
 
@@ -16,15 +14,45 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * Class for manipulating (selecting, updating, creating, ...) database data.
+ */
 @Component
 public class DatabaseInterface {
 
+    /** JdbcTemplate for executing queries. */
     private JdbcTemplate jdbcTemplate = null;
 
+    /**
+     * Constructor.
+     * @param jdbcTemplate - JdbcTemplate for executing queries.
+     */
     public DatabaseInterface(JdbcTemplate jdbcTemplate) {
         this.jdbcTemplate = jdbcTemplate;
     }
 
+    /**
+     * Validate given SQLQuery.
+     * @param sqlQuery - Tested SQL Query.
+     * @return true if SQL query is valid, false if not.
+     */
+    public boolean validateSQLQuery(String sqlQuery) {
+        try
+        {
+            jdbcTemplate.execute("EXPLAIN PLAN FOR " + sqlQuery);
+            return true;
+        }
+        catch (DataAccessException e)
+        {
+            return false;
+        }
+    }
+
+    /**
+     * Execute given SQL Query and return results as list of TableColumn class.
+     * @param sqlQuery - SQL query.
+     * @return List of results saved as TableColumn.
+     */
     public Map<String, TableColumn> executeQueryAndReturnTableColumns(String sqlQuery) {
         return jdbcTemplate.query(
                 sqlQuery,
diff --git a/src/main/java/vldc/aswi/domain/Assembly.java b/src/main/java/vldc/aswi/domain/Assembly.java
index a23527bd..d468500e 100644
--- a/src/main/java/vldc/aswi/domain/Assembly.java
+++ b/src/main/java/vldc/aswi/domain/Assembly.java
@@ -65,6 +65,11 @@ public class Assembly extends EntityParent {
         this.setIsPublic(isPublic);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/Configuration.java b/src/main/java/vldc/aswi/domain/Configuration.java
index db1b334d..eb7ca3a5 100644
--- a/src/main/java/vldc/aswi/domain/Configuration.java
+++ b/src/main/java/vldc/aswi/domain/Configuration.java
@@ -49,6 +49,11 @@ public class Configuration extends EntityParent {
         this.setTableName(tableName);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/EntityParent.java b/src/main/java/vldc/aswi/domain/EntityParent.java
index 75a10b41..631b796c 100644
--- a/src/main/java/vldc/aswi/domain/EntityParent.java
+++ b/src/main/java/vldc/aswi/domain/EntityParent.java
@@ -3,11 +3,6 @@ package vldc.aswi.domain;
 import javax.persistence.*;
 
 import lombok.Data;
-import org.apache.poi.ss.formula.functions.T;
-import vldc.aswi.domain.parameter.Parameter;
-
-import java.util.LinkedList;
-import java.util.List;
 
 /**
  * Class which is extended for all domain entities containing common attributes.
@@ -22,6 +17,11 @@ public class EntityParent {
     @GeneratedValue(strategy=GenerationType.IDENTITY)
     private Long id;
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj)
     {
diff --git a/src/main/java/vldc/aswi/domain/Function.java b/src/main/java/vldc/aswi/domain/Function.java
index 0e065556..90940f4d 100644
--- a/src/main/java/vldc/aswi/domain/Function.java
+++ b/src/main/java/vldc/aswi/domain/Function.java
@@ -41,6 +41,11 @@ public class Function extends EntityParent {
         this.setName(name);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/Location.java b/src/main/java/vldc/aswi/domain/Location.java
index f5f85e74..81ac7104 100644
--- a/src/main/java/vldc/aswi/domain/Location.java
+++ b/src/main/java/vldc/aswi/domain/Location.java
@@ -38,6 +38,11 @@ public class Location extends EntityParent {
         this.setName(name);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/Operator.java b/src/main/java/vldc/aswi/domain/Operator.java
index 1bdf2751..f3083040 100644
--- a/src/main/java/vldc/aswi/domain/Operator.java
+++ b/src/main/java/vldc/aswi/domain/Operator.java
@@ -38,6 +38,11 @@ public class Operator extends EntityParent {
         this.setName(name);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/Role.java b/src/main/java/vldc/aswi/domain/Role.java
index 98e1ded2..f45a8530 100644
--- a/src/main/java/vldc/aswi/domain/Role.java
+++ b/src/main/java/vldc/aswi/domain/Role.java
@@ -36,6 +36,11 @@ public class Role extends EntityParent {
         this.setName(name);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/User.java b/src/main/java/vldc/aswi/domain/User.java
index 5a29672d..dac0f40c 100644
--- a/src/main/java/vldc/aswi/domain/User.java
+++ b/src/main/java/vldc/aswi/domain/User.java
@@ -45,6 +45,11 @@ public class User extends EntityParent {
         this.setPassword(password);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/parameter/Parameter.java b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
index 79e3fda2..9aa4236f 100644
--- a/src/main/java/vldc/aswi/domain/parameter/Parameter.java
+++ b/src/main/java/vldc/aswi/domain/parameter/Parameter.java
@@ -1,13 +1,8 @@
 package vldc.aswi.domain.parameter;
 
-import com.fasterxml.jackson.annotation.JsonBackReference;
-import com.fasterxml.jackson.annotation.JsonIdentityInfo;
-import com.fasterxml.jackson.annotation.JsonManagedReference;
-import com.fasterxml.jackson.annotation.ObjectIdGenerators;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
-import lombok.ToString;
 import vldc.aswi.domain.*;
 import javax.persistence.*;
 import java.util.List;
@@ -99,11 +94,20 @@ public class Parameter extends EntityParent {
         this.setDefaultValue(defaultValue);
     }
 
+    /**
+     * Overriding toString method to prevent StackOverflowError when parsing values from assembly form.
+     * @return Parameter info.
+     */
     @Override
     public String toString() {
         return "Parameter[name=" + name + ", nameOfSelect=" + nameOfSelect + ", defaultHodnota=" + defaultValue + "]";
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
index ba3bf6d1..476adebc 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterInConfiguration.java
@@ -66,6 +66,11 @@ public class ParameterInConfiguration extends EntityParent {
         this.setColumnName(columnName);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
index 8b2f78f2..517b7cb0 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterType.java
@@ -36,6 +36,11 @@ public class ParameterType extends EntityParent {
         this.setName(name);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
index 51f7fe8c..ab3d0d13 100644
--- a/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
+++ b/src/main/java/vldc/aswi/domain/parameter/ParameterValue.java
@@ -34,6 +34,11 @@ public class ParameterValue extends EntityParent {
         this.setValue(value);
     }
 
+    /**
+     * Equal method for comparing two objects.
+     * @param obj - Comparing object.
+     * @return true if objects are same.
+     */
     @Override
     public boolean equals(Object obj) {
         return super.equals(obj);
diff --git a/src/main/java/vldc/aswi/model/table/TableColumn.java b/src/main/java/vldc/aswi/model/table/TableColumn.java
index 8d15577b..7bed239b 100644
--- a/src/main/java/vldc/aswi/model/table/TableColumn.java
+++ b/src/main/java/vldc/aswi/model/table/TableColumn.java
@@ -3,25 +3,46 @@ package vldc.aswi.model.table;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * Class representing one table column.
+ */
 public class TableColumn {
 
+    /** Name of table column. */
     private String name;
 
+    /** List of values in current column. */
     private List<String> values;
 
+    /**
+     * Constructor.
+     * @param name - Name of table column.
+     */
     public TableColumn(String name) {
         this.name = name;
         values = new ArrayList<>();
     }
 
+    /**
+     * Add new value into list of values.
+     * @param value - New value.
+     */
     public void addValue(String value) {
         values.add(value);
     }
 
+    /**
+     * Get name of table column.
+     * @return Name of table column.
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Get all values in current table column.
+     * @return List of all values.
+     */
     public List<String> getValues() {
         return values;
     }
diff --git a/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRow.java b/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRow.java
index 00d89382..2d5458e1 100644
--- a/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRow.java
+++ b/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRow.java
@@ -3,14 +3,25 @@ package vldc.aswi.model.table.contingencyTable;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * Class representing one row in Contingency table. Rows are represented as tree with given level.
+ */
 public class ContingencyTableRow {
 
+    /** True if current row is header, false if not. */
     private boolean isHeader;
 
+    /** Level of current row. */
     private int level;
 
+    /** List of cells in current row. */
     private List<ContingencyTableRowCell> cells;
 
+    /**
+     * Constructor.
+     * @param isHeader - True if current row is header, false if not.
+     * @param level - Level of current row.
+     */
     public ContingencyTableRow(boolean isHeader, int level) {
         this.isHeader = isHeader;
         this.level = level;
@@ -18,22 +29,42 @@ public class ContingencyTableRow {
         cells = new ArrayList<>();
     }
 
+    /**
+     * Add new cell into current row.
+     * @param cell - New cell.
+     */
     public void addTableRowCell(ContingencyTableRowCell cell) {
         cells.add(cell);
     }
 
+    /**
+     * Check if current row is header or not.
+     * @return True if current row is header, false if not.
+     */
     public boolean isHeader() {
         return isHeader;
     }
 
+    /**
+     * Get level of current cell.
+     * @return
+     */
     public int getLevel() {
         return level;
     }
 
+    /**
+     * Get all cells in current row.
+     * @return List of cells.
+     */
     public List<ContingencyTableRowCell> getCells() {
         return cells;
     }
 
+    /**
+     * Overriding toString method for debugging.
+     * @return String.
+     */
     @Override
     public String toString() {
         String str = "";
diff --git a/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRowCell.java b/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRowCell.java
index 8fae87f6..254929ff 100644
--- a/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRowCell.java
+++ b/src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRowCell.java
@@ -1,24 +1,46 @@
 package vldc.aswi.model.table.contingencyTable;
 
+/**
+ * Class representing one cell in Contingency table row.
+ */
 public class ContingencyTableRowCell {
 
+    /** Colspan of current cell. */
     private int colSpan;
 
+    /** Value in current cell. */
     private String value;
 
+    /**
+     * Constructor.
+     * @param value - Value in current cell.
+     * @param colSpan - Colspan of current cell.
+     */
     public ContingencyTableRowCell(String value, int colSpan) {
         this.value = value;
         this.colSpan = colSpan;
     }
 
+    /**
+     * Get value of current cell.
+     * @return Value of cell.
+     */
     public String getValue() {
         return value;
     }
 
+    /**
+     * Get colspan of current cell.
+     * @return Colspan of cell.
+     */
     public int getColSpan() {
         return colSpan;
     }
 
+    /**
+     * Overrided toString method for debugging.
+     * @return String.
+     */
     @Override
     public String toString() {
         return "(" + value + ", " + colSpan + ")";
diff --git a/src/main/java/vldc/aswi/service/AssemblyManager.java b/src/main/java/vldc/aswi/service/AssemblyManager.java
index 36ce28ed..010ec025 100644
--- a/src/main/java/vldc/aswi/service/AssemblyManager.java
+++ b/src/main/java/vldc/aswi/service/AssemblyManager.java
@@ -17,11 +17,31 @@ public interface AssemblyManager {
      */
     List<Assembly> getAssemblies();
 
+    /**
+     * Get assembly by id.
+     * @param id - ID of assembly.
+     * @return Assembly.
+     */
     Assembly getAssemblyById(Long id);
 
+    /**
+     * Update assembly.
+     * @param updatedAssemblyValues - Assembly values.
+     * @return ID of assembly.
+     */
     Long updateAssembly(Assembly updatedAssemblyValues);
 
+    /**
+     * Update assembly's order.
+     * @param id - ID of assembly.
+     * @param order - Assembly's order.
+     */
     void updateAssemblyOrder(Long id, int order);
 
+    /**
+     * Create new assembly.
+     * @param assemblyValues - Assembly values.
+     * @return ID of assembly.
+     */
     Long createAssembly(Assembly assemblyValues);
 }
diff --git a/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java b/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
index ba84578a..3bcf630c 100644
--- a/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/AssemblyManagerImpl.java
@@ -15,6 +15,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Assembly.
+ */
 @Service
 @Slf4j
 public class AssemblyManagerImpl implements AssemblyManager {
@@ -53,11 +56,21 @@ public class AssemblyManagerImpl implements AssemblyManager {
         return retVal;
     }
 
+    /**
+     * Get assembly by id.
+     * @param id - ID of assembly.
+     * @return Assembly.
+     */
     @Override
     public Assembly getAssemblyById(Long id) {
         return assemblyRepository.getById(id);
     }
 
+    /**
+     * Update assembly's order.
+     * @param id - ID of assembly.
+     * @param order - Assembly's order.
+     */
     @Override
     public void updateAssemblyOrder(Long id, int order) {
         Assembly assembly = getAssemblyById(id);
@@ -65,6 +78,11 @@ public class AssemblyManagerImpl implements AssemblyManager {
         this.assemblyRepository.save(assembly);
     }
 
+    /**
+     * Update assembly.
+     * @param updatedAssemblyValues - Assembly values.
+     * @return ID of assembly.
+     */
     @Override
     public Long updateAssembly(Assembly updatedAssemblyValues) {
         // TODO: test it.
@@ -80,6 +98,11 @@ public class AssemblyManagerImpl implements AssemblyManager {
         return assembly.getId();
     }
 
+    /**
+     * Update assembly's roles.
+     * @param id - ID of assembly.
+     * @param updatedRoles - List of roles.
+     */
     private void updateAssemblyRoles(Long id, List<Role> updatedRoles) {
         // TODO: test it.
         Assembly assembly = getAssemblyById(id);
@@ -108,9 +131,15 @@ public class AssemblyManagerImpl implements AssemblyManager {
         this.assemblyRepository.save(assembly);
     }
 
+    /**
+     * Create new assembly.
+     * @param assemblyValues - Assembly values.
+     * @return ID of assembly.
+     */
     @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());
@@ -118,6 +147,7 @@ public class AssemblyManagerImpl implements AssemblyManager {
         assembly.setIsPublic(assemblyValues.getIsPublic());
         List<Role> roles = new LinkedList<>();
 
+        // Add access for roles.
         if (assemblyValues.getRoles() != null && assemblyValues.getRoles().size() > 0) {
             for (Role newRole : assemblyValues.getRoles()) {
                 roles.add(this.roleRepository.getById(newRole.getId()));
@@ -125,6 +155,8 @@ public class AssemblyManagerImpl implements AssemblyManager {
         }
 
         assembly.setRoles(roles);
+
+        // Create new record in database.
         this.assemblyRepository.save(assembly);
 
         return assembly.getId();
diff --git a/src/main/java/vldc/aswi/service/FunctionManagerImpl.java b/src/main/java/vldc/aswi/service/FunctionManagerImpl.java
index 1e34a6d1..5012fa34 100644
--- a/src/main/java/vldc/aswi/service/FunctionManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/FunctionManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Function.
+ */
 @Service
 @Slf4j
 public class FunctionManagerImpl implements  FunctionManager {
diff --git a/src/main/java/vldc/aswi/service/LocationManagerImpl.java b/src/main/java/vldc/aswi/service/LocationManagerImpl.java
index 354b666b..6ecbc5c7 100644
--- a/src/main/java/vldc/aswi/service/LocationManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/LocationManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Location.
+ */
 @Service
 @Slf4j
 public class LocationManagerImpl implements LocationManager {
diff --git a/src/main/java/vldc/aswi/service/OperatorManagerImpl.java b/src/main/java/vldc/aswi/service/OperatorManagerImpl.java
index 1e006491..3b3198b9 100644
--- a/src/main/java/vldc/aswi/service/OperatorManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/OperatorManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Operator.
+ */
 @Service
 @Slf4j
 public class OperatorManagerImpl implements OperatorManager {
diff --git a/src/main/java/vldc/aswi/service/RoleManagerImpl.java b/src/main/java/vldc/aswi/service/RoleManagerImpl.java
index 5486cac2..14a08243 100644
--- a/src/main/java/vldc/aswi/service/RoleManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/RoleManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Role.
+ */
 @Service
 @Slf4j
 public class RoleManagerImpl implements RoleManager {
diff --git a/src/main/java/vldc/aswi/service/SqlQueryManager.java b/src/main/java/vldc/aswi/service/SqlQueryManager.java
index 735e53f8..178d5277 100644
--- a/src/main/java/vldc/aswi/service/SqlQueryManager.java
+++ b/src/main/java/vldc/aswi/service/SqlQueryManager.java
@@ -4,7 +4,22 @@ import vldc.aswi.model.table.contingencyTable.ContingencyTableRow;
 
 import java.util.List;
 
+/**
+ * Interface for SqlQuery manager.
+ */
 public interface SqlQueryManager {
 
-    List<ContingencyTableRow> getContingencyTableRow(String sql);
+    /**
+     * Get list of  contingencyTableRow.
+     * @param sqlQuery - SQL query.
+     * @return List of contingencyTableRow.
+     */
+    List<ContingencyTableRow> getContingencyTableRow(String sqlQuery);
+
+    /**
+     * Validate given SQL query.
+     * @param sqlQuery - Validated SQL query.
+     * @return true if SQL query is ok, false if not.
+     */
+    boolean validateSQLQuery(String sqlQuery);
 }
diff --git a/src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java b/src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java
index 93e7f51c..70f2440b 100644
--- a/src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java
@@ -12,19 +12,35 @@ import javax.sql.DataSource;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * Manager for SqlQuery.
+ */
 @Service
 @Slf4j
 public class SqlQueryManagerImpl implements SqlQueryManager{
 
-    @Autowired
-    private DataSource dataSource;
-
+    /** Autowired databaseInterface component. */
     @Autowired
     private DatabaseInterface databaseInterface;
 
+    /**
+     * Get list of  contingencyTableRow.
+     * @param sqlQuery - SQL query.
+     * @return List of contingencyTableRow.
+     */
     @Override
     public List<ContingencyTableRow> getContingencyTableRow(String sqlQuery) {
         Map<String, TableColumn> tableColumns = databaseInterface.executeQueryAndReturnTableColumns(sqlQuery);
         return Converter.convertTableColumnsToContingencyTableRows(tableColumns);
     }
+
+    /**
+     * Validate given SQL query.
+     * @param sqlQuery - Validated SQL query.
+     * @return true if SQL query is ok, false if not.
+     */
+    @Override
+    public boolean validateSQLQuery(String sqlQuery) {
+        return databaseInterface.validateSQLQuery(sqlQuery);
+    }
 }
diff --git a/src/main/java/vldc/aswi/service/UserManagerImpl.java b/src/main/java/vldc/aswi/service/UserManagerImpl.java
index 95791642..b07e6b3f 100644
--- a/src/main/java/vldc/aswi/service/UserManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/UserManagerImpl.java
@@ -14,6 +14,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for User.
+ */
 @Service
 @Slf4j
 public class UserManagerImpl implements UserManager {
@@ -46,7 +49,6 @@ public class UserManagerImpl implements UserManager {
             User referentka = this.userRepository.getById(idReferentka);
             User prorektor = this.userRepository.getById(idProrektor);
 
-            // TODO: set roles for every default user.
             //admin.setRole();
         }
     }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
index a8e20b1d..990bd5f1 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterInConfigurationManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for ParameterInConfiguration.
+ */
 @Service
 @Slf4j
 public class ParameterInConfigurationManagerImpl implements ParameterInConfigurationManager {
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterManager.java b/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
index 7a0c7820..1812fd40 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterManager.java
@@ -15,7 +15,17 @@ public interface ParameterManager {
      */
     List<Parameter> getParameters();
 
+    /**
+     * Add new parameter into database.
+     * @param assemblyId - Assembly in which parameter is presented.
+     * @param parameterValuesList - Parameter values.
+     */
     void addParameters(Long assemblyId, List<Parameter> parameterValuesList);
 
+    /**
+     * Update parameter with given values.
+     * @param assemblyId - Assembly in which parameter is presented.
+     * @param newAssemblyParameters - List of parameters.
+     */
     void updateParameters(Long assemblyId, List<Parameter> newAssemblyParameters);
 }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
index 89ad8398..7a313103 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java
@@ -15,17 +15,15 @@ import vldc.aswi.dao.parameter.ParameterTypeRepository;
 import vldc.aswi.dao.parameter.ParameterValueRepository;
 import vldc.aswi.domain.*;
 import vldc.aswi.domain.parameter.Parameter;
-import vldc.aswi.domain.parameter.ParameterType;
 import vldc.aswi.domain.parameter.ParameterValue;
-import vldc.aswi.service.FunctionManager;
-import vldc.aswi.service.LocationManager;
-import vldc.aswi.service.OperatorManager;
 
 import javax.transaction.Transactional;
-import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for Parameter.
+ */
 @Service
 @Slf4j
 public class ParameterManagerImpl implements ParameterManager {
@@ -34,21 +32,27 @@ public class ParameterManagerImpl implements ParameterManager {
     @Autowired
     private ParameterRepository parameterRepository;
 
+    /** Autowired assembly repository. */
     @Autowired
     private AssemblyRepository assemblyRepository;
 
+    /** Autowired parameterType repository. */
     @Autowired
     private ParameterTypeRepository parameterTypeRepository;
 
+    /** Autowired location repository. */
     @Autowired
     private LocationRepository locationRepository;
 
+    /** Autowired function repository. */
     @Autowired
     private FunctionRepository functionRepository;
 
+    /** Autowired operator repository. */
     @Autowired
     private OperatorRepository operatorRepository;
 
+    /** Autowired parameterValue repository. */
     @Autowired
     private ParameterValueRepository parameterValueRepository;
 
@@ -79,6 +83,11 @@ public class ParameterManagerImpl implements ParameterManager {
         return retVal;
     }
 
+    /**
+     * Add new parameter into database.
+     * @param assemblyId - Assembly in which parameter is presented.
+     * @param parameterValuesList - Parameter values.
+     */
     @Override
     public void addParameters(Long assemblyId, List<Parameter> parameterValuesList) {
         Assembly assembly = this.assemblyRepository.getById(assemblyId);
@@ -86,6 +95,7 @@ public class ParameterManagerImpl implements ParameterManager {
         if (parameterValuesList == null) return;
 
         for (Parameter parameterValues : parameterValuesList) {
+            // Create new parameter and assign him all values.
             Parameter parameter = new Parameter();
             parameter.setName(parameterValues.getNameOfSelect());
             parameter.setNameOfSelect(parameterValues.getNameOfSelect());
@@ -97,44 +107,54 @@ public class ParameterManagerImpl implements ParameterManager {
             List<Function> functionList = new LinkedList<>();
             List<Operator> operatorList = new LinkedList<>();
 
+            // Try to put all locations into list.
             if (parameterValues.getLocations() != null && parameterValues.getLocations().size() > 0) {
                 for (Location location : parameterValues.getLocations()) {
                     locationList.add(this.locationRepository.getById(location.getId()));
                 }
             }
 
+            // Try to put all functions into list.
             if (parameterValues.getFunctions() != null && parameterValues.getFunctions().size() > 0) {
                 for (Function function : parameterValues.getFunctions()) {
                     functionList.add(this.functionRepository.getById(function.getId()));
                 }
             }
 
+            // Try to put all operators into list.
             if (parameterValues.getOperators() != null && parameterValues.getOperators().size() > 0) {
                 for (Operator operator : parameterValues.getOperators()) {
                     operatorList.add(this.operatorRepository.getById(operator.getId()));
                 }
             }
 
+            // Set lists of values into parameter.
             parameter.setLocations(locationList);
             parameter.setFunctions(functionList);
             parameter.setOperators(operatorList);
 
+            // Insert parameter into database.
             this.parameterRepository.save(parameter);
         }
     }
 
+    /**
+     * Update parameter - remove deleted parameters, add new parameters, update updated parameters.
+     * @param assemblyId - Assembly in which parameter is presented.
+     * @param newAssemblyParameters - List of parameters.
+     */
     @Override
     public void updateParameters(Long assemblyId, List<Parameter> newAssemblyParameters) {
         // TODO: test it.
         Assembly assembly = this.assemblyRepository.getById(assemblyId);
         List<Parameter> currentAssemblyParameters = assembly.getParameters();
 
-        // Find new parameters;
+        // Find new parameters.
         List<Parameter> currentAssemblyParametersNew = new LinkedList<>(currentAssemblyParameters);
         List<Parameter> newAssemblyParametersNew = new LinkedList<>(newAssemblyParameters);
         newAssemblyParametersNew.removeAll(currentAssemblyParametersNew);
 
-        // Find deleted parameters
+        // Find deleted parameters.
         List<Parameter> currentAssemblyParametersDeleted = new LinkedList<>(currentAssemblyParameters);
         List<Parameter> newAssemblyParametersDeleted = new LinkedList<>(newAssemblyParameters);
         currentAssemblyParametersDeleted.removeAll(newAssemblyParametersDeleted);
@@ -150,9 +170,11 @@ public class ParameterManagerImpl implements ParameterManager {
         // 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);
         }
 
@@ -163,17 +185,26 @@ public class ParameterManagerImpl implements ParameterManager {
         addParameters(assemblyId, newAssemblyParametersNew);
     }
 
+    /**
+     * Update updated parameters.
+     * @param parameterValuesList - List of updated parameters.
+     */
     private void updateParameters(List<Parameter> parameterValuesList) {
         // TODO: test it.
         for (Parameter parameterValues : parameterValuesList) {
+            // Get current parameter from database.
             Parameter parameter = this.parameterRepository.getById(parameterValues.getId());
+            // Update current parameter values.
             parameter.setName(parameterValues.getName());
             parameter.setNameOfSelect(parameterValues.getNameOfSelect());
             parameter.setAssembly(this.assemblyRepository.getById(parameterValues.getAssembly().getId()));
             parameter.setParameterType(this.parameterTypeRepository.getById(parameterValues.getParameterType().getId()));
             parameter.setDefaultValue(parameterValues.getDefaultValue());
+
+            // Insert changes into database.
             this.parameterRepository.save(parameter);
 
+            // Update parameter values, locations, functions and operators.
             updateParameterValues(parameterValues.getId(), parameterValues.getParameterValues());
             updateParameterLocations(parameterValues.getId(), parameterValues.getLocations());
             updateParameterFunctions(parameterValues.getId(), parameterValues.getFunctions());
@@ -181,113 +212,171 @@ public class ParameterManagerImpl implements ParameterManager {
         }
     }
 
+    /**
+     * Update current parameter locations.
+     * @param id - Id of parameter.
+     * @param updatedLocations - List of locations.
+     */
     private void updateParameterLocations(Long id, List<Location> updatedLocations) {
         // TODO: test it.
         Parameter parameter = this.parameterRepository.getById(id);
         List<Location> currentLocations = parameter.getLocations();
 
+        // Get new locations.
         List<Location> currentLocationsNew = new LinkedList<>(currentLocations);
         List<Location> updatedLocationsNew = new LinkedList<>(updatedLocations);
         updatedLocationsNew.removeAll(currentLocationsNew);
 
+        // Get deleted locations.
         List<Location> currentLocationsDeleted = new LinkedList<>(currentLocations);
         List<Location> updatedLocationsDeleted = new LinkedList<>(updatedLocations);
         currentLocationsDeleted.removeAll(updatedLocationsDeleted);
 
+        // If there is no change, do not update.
         if (updatedLocationsNew.size() == 0 && currentLocationsDeleted.size() == 0) return;
 
+        // Add new locations.
         for (Location newLocation : updatedLocationsNew) {
             currentLocations.add(this.locationRepository.getById(newLocation.getId()));
         }
+
+        // Remove deleted locations.
         currentLocations.removeAll(currentLocationsDeleted);
 
+        // Insert changes into database.
         this.parameterRepository.save(parameter);
     }
 
+    /**
+     * Update current parameter functions.
+     * @param id - Id of parameter.
+     * @param updatedFunctions - List of functions.
+     */
     private void updateParameterFunctions(Long id, List<Function> updatedFunctions) {
         // TODO: test it.
         Parameter parameter = this.parameterRepository.getById(id);
         List<Function> currentFunctions = parameter.getFunctions();
 
+        // Get new functions.
         List<Function> currentFunctionsNew = new LinkedList<>(currentFunctions);
         List<Function> updatedFunctionsNew = new LinkedList<>(updatedFunctions);
         updatedFunctionsNew.removeAll(currentFunctionsNew);
 
+        // Get deleted functions.
         List<Function> currentFunctionsDeleted = new LinkedList<>(currentFunctions);
         List<Function> updatedFunctionsDeleted = new LinkedList<>(updatedFunctions);
         currentFunctionsDeleted.removeAll(updatedFunctionsDeleted);
 
+        // If there is no change, do not update.
         if (updatedFunctionsNew.size() == 0 && currentFunctionsDeleted.size() == 0) return;
 
+        // Add new functions.
         for (Function newFunction : updatedFunctionsNew) {
             currentFunctions.add(this.functionRepository.getById(newFunction.getId()));
         }
+
+        // Delete removed functions.
         currentFunctions.removeAll(currentFunctionsDeleted);
 
+        // Insert changes into database.
         this.parameterRepository.save(parameter);
     }
 
+    /**
+     * Update current parameter operators.
+     * @param id - Id of parameter.
+     * @param updatedOperators - List of operators.
+     */
     private void updateParameterOperators(Long id, List<Operator> updatedOperators) {
         // TODO: test it.
         Parameter parameter = this.parameterRepository.getById(id);
         List<Operator> currentOperators = parameter.getOperators();
 
+        // Get new operators.
         List<Operator> currentOperatorsNew = new LinkedList<>(currentOperators);
         List<Operator> updatedOperatorsNew = new LinkedList<>(updatedOperators);
         updatedOperatorsNew.removeAll(currentOperatorsNew);
 
+        // Get deleted operators.
         List<Operator> currentOperatorsDeleted = new LinkedList<>(currentOperators);
         List<Operator> updatedOperatorsDeleted = new LinkedList<>(updatedOperators);
         currentOperatorsDeleted.removeAll(updatedOperatorsDeleted);
 
+        // If there is no changes, do not update.
         if (updatedOperatorsNew.size() == 0 && currentOperatorsDeleted.size() == 0) return;
 
+        // Insert new operators.
         for (Operator newOperator : updatedOperatorsNew) {
             currentOperators.add(this.operatorRepository.getById(newOperator.getId()));
         }
+
+        // Delete removed operators.
         currentOperators.removeAll(currentOperatorsDeleted);
 
+        // Insert changes into database.
         this.parameterRepository.save(parameter);
     }
 
+    /**
+     * Update current parameter values.
+     * @param parameterId - ID of parameter.
+     * @param newParameterValues - List of parameter values.
+     */
     private void updateParameterValues(Long parameterId, List<ParameterValue> newParameterValues) {
         // TODO: test it.
         Parameter parameter = this.parameterRepository.getById(parameterId);
         List<ParameterValue> currentParameterValues = parameter.getParameterValues();
 
+        // Get new parameter values.
         List<ParameterValue> currentParameterValuesNew = new LinkedList<>(currentParameterValues);
         List<ParameterValue> newParameterValuesNew = new LinkedList<>(newParameterValues);
         newParameterValuesNew.removeAll(currentParameterValuesNew);
 
+        // Get deleted parameter values.
         List<ParameterValue> currentParameterValuesDeleted = new LinkedList<>(currentParameterValues);
         List<ParameterValue> newParameterValuesDeleted = new LinkedList<>(newParameterValues);
         currentParameterValuesDeleted.removeAll(newParameterValuesDeleted);
 
+        // Get updated parameter values.
         List<ParameterValue> currentParameterValuesUpdated = new LinkedList<>(currentParameterValues);
         List<ParameterValue> newParameterValuesUpdated = new LinkedList<>(newParameterValues);
         newParameterValuesUpdated.retainAll(currentParameterValuesUpdated);
 
+        // If there is no changes, do not update.
         if (newParameterValuesNew.size() == 0 && currentParameterValuesDeleted.size() == 0 && newParameterValuesUpdated.size() == currentParameterValues.size()) return;
 
+        // Delete removed parameter values.
         for (ParameterValue parameterValue : currentParameterValuesDeleted) {
             this.parameterValueRepository.delete(parameterValue);
         }
 
+        // Update parameter values.
         updateParameterValueValues(newParameterValuesUpdated);
 
+        // Add new parameter values.
         addParameterValueValues(parameterId, newParameterValuesNew);
     }
 
+    /**
+     * Update all updated parameter values.
+     * @param updatedParameterValuesList - List of all updated parameter values.
+     */
     private void updateParameterValueValues(List<ParameterValue> updatedParameterValuesList) {
         // TODO: test it.
         for (ParameterValue parameterValueValues : updatedParameterValuesList) {
             ParameterValue parameterValue = this.parameterValueRepository.getById(parameterValueValues.getId());
             parameterValue.setValue(parameterValueValues.getValue());
 
+            // Insert changes into database.
             this.parameterValueRepository.save(parameterValue);
         }
     }
 
+    /**
+     * Add new parameter values.
+     * @param parameterId - ID of parameter.
+     * @param newParameterValuesNew - List of new parameter values.
+     */
     private void addParameterValueValues(Long parameterId, List<ParameterValue> newParameterValuesNew) {
         // TODO: test it.
         Parameter parameter = this.parameterRepository.getById(parameterId);
@@ -297,6 +386,7 @@ public class ParameterManagerImpl implements ParameterManager {
             parameterValue.setValue(parameterValueValues.getValue());
             parameterValue.setParameter(parameter);
 
+            // Insert new parameterValue into database.
             this.parameterValueRepository.save(parameterValue);
         }
     }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterTypeManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterTypeManagerImpl.java
index 3a999441..55cb03b3 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterTypeManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterTypeManagerImpl.java
@@ -13,6 +13,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for ParameterType.
+ */
 @Service
 @Slf4j
 public class ParameterTypeManagerImpl implements ParameterTypeManager {
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterValueManager.java b/src/main/java/vldc/aswi/service/parameter/ParameterValueManager.java
index 50f155ff..0fc7ca71 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterValueManager.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterValueManager.java
@@ -14,10 +14,4 @@ public interface ParameterValueManager {
      * @return List of parameter values.
      */
     List<ParameterValue> getParameterValues();
-
-    void createParameterValues(Long parameterId, List<ParameterValue> parameterValues);
-
-    void updateParameterValues(Long parameterId, List<ParameterValue> parameterValues);
-
-    void addParameterValues(Long parameterId, List<ParameterValue> newParameterValuesNew);
 }
diff --git a/src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java b/src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java
index 4a01e912..d96acdca 100644
--- a/src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java
+++ b/src/main/java/vldc/aswi/service/parameter/ParameterValueManagerImpl.java
@@ -15,6 +15,9 @@ import javax.transaction.Transactional;
 import java.util.LinkedList;
 import java.util.List;
 
+/**
+ * Manager for ParameterValue.
+ */
 @Service
 @Slf4j
 public class ParameterValueManagerImpl implements ParameterValueManager {
@@ -52,69 +55,4 @@ public class ParameterValueManagerImpl implements ParameterValueManager {
         this.parameterValueRepository.findAll().forEach(retVal::add);
         return retVal;
     }
-
-
-    @Override
-    public void createParameterValues(Long parameterId, List<ParameterValue> parameterValues) {
-        Parameter parameter = this.parameterRepository.getById(parameterId);
-
-        for (ParameterValue newParameterValue : parameterValues) {
-            ParameterValue parameterValue = new ParameterValue();
-            parameterValue.setValue(newParameterValue.getValue());
-            parameterValue.setParameter(parameter);
-
-            this.parameterValueRepository.save(parameterValue);
-        }
-    }
-
-    @Override
-    public void updateParameterValues(Long parameterId, List<ParameterValue> newParameterValues) {
-        Parameter parameter = this.parameterRepository.getById(parameterId);
-        List<ParameterValue> currentParameterValues = parameter.getParameterValues();
-
-        List<ParameterValue> currentParameterValuesNew = new LinkedList<>(currentParameterValues);
-        List<ParameterValue> newParameterValuesNew = new LinkedList<>(newParameterValues);
-        newParameterValuesNew.removeAll(currentParameterValuesNew);
-
-        List<ParameterValue> currentParameterValuesDeleted = new LinkedList<>(currentParameterValues);
-        List<ParameterValue> newParameterValuesDeleted = new LinkedList<>(newParameterValues);
-        currentParameterValuesDeleted.removeAll(newParameterValuesDeleted);
-
-        List<ParameterValue> currentParameterValuesUpdated = new LinkedList<>(currentParameterValues);
-        List<ParameterValue> newParameterValuesUpdated = new LinkedList<>(newParameterValues);
-        newParameterValuesUpdated.retainAll(currentParameterValuesUpdated);
-
-        if (newParameterValuesNew.size() == 0 && currentParameterValuesDeleted.size() == 0 && newParameterValuesUpdated.size() == currentParameterValues.size()) return;
-
-        for (ParameterValue parameterValue : currentParameterValuesDeleted) {
-            this.parameterValueRepository.delete(parameterValue);
-        }
-
-        updateParameterValues(newParameterValuesUpdated);
-
-        addParameterValues(parameterId, newParameterValuesNew);
-    }
-
-    private void updateParameterValues(List<ParameterValue> updatedParameterValuesList) {
-        for (ParameterValue parameterValueValues : updatedParameterValuesList) {
-            ParameterValue parameterValue = this.parameterValueRepository.getById(parameterValueValues.getId());
-            parameterValue.setValue(parameterValueValues.getValue());
-
-            this.parameterValueRepository.save(parameterValue);
-        }
-    }
-
-    @Override
-    public void addParameterValues(Long parameterId, List<ParameterValue> newParameterValuesNew) {
-        Parameter parameter = this.parameterRepository.getById(parameterId);
-
-        for (ParameterValue parameterValueValues : newParameterValuesNew) {
-            ParameterValue parameterValue = new ParameterValue();
-            parameterValue.setValue(parameterValueValues.getValue());
-            parameterValue.setParameter(parameter);
-
-            this.parameterValueRepository.save(parameterValue);
-        }
-    }
-
 }
diff --git a/src/main/java/vldc/aswi/utils/Converter.java b/src/main/java/vldc/aswi/utils/Converter.java
index a075fdfe..6c7fda27 100644
--- a/src/main/java/vldc/aswi/utils/Converter.java
+++ b/src/main/java/vldc/aswi/utils/Converter.java
@@ -8,11 +8,20 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * Class for converting classes.
+ */
 public class Converter {
 
+    /**
+     * Convert Map of TableColumns into list of ContingencyTableRow.
+     * @param tableColumns - Map of TableColumn.
+     * @return List of ContingencyTableRow.
+     */
     public static List<ContingencyTableRow> convertTableColumnsToContingencyTableRows(Map<String, TableColumn> tableColumns) {
         List<ContingencyTableRow> contingencyTableRows = new ArrayList<>();
 
+        // Create header row with column names.
         ContingencyTableRow contingencyTableRowHeader = new ContingencyTableRow(true, 0);
         for (String columnName : tableColumns.keySet()) {
             contingencyTableRowHeader.addTableRowCell(new ContingencyTableRowCell(columnName, 0));
@@ -21,9 +30,11 @@ public class Converter {
 
         boolean listExpanded = false;
 
+        // Create contingency table row.
         for (TableColumn tableColumn : tableColumns.values()) {
             List<String> values = tableColumn.getValues();
 
+            // If list is not created, then create it.
             if (!listExpanded) {
                 for (int j = 0; j < values.size(); j++) {
                     ContingencyTableRow contingencyTableRow = new ContingencyTableRow(false, 0);
@@ -32,6 +43,7 @@ public class Converter {
                 listExpanded = true;
             }
 
+            // Iterate through all values and assign one value per one row.
             for (int j = 0; j < values.size(); j++) {
                 ContingencyTableRowCell contingencyTableRowCell = new ContingencyTableRowCell(values.get(j), 0);
                 contingencyTableRows.get(j + 1).addTableRowCell(contingencyTableRowCell);
diff --git a/src/main/java/vldc/aswi/validators/AssemblyValidator.java b/src/main/java/vldc/aswi/validators/AssemblyValidator.java
new file mode 100644
index 00000000..1fb62d96
--- /dev/null
+++ b/src/main/java/vldc/aswi/validators/AssemblyValidator.java
@@ -0,0 +1,78 @@
+package vldc.aswi.validators;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.validation.Errors;
+import org.springframework.validation.Validator;
+import vldc.aswi.domain.Assembly;
+import vldc.aswi.domain.parameter.Parameter;
+import vldc.aswi.service.SqlQueryManager;
+
+/**
+ * Validator for assembly.
+ */
+@Component
+public class AssemblyValidator implements Validator {
+
+    /** Autowired sql query manager. */
+    @Autowired
+    private SqlQueryManager sqlQueryManager;
+
+    /**
+     * Validator for supporting this class.
+     * @param aClass - Class.
+     * @return true if sent class match Assembly class.
+     */
+    @Override
+    public boolean supports(Class<?> aClass) {
+        return Assembly.class.equals(aClass);
+    }
+
+    /**
+     * Validate assembly values.
+     * @param obj - Validated object.
+     * @param errors - Errors sended to output.
+     */
+    @Override
+    public void validate(Object obj, Errors errors) {
+        // TODO: VALIDATING   - https://docs.spring.io/spring/docs/4.1.x/spring-framework-reference/html/validation.html
+        // TODO: ERROR STYLES - https://mkyong.com/spring-mvc/spring-mvc-form-errors-tag-example/
+
+        // Get assembly values.
+        Assembly assembly = (Assembly) obj;
+
+        // Validate SQL Query.
+        boolean isSQLQueryValid = this.sqlQueryManager.validateSQLQuery(assembly.getSQLQuery());
+
+        if (!isSQLQueryValid) {
+            errors.rejectValue("SQLQuery", "SQL Query není validní!");
+            // Field error in object 'assembly' on field 'SQLQuery': rejected value [SELECT SP.fakulta_S as fakulta_studia,
+            // SP.kodSP_i as program_studia, fn_meaning2(SP.typ,'TYP_OBORU') as typ_studia, fn_meaning2(SP.forma,'FORMA_OBORU_NEW')
+            // as forma_studia, OS.prijmeni || ' ' || OS.jmeno as osoba, trunc((sysdate - OS.datum_naroz) / 365) as vek, 1 as pocet
+            // FROM studijni_programy SP, studenti ST, osoby OS WHERE SP.stpridno = ST.stpridno AND ST.osobidno = OS.osobidno AND
+            // exists (SELECT 'a' FROM studenti_v_roce SVR WHERE ST.os_cislo = SVR.os_cislo AND SVR.rok_platnosti >= '2018') AND
+            // ROWNUM <= 50];
+            // codes [SQL Query není validní!.assembly.SQLQuery,SQL Query není validní!.
+            // SQLQuery,SQL Query není validní!.java.lang.String,SQL Query není validní!]; arguments []; default message [null]
+        }
+
+        // TODO: test validation for new assembly -> especially for parameters.
+        for (int i = 0; i < assembly.getParameters().size(); i++) {
+            // TODO: Parametr - Pokud název v SQL nebude v dotazu SQL, bude vyhozena chyba.
+            // TODO: Maybe nejdříve vzít všechny sloupce a potom zkontrolovat jestli obsahuje ten vybranej sloupec ?
+            // TODO: A kontrolovat to podle ".. as NAZEV_SLOUPCE" nebo jako "SP.TYP_STUDIA ...." ???
+
+            /*
+            if (!isParameterNameInSQLQuery) {
+                errors.rejectValue("parameterSQLName" + i, "Název parametru v SQL query není validní!");
+            }
+             */
+
+            Parameter parameter = assembly.getParameters().get(i);
+            // Check if current parameter have at least 1 location.
+            if (parameter == null || parameter.getLocations() == null || parameter.getLocations().size() == 0) {
+                errors.rejectValue("parameters[" + i + "].locations", "Není vybrána žádná lokace!");
+            }
+        }
+    }
+}
diff --git a/src/main/java/vldc/aswi/web/controller/AssemblyController.java b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
index 37435329..876a8e73 100644
--- a/src/main/java/vldc/aswi/web/controller/AssemblyController.java
+++ b/src/main/java/vldc/aswi/web/controller/AssemblyController.java
@@ -2,57 +2,73 @@ package vldc.aswi.web.controller;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
 import org.springframework.ui.ModelMap;
 import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.WebDataBinder;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.InitBinder;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import vldc.aswi.domain.Assembly;
-import vldc.aswi.domain.Function;
-import vldc.aswi.domain.Location;
-import vldc.aswi.domain.parameter.Parameter;
 import vldc.aswi.service.*;
 import vldc.aswi.service.parameter.ParameterManager;
 import vldc.aswi.service.parameter.ParameterTypeManager;
-import vldc.aswi.service.parameter.ParameterValueManager;
+import vldc.aswi.validators.AssemblyValidator;
 
 import javax.validation.Valid;
-import java.beans.PropertyEditorSupport;
-import java.util.LinkedList;
-import java.util.List;
 
+/**
+ * Controller for assembly.
+ */
 @Controller
 public class AssemblyController {
 
+    /** Autowired sql query manager. */
     @Autowired
     private SqlQueryManager sqlQueryManager;
 
+    /** Autowired assembly manager. */
     @Autowired
     private AssemblyManager assemblyManager;
 
+    /** Autowired role manager. */
     @Autowired
     private RoleManager roleManager;
 
+    /** Autowired parameterType manager. */
     @Autowired
     private ParameterTypeManager parameterTypeManager;
 
+    /** Autowired operator manager. */
     @Autowired
     private OperatorManager operatorManager;
 
+    /** Autowired function manager. */
     @Autowired
     private FunctionManager functionManager;
 
+    /** Autowired location manager. */
     @Autowired
     private LocationManager locationManager;
 
+    /** Autowired parameter manager. */
     @Autowired
     private ParameterManager parameterManager;
 
+    /** Autowired assembly validator */
     @Autowired
-    private ParameterValueManager parameterValueManager;
+    private AssemblyValidator assemblyValidator;
+
+    /**
+     * Bind assembly validator.
+     * @param binder Binder.
+     */
+    @InitBinder("assembly")
+    protected void userBinder(WebDataBinder binder) {
+        binder.addValidators(this.assemblyValidator);
+    }
 
     @GetMapping("/assembly")
     public ModelAndView assemblyIndex(@Valid @ModelAttribute("assemblyID") String id) {
@@ -108,20 +124,18 @@ public class AssemblyController {
     public ModelAndView assemblyEditPostIndex(@Valid @ModelAttribute("assembly") Assembly assembly, @Valid @ModelAttribute("checkboxPublic") String assemblyIsPublic) {
 
         ModelAndView modelAndView = new ModelAndView("assembly_manage");
-
         ModelMap modelMap = modelAndView.getModelMap();
+
         if (assemblyIsPublic.equals("on")) assembly.setIsPublic(1);
         else assembly.setIsPublic(0);
 
+        // TODO: chybí defaultValue.
         Long assemblyID = this.assemblyManager.updateAssembly(assembly);
         this.parameterManager.updateParameters(assemblyID, assembly.getParameters());
         Assembly updatedAssembly = this.assemblyManager.getAssemblyById(assembly.getId());
 
-        // TODO: vyzkoušet jestli se dobře vrací ID parameterType a zda se vypisuje název v selectboxu namísto ID !!
-        // TODO: chybí defaultValue.
-
-
         modelMap.addAttribute("assembly", updatedAssembly);
+
         modelMap.addAttribute("allRoles", this.roleManager.getRoles());
         modelMap.addAttribute("allParameterTypes", this.parameterTypeManager.getParameterTypes());
         modelMap.addAttribute("allFunctions", this.functionManager.getFunctions());
@@ -153,10 +167,12 @@ public class AssemblyController {
 
         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=" + assembly.getId());
+
         return modelAndView;
     }
 }
diff --git a/src/main/webapp/WEB-INF/templates/assembly_manage.html b/src/main/webapp/WEB-INF/templates/assembly_manage.html
index 2314d15e..c57e179b 100644
--- a/src/main/webapp/WEB-INF/templates/assembly_manage.html
+++ b/src/main/webapp/WEB-INF/templates/assembly_manage.html
@@ -37,13 +37,13 @@
     <div class="form-group row">
       <label for="name" class="col-sm-2 col-form-label">Název sestavy:</label>
       <div class="col-sm-10">
-        <input type="text" class="form-control" id="name" th:field="*{name}" th:value="*{name}">
+        <input type="text" class="form-control" name="assemblyName" id="assemblyName" th:field="*{name}" th:value="*{name}" required>
       </div>
     </div>
     <div class="form-group row">
-      <label for="sql_query" class="col-sm-2 col-form-label">SQL dotaz:</label>
+      <label for="assemblySQLQuery" class="col-sm-2 col-form-label">SQL dotaz:</label>
       <div class="col-sm-10">
-        <textarea class="form-control" id="sql_query" rows="6" th:field="*{SQLQuery}" th:text="*{SQLQuery}"></textarea>
+        <textarea class="form-control" name="assemblySQLQuery" id="assemblySQLQuery" rows="6" th:field="*{SQLQuery}" th:text="*{SQLQuery}" required></textarea>
       </div>
     </div>
     <div class="form-group row">
@@ -88,19 +88,19 @@
             <div class="form-group row">
               <label for="name" class="col-sm-2 col-form-label">Název:</label>
               <div class="col-sm-10">
-                <input type="text" class="form-control" id="name" th:field="*{parameters[__${i.index}__].name}" th:value="*{parameters[__${i.index}__].name}">
+                <input type="text" class="form-control" th:name="'parameterName' + ${i.index}" th:id="'parameterName' + ${i.index}" th:field="*{parameters[__${i.index}__].name}" th:value="*{parameters[__${i.index}__].name}" required>
               </div>
             </div>
             <div class="form-group row">
               <label for="name" class="col-sm-2 col-form-label">V&nbsp;SQL:</label>
               <div class="col-sm-10">
-                <input type="text" class="form-control" id="name" th:field="*{parameters[__${i.index}__].nameOfSelect}" th:value="*{parameters[__${i.index}__].nameOfSelect}">
+                <input type="text" class="form-control" th:name="'parameterSQLName' + ${i.index}" th:id="'parameterSQLName' + ${i.index}" th:field="*{parameters[__${i.index}__].nameOfSelect}" th:value="*{parameters[__${i.index}__].nameOfSelect}" required>
               </div>
             </div>
             <div class="form-group row">
               <label for="exampleFormControlSelect1" class="col-sm-2">Typ:</label>
               <div class="col-sm-10">
-                <select th:field="*{parameters[__${i.index}__].parameterType.name}" class="form-control" id="exampleFormControlSelect1">
+                <select th:field="*{parameters[__${i.index}__].parameterType}" class="form-control" id="exampleFormControlSelect1">
                   <option th:each="parameterType : ${allParameterTypes}" th:value="${parameterType.id}" th:text="${parameterType.name}"></option>
                 </select>
               </div>
@@ -129,7 +129,7 @@
               </div>
             </div>
 
-            <div class="form-group row">
+            <div th:name="'parameterLocations' + ${i.index}" class="form-group row">
               <label for="exampleFormControlSelect1" class="col-sm-2">Umístění:</label>
               <div class="col-sm-10">
                 <div th:each="location, j : ${allLocations}" class="form-check form-check-inline">
