commit e15a66498f8f8113b30d65b63e9b4ee155a7b594
Author: Ondřej Váně <onry.vane@gmail.com>
Date:   Sun Sep 5 22:05:14 2021 +0200

    #9 Split SQL scripts
    
    - all queries in the files are split into separate queries
    - each AP has a list of all the queries it needs to evaluate
    - all queries from the file are loaded at application startup
    - mineor changes in PositiveNUmber formating
    - minor fix

diff --git a/README.md b/README.md
index cc8acad..9ceab6d 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,6 @@
-# AntiPatternDetectionApp
-This application was created as part of the thesis. It is used for analysis and detection of anti-patterns in project data.
+# ReliSA - SPADe-Web-GUI
+This application was is used for analysis and detection of anti-patterns in project data.
 
-## Thesis abstract
-The goal of this thesis is to analyze and automatically detect anti-patterns in the data of project management tools using SPADe tools. The SPADe tool is used to collect data from ALM tools and search for bad practices (anti-patterns) in project data. In order to develop this thesis, an analysis of the available anti-patterns was performed and then a subset was selected for further investigation. In the next part, the detection of the analyzed anti-patterns was implemented using SQL queries and Java programming language was used to process the results of these queries. As an extra feature of this thesis, going beyond the scope of the original assignment, a support web application for running the detection process of implemented anti-patters and results presentation was also developed. Furthermore, an experiment was performed on a selected sets of anti-patterns and project data. The success of the detection was verified by comparing the results to those from a manual anti-pattern detection in project data from the source ALM tools. Detection success was successful at 93.65 % compared to manual control.
-
-## Analyzed Anti-Patterns
 In version 1.0.0 of this application, the detection of the following Anti-Patterns is implemented:
 * Business As Usual
 * Long Or Non-Existant Feedback Loops
@@ -14,19 +10,54 @@ In version 1.0.0 of this application, the detection of the following Anti-Patter
 * Too Long Sprint
 * Varying Sprint Length
 
-## Run
-### Tools to run
-It will need the following tools to run the application:
-* Docker
-* Docker Compose
-### Run application
-The following list describes the steps to run (you will need):
-1. Open terminal.
-2. Move to the root folder of this project (AntiPatternDetectionApp).
-3. Build docker images with command `docker-compose build`.
-4. Create and run all containers with command `docker-compose run`.
-5. Open phpMyAdmin on docker address on port 8082.
-6. Create database with name spade using command `CREATE DATABASE spade;`.
-7. Restore database from file `db_dump.sql` located in project root folder.
-8. Run all commands from file `config.sql` located in project root folder.
+# Basic architecture of app
+
+# Installation guide
+
+# Add new Anti-Pattern
+
+# User guide
+## Analyze projects
+1) On home page select project to analyze (you can use check box for select/deselect all projects)
+TODO obrázek
+2) Select Anti-Patterns to analyze (you can use check box for select/deselect all Anti-Patterns)
+TODO obrázek
+3) Click to button Analyze
+TODO obrázek
+4) Table with detections result
+TODO obrázek
+5) Show details of detection
+6) Show detail of Anti-Pattern
+
+## Configuration of Anti-Patterns
+1) Go to Configuration page
+TODO obrázek
+2) Change corresponding threshold values
+TODO obrázek
+3) Click button Save or press Enter
+TODO obrázek
+4) If the values ​​are set correctly, a message is displayed stating that the values ​​were saved successfully
+TODO obrázek
+5) If the values ​​are set incorrectly, a error message is displayed and the corresponding values ​​are highlighted in red with error message
+TODO obrázek
+
+## Show Anti-Pattern detail
+1) Go to Anti-Pattern detail page
+    1) On Home page click on anchor Show next to corresponding Anti-Pattern
+    2) On result page slick on Anti-Pattern name and anchor Detail
+2) Anti-Pattern detail page is shown (name, description, anchor to catalogue, configuration values)
+3) Configuration values can be updated also in this page
+    1) Change corresponding threshold values
+    2) Click button Save or press Enter
+4) If the values ​​are set correctly, a message is displayed stating that the values ​​were saved successfully
+TODO obrázek
+5) If the values ​​are set incorrectly, a error message is displayed and the corresponding values ​​are highlighted in red with error message
+TODO obrázek
+
+## Show project detail
+1) On home page click on anchor Show, next to corresponding project
+TODO obrázek
+2) Project details is shown (project id, name, description) 
+TODO obrázek
+
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java
index 11eab70..b6dec52 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java
@@ -12,7 +12,7 @@ public interface AntiPatternDetector {
 
     AntiPattern getAntiPatternModel();
 
-    String getAntiPatternSqlFileName();
+    List<String> getSqlFileNames();
 
     void setSqlQueries(List<String> queries);
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java
index 0f9e9b4..ba292c9 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java
@@ -35,7 +35,11 @@ public class BusinessAsUsualDetectorImpl implements AntiPatternDetector {
             }},
             "Business_As_Usual.md");
 
-    private final String sqlFileName = "business_as_usual.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "select_number_of_iterations.sql",
+            "select_iterations_with_substrings.sql",
+            "select_all_wikipages_that_is_updated_in_iteration.sql");
 
     // sql queries loaded from sql file
     private List<String> sqlQueries;
@@ -54,8 +58,8 @@ public class BusinessAsUsualDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.sqlFileName;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetectorImpl.java
index 7e9bf6a..a0931fb 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetectorImpl.java
@@ -51,7 +51,16 @@ public class LongOrNonExistentFeedbackLoopsDetectorImpl implements AntiPatternDe
             }}
     );
 
-    private final String SQL_FILE_NAME = "long_or_non_existent_feedback_loops.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "select_number_of_iterations.sql",
+            "select_average_iterations_length.sql",
+            "select_number_of_iterations_with_substrings_in_activity.sql",
+            "select_all_activities_with_substrings_and_last_modified_date_as_end_date.sql",
+            "select_project_start_date.sql",
+            "select_project_end_date.sql",
+            "select_all_iterations_that_contains_wikipages_with_substrings.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
@@ -60,7 +69,7 @@ public class LongOrNonExistentFeedbackLoopsDetectorImpl implements AntiPatternDe
     }
 
     private float getMaxGapBetweenFeedbackLoopRate() {
-        return (float) antiPattern.getConfigurations().get("maxGapBetweenFeedbackLoopRate").getValue();
+        return ((PositiveFloat) antiPattern.getConfigurations().get("maxGapBetweenFeedbackLoopRate").getValue()).floatValue();
     }
 
     private List<String> getSearchSubstringsWithFeedbackLoop() {
@@ -72,9 +81,8 @@ public class LongOrNonExistentFeedbackLoopsDetectorImpl implements AntiPatternDe
         return this.antiPattern;
     }
 
-    @Override
-    public String getAntiPatternSqlFileName() {
-        return this.SQL_FILE_NAME;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
@@ -124,7 +132,7 @@ public class LongOrNonExistentFeedbackLoopsDetectorImpl implements AntiPatternDe
                     break;
                 case 2:
                     if (rs.size() != 0) {
-                        numberOfIterationsWhichContainsAtLeastOneActivityForFeedback = ((Long) rs.get(0).get("totalCountOfIterationsWithFeedbackActivity")).intValue();
+                        numberOfIterationsWhichContainsAtLeastOneActivityForFeedback = ((Long) rs.get(0).get("totalCountOfIterationsWithSubstringsInActivity")).intValue();
                     }
                     break;
                 case 3:
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/NinetyNinetyRuleDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/NinetyNinetyRuleDetectorImpl.java
index 01f8afa..38ed33e 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/NinetyNinetyRuleDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/NinetyNinetyRuleDetectorImpl.java
@@ -34,16 +34,19 @@ public class NinetyNinetyRuleDetectorImpl implements AntiPatternDetector {
                         new PositiveInteger(2)));
             }});
 
-    private final String sqlFileName = "ninety_ninety_rule.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "select_all_iterations_with_sum_estimated_and_spent_time.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
     private double getMaxDivisionRange() {
-        return (Double) antiPattern.getConfigurations().get("maxDivisionRange").getValue();
+        return ((PositiveFloat) antiPattern.getConfigurations().get("maxDivisionRange").getValue()).doubleValue();
     }
 
     private int getMaxBadDivisionLimit() {
-        return (int) antiPattern.getConfigurations().get("maxBadDivisionLimit").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("maxBadDivisionLimit").getValue()).intValue();
     }
 
     @Override
@@ -52,8 +55,8 @@ public class NinetyNinetyRuleDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.sqlFileName;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
@@ -63,11 +66,11 @@ public class NinetyNinetyRuleDetectorImpl implements AntiPatternDetector {
 
     /**
      * Postup detekce:
-     *      1) pro každou iteraci udělat součet stráveného a odhadovaného času přes všechny aktivity
-     *      2) udělat podíl strávený čas / odhadovaný čas
-     *      3) pokud všechny výsledky podílů budou menší než 1.2 => vše ok
-     *      4) pokud předchozí bod nezabere, tak iterovat přes všechny podíly
-     *      5) pokud budou nalezeny tři iterace po sobě, kde se stále zhoršují odhady => detekováno
+     * 1) pro každou iteraci udělat součet stráveného a odhadovaného času přes všechny aktivity
+     * 2) udělat podíl strávený čas / odhadovaný čas
+     * 3) pokud všechny výsledky podílů budou menší než 1.2 => vše ok
+     * 4) pokud předchozí bod nezabere, tak iterovat přes všechny podíly
+     * 5) pokud budou nalezeny tři iterace po sobě, kde se stále zhoršují odhady => detekováno
      *
      * @param project            analyzovaný project
      * @param databaseConnection databázové připojení
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetectorImpl.java
index 9874e80..8f60a3c 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetectorImpl.java
@@ -44,16 +44,23 @@ public class RoadToNowhereDetectorImpl implements AntiPatternDetector {
             }},
             "Road_To_Nowhere.md");
 
-    private final String sqlFileName = "road_to_nowhere.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "set_first_iteration_start_date.sql",
+            "set_second_iteration_start_date.sql",
+            "set_number_of_activities_with_substrings.sql",
+            "set_number_of_wiki_pages_with_substrings.sql",
+            "select_number_of_activities_and_wiki_pages_with_substrings.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
     private int getMinNumberOfWikiPagesWithProjectPlan() {
-        return (int) antiPattern.getConfigurations().get("minNumberOfWikiPagesWithProjectPlan").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("minNumberOfWikiPagesWithProjectPlan").getValue()).intValue();
     }
 
     private int getMinNumberOfActivitiesWithProjectPlan() {
-        return (int) antiPattern.getConfigurations().get("minNumberOfActivitiesWithProjectPlan").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("minNumberOfActivitiesWithProjectPlan").getValue()).intValue();
     }
 
     private List<String> getSearchSubstringsWithProjectPlan() {
@@ -66,8 +73,8 @@ public class RoadToNowhereDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.sqlFileName;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
@@ -98,8 +105,8 @@ public class RoadToNowhereDetectorImpl implements AntiPatternDetector {
                     Utils.fillQueryWithSearchSubstrings(this.sqlQueries, getSearchSubstringsWithProjectPlan()));
             if (rs != null) {
                 while (rs.next()) {
-                    numberOfIssuesForProjectPlan = rs.getInt("numberOfIssuesForProjectPlan");
-                    numberOfWikiPagesForProjectPlan = rs.getInt("numberOfWikiPagesForProjectPlan");
+                    numberOfIssuesForProjectPlan = rs.getInt("numberOfActivitiesWithSubstrings");
+                    numberOfWikiPagesForProjectPlan = rs.getInt("numberOfWikiPagesWithSubstrings");
                 }
             }
 
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetectorImpl.java
index 9ac9c85..517066b 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetectorImpl.java
@@ -49,20 +49,26 @@ public class SpecifyNothingDetectorImpl implements AntiPatternDetector {
             }},
             "Specify_Nothing.md");
 
-    private final String sqlFileName = "specify_nothing.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "set_number_of_wiki_pages_with_substrings.sql",
+            "set_number_of_activities_with_substrings.sql",
+            "set_average_length_of_activities_description.sql",
+            "select_statistics_for_given_project.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
     private int getMinNumberOfWikiPagesWithSpecification() {
-        return (int) antiPattern.getConfigurations().get("minNumberOfWikiPagesWithSpecification").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("minNumberOfWikiPagesWithSpecification").getValue()).intValue();
     }
 
     private int getMinNumberOfActivitiesWithSpecification() {
-        return (int) antiPattern.getConfigurations().get("minNumberOfActivitiesWithSpecification").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("minNumberOfActivitiesWithSpecification").getValue()).intValue();
     }
 
     private int getMinAvgLengthOfActivityDescription() {
-        return (int) antiPattern.getConfigurations().get("minAvgLengthOfActivityDescription").getValue();
+        return ((PositiveInteger) antiPattern.getConfigurations().get("minAvgLengthOfActivityDescription").getValue()).intValue();
     }
 
     private List<String> getSearchSubstringsWithProjectSpecification() {
@@ -75,8 +81,8 @@ public class SpecifyNothingDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.sqlFileName;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
@@ -110,8 +116,8 @@ public class SpecifyNothingDetectorImpl implements AntiPatternDetector {
                     Utils.fillQueryWithSearchSubstrings(this.sqlQueries, getSearchSubstringsWithProjectSpecification()));
             if (rs != null) {
                 while (rs.next()) {
-                    numberOfWikiPages = rs.getInt("numberOfWikiPages");
-                    numberOfActivitiesForSpecification = rs.getInt("numberOfActivitiesForSpecification");
+                    numberOfWikiPages = rs.getInt("numberOfWikiPagesWithSubstrings");
+                    numberOfActivitiesForSpecification = rs.getInt("numberOfActivitiesWithSubstrings");
                     averageLengthOfIssueDescription = rs.getDouble("averageLengthOfIssueDescription");
                 }
             }
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
index 1b01069..bf08c3f 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
@@ -6,10 +6,7 @@ import cz.zcu.fav.kiv.antipatterndetectionapp.model.types.PositiveInteger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class TooLongSprintDetectorImpl implements AntiPatternDetector {
 
@@ -37,7 +34,12 @@ public class TooLongSprintDetectorImpl implements AntiPatternDetector {
             }}
     );
 
-    private final String SQL_FILE_NAME = "too_long_sprint.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "set_first_iteration_id.sql",
+            "set_last_iteration_id.sql",
+            "select_all_iterations_with_lengths_without_first_and_last.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
@@ -47,21 +49,22 @@ public class TooLongSprintDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.SQL_FILE_NAME;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
+
     @Override
     public void setSqlQueries(List<String> queries) {
         this.sqlQueries = queries;
     }
 
     private Integer getMaxIterationLength(){
-        return (Integer) this.antiPattern.getConfigurations().get("maxIterationLength").getValue();
+        return ((PositiveInteger) this.antiPattern.getConfigurations().get("maxIterationLength").getValue()).intValue();
     }
 
     private Integer getMaxNumberOfTooLongIterations(){
-        return (Integer) this.antiPattern.getConfigurations().get("maxNumberOfTooLongIterations").getValue();
+        return ((PositiveInteger) this.antiPattern.getConfigurations().get("maxNumberOfTooLongIterations").getValue()).intValue();
     }
 
     /**
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
index 827e1ae..816534d 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
@@ -37,16 +38,21 @@ public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
                         new PositiveInteger(1)));
             }});
 
-    private final String sqlFileName = "varying_sprint_length.sql";
+    private final List<String> SQL_FILE_NAMES = Arrays.asList(
+            "set_project_id.sql",
+            "set_first_iteration_id.sql",
+            "set_last_iteration_id.sql",
+            "select_all_iterations_with_lengths_without_first_and_last.sql");
+
     // sql queries loaded from sql file
     private List<String> sqlQueries;
 
     private Integer getMaxDaysDifference(){
-        return (Integer) this.antiPattern.getConfigurations().get("maxDaysDifference").getValue();
+        return ((PositiveInteger) this.antiPattern.getConfigurations().get("maxDaysDifference").getValue()).intValue();
     }
 
     private Integer getMaxIterationChanged(){
-        return (Integer) this.antiPattern.getConfigurations().get("maxIterationChanged").getValue();
+        return ((PositiveInteger) this.antiPattern.getConfigurations().get("maxIterationChanged").getValue()).intValue();
     }
 
     @Override
@@ -55,8 +61,8 @@ public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
     }
 
     @Override
-    public String getAntiPatternSqlFileName() {
-        return this.sqlFileName;
+    public List<String> getSqlFileNames() {
+        return this.SQL_FILE_NAMES;
     }
 
     @Override
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveFloat.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveFloat.java
index 2d59429..d37eb5c 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveFloat.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveFloat.java
@@ -16,22 +16,22 @@ public class PositiveFloat extends Number {
 
     @Override
     public int intValue() {
-        return 0;
+        return (int) this.value;
     }
 
     @Override
     public long longValue() {
-        return 0;
+        return (long) this.value;
     }
 
     @Override
     public float floatValue() {
-        return 0;
+        return this.value;
     }
 
     @Override
     public double doubleValue() {
-        return 0;
+        return this.value;
     }
 
     public static PositiveFloat parsePositiveFloat(String value) {
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveInteger.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveInteger.java
index e367a5e..9781c49 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveInteger.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/types/PositiveInteger.java
@@ -17,22 +17,22 @@ public class PositiveInteger extends Number {
 
     @Override
     public int intValue() {
-        return 0;
+        return this.value;
     }
 
     @Override
     public long longValue() {
-        return 0;
+        return this.value;
     }
 
     @Override
     public float floatValue() {
-        return 0;
+        return this.value;
     }
 
     @Override
     public double doubleValue() {
-        return 0;
+        return this.value;
     }
 
     public static PositiveInteger parsePositiveInteger(String value) {
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/AntiPatternRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/AntiPatternRepository.java
index 47494bc..f49bc15 100644
--- a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/AntiPatternRepository.java
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/AntiPatternRepository.java
@@ -18,13 +18,11 @@ import java.util.*;
 @Component
 public class AntiPatternRepository implements ServletContextAware {
 
+    private static final String QUERY_DIR = "/queries/";
     private final Logger LOGGER = LoggerFactory.getLogger(AntiPatternRepository.class);
-
     private ServletContext servletContext;
     private Map<Long, AntiPatternDetector> antiPatternDetectors = init();
 
-    private static final String QUERY_DIR = "/queries/" ;
-
     private Map<Long, AntiPatternDetector> init() {
         LOGGER.info("-------START CREATING DETECTORS WITH REFLECTION-------");
         Map<Long, AntiPatternDetector> antiPatterns = new HashMap<>();
@@ -57,29 +55,39 @@ public class AntiPatternRepository implements ServletContextAware {
         this.servletContext = servletContext;
         LOGGER.info("-------START READING SQL FROM FILES-------");
         for (AntiPatternDetector antiPatternDetector : getAllAntiPatterns()) {
-            LOGGER.info("Reading sql from file " + antiPatternDetector.getAntiPatternSqlFileName());
-            antiPatternDetector.setSqlQueries(loadSqlFile(antiPatternDetector.getAntiPatternSqlFileName()));
+            LOGGER.info("Reading sql files for AP " + antiPatternDetector.getAntiPatternModel().getPrintName());
+            antiPatternDetector.setSqlQueries(loadSqlFile(antiPatternDetector.getSqlFileNames()));
+
         }
         LOGGER.info("-------FINISHED READING SQL FROM FILES-------");
     }
 
-    private List<String> loadSqlFile(String fileName) {
+    /**
+     * Method for loading list of sql files from given list of files
+     * @param fileNames list of files with sql queries
+     * @return list of queries
+     */
+    private List<String> loadSqlFile(List<String> fileNames) {
         List<String> queries = new ArrayList<>();
 
-        try {
-            URL test = servletContext.getResource(QUERY_DIR + fileName);
-            BufferedReader read = new BufferedReader(
-                    new InputStreamReader(test.openStream()));
-            String line;
-            while ((line = read.readLine()) != null) {
-                if (line.startsWith("select") || line.startsWith("set") && line.charAt(line.length()-1) == ';') {
-                    queries.add(line);
+        // walk through all sql filenames and load all sql queries
+        for (String fileName : fileNames) {
+            LOGGER.info("Reading sql query from file name " + fileName);
+            try {
+                URL test = servletContext.getResource(QUERY_DIR + fileName);
+                BufferedReader read = new BufferedReader(
+                        new InputStreamReader(test.openStream()));
+                String line;
+                while ((line = read.readLine()) != null) {
+                    if (line.startsWith("select") || line.startsWith("set") && line.charAt(line.length() - 1) == ';') {
+                        queries.add(line);
+                    }
                 }
+                read.close();
+            } catch (IOException e) {
+                LOGGER.warn("Cannot read sql from file " + fileName, e);
+                return queries;
             }
-            read.close();
-        } catch (IOException e) {
-            LOGGER.warn("Cannot read sql from file " + fileName, e);
-            return queries;
         }
         return queries;
     }
diff --git a/src/main/webapp/queries/business_as_usual.sql b/src/main/webapp/queries/business_as_usual.sql
deleted file mode 100644
index 88663c0..0000000
--- a/src/main/webapp/queries/business_as_usual.sql
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Anti-pattern name: Business as usual (No sprint retrospective)
-
-Description: Absence of a retrospective after individual
-             iterations or after the completion project.
-
-Detection: There will be no activities in the project
-           that would indicate that a retrospective is
-           taking place (issue with the name of the
-           retrospective, issue on which all team members
-           log, issue that is repeated periodically,
-           issue to which no commit is bound, issue which
-           will be marked as administration or something like that).
-           There will be no notes in the wiki or other tool called
-           retrospectives (%retr%).
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Number of iterations for given project */
-select COUNT(id) as 'numberOfIterations' from iteration where superProjectId = @projectId and name like '%itera%';
-/* Select all iteration with detected retrospective activities */
-select iterationName as 'iterationName', count(name) as 'numberOfIssues' from workUnitView where projectId = @projectId and (lower(name) like lower('§0§') or lower(name) like lower('§1§') or lower(name) like lower('§2§') or lower(name) like lower('§3§') or lower(name) like lower('§4§') or lower(name) like lower('§5§') or lower(name) like lower('§6§') or lower(name) like lower('§7§') or lower(name) like lower('§8§') or lower(name) like lower('§9§')) group by iterationName;
-/* Select all wikipages that were created or updated in iteration and have name with retr or revi*/
-select iteration.name as 'iterationName', count(distinct(artifactView.name)) as 'numberOfWikiPages' from artifactView inner join fieldChangeView on artifactView.id = fieldChangeView.itemId inner join iteration on (fieldChangeView.created between iteration.startDate and iteration.endDate) and iteration.superProjectId = @projectId where artifactView.projectId = @projectId and artifactView.artifactClass like 'WIKIPAGE' and (lower(artifactView.name) like lower('§0§') or lower(artifactView.name) like lower('§1§') or lower(artifactView.name) like lower('§2§') or lower(artifactView.name) like lower('§3§') or lower(artifactView.name) like lower('§4§') or lower(artifactView.name) like lower('§5§') or lower(artifactView.name) like lower('§6§') or lower(artifactView.name) like lower('§7§') or lower(artifactView.name) like lower('§8§') or lower(artifactView.name) like lower('§9§')) group by iteration.id order by iteration.name;
diff --git a/src/main/webapp/queries/long_or_non_existent_feedback_loops.sql b/src/main/webapp/queries/long_or_non_existent_feedback_loops.sql
deleted file mode 100644
index d7e1e03..0000000
--- a/src/main/webapp/queries/long_or_non_existent_feedback_loops.sql
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-Anti-pattern name: Long Or Non-Existant Feedback Loops (No Customer feedback)
-
-Description: Long spacings between customer feedback or no feedback. The customer
-             enters the project and sees the final result. In the end, the customer
-             may not get what he really wanted. With long intervals of feedback,
-             some misunderstood functionality can be created and we have to spend
-             a lot of effort and time to redo it.
-
-
-Detection: How to choose what is the optimal spacing between feedbacks? In ASWI,
-           it was mostly after each iteration, ie 2-3 weeks apart. Check if there
-           is an activity that is repeated periodically, all team members or
-           leaders log time on it (essentially a similar issue as in the anti-Business
-           as usual model). Search for an activity named "DEMO", "CUSTOMER", etc.
-           Search for some records from the demo in the wiki. Similar to Business as usual.
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Number of iterations for given project */
-select COUNT(id) as 'numberOfIterations' from iteration where superProjectId = @projectId;
-/* Average iteration length */
-select avg(abs(dateDiff(iteration.endDate, iteration.startDate))) as 'averageIterationLength' from iteration where superProjectId = @projectId;
-/* Select number of iterations which contains at least one feedback activity */
-select count(*) over () as 'totalCountOfIterationsWithFeedbackActivity' from workUnitView as wuv where wuv.projectId = @projectId and (wuv.name like '§0§' or wuv.name like '§1§' or wuv.name like '§2§' or wuv.name like '§3§' or wuv.name like '§4§' or wuv.name like '§5§' or wuv.name like '§6§' or wuv.name like '§7§' or wuv.name like '§8§' or wuv.name like '§9§') group by wuv.iterationName order by wuv.activityEndDate;
-/* Select all activities for feedback loop with last modified date as end date */
-select wuv.id, wuv.iterationName, wuv.name, cast(max(fieldChangeView.created) as date) as 'endDate' from workUnitView as wuv inner join fieldChangeView on wuv.id = fieldChangeView.itemId where wuv.projectId = @projectId and (wuv.name like '§0§' or wuv.name like '§1§' or wuv.name like '§2§' or wuv.name like '§3§' or wuv.name like '§4§' or wuv.name like '§5§' or wuv.name like '§6§' or wuv.name like '§7§' or wuv.name like '§8§' or wuv.name like '§9§') GROUP by id order by fieldChangeView.created;
-/* Get project start date */
-select startDate as 'projectStartDate' from iteration where superProjectId = @projectId order by startDate limit 1;
-/* Get project end date */
-select endDate as 'projectEndDate' from iteration where superProjectId = @projectId order by endDate desc limit 1;
-/* Select all iterations that contains wiki pages which were created or updated in iteration and have name or description that mentions some key words for customer demo*/
-select iteration.name as 'iterationWithCustomerFeedback', cast(max(fieldChangeView.created) as date) as 'appointmentDate' from artifactView inner join fieldChangeView on artifactView.id = fieldChangeView.itemId inner join iteration on (fieldChangeView.created between iteration.startDate and iteration.endDate) and iteration.superProjectId = @projectId where artifactView.artifactClass like 'WIKIPAGE' and artifactView.projectId = @projectId and length(fieldChangeView.newValue) > length(fieldChangeView.oldValue) and (artifactView.name like '§0§' or artifactView.name like '§1§' or artifactView.name like '§2§' or artifactView.name like '§3§' or artifactView.name like '§4§' or artifactView.name like '§5§' or artifactView.name like '§6§' or artifactView.name like '§7§' or artifactView.name like '§8§' or artifactView.name like '§9§') group by iteration.name order by iteration.name;
diff --git a/src/main/webapp/queries/ninety_ninety_rule.sql b/src/main/webapp/queries/ninety_ninety_rule.sql
deleted file mode 100644
index 9c360f7..0000000
--- a/src/main/webapp/queries/ninety_ninety_rule.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-Anti-pattern name: Ninety-Ninety Rule
-
-Description: The first 90 percent of the code represents the first 90 percent of development time. The
-             remaining 10 percent of the code represents another 90 percent of development time.
-             Then decide on a long delay of the project compared to the original estimate.
-             The functionality is almost done, some number is already closed and is only waiting
-             for one activity to close, but it has been open for a long time.
-
-Detection: Compare the estimated time and time spent in each iteration. If the estimates deteriorate
-           continuously during the project, it will be detected.
-
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Select all activities for each iteration and sum estimated time and spent time */
-select iterationName, sum(estimatedTime) as 'estimatedTime', sum(spentTime) as 'spentTime', sum(spentTime)/sum(estimatedTime) as 'timeDivision',  abs(1-(sum(spentTime)/sum(estimatedTime))) as 'deviation' from workUnitView where projectid = @projectId and iterationName is not null group by iterationName order by iterationName;
diff --git a/src/main/webapp/queries/road_to_nowhere.sql b/src/main/webapp/queries/road_to_nowhere.sql
deleted file mode 100644
index 901d77c..0000000
--- a/src/main/webapp/queries/road_to_nowhere.sql
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-Anti-pattern name: Road To Nowhere
-
-Description: The project is not sufficiently planned and therefore
-             takes place on an ad hoc basis with an uncertain
-             outcome and deadline. There is no project plan in the project.
-
-Detection: There is no activity in ALM that would indicate the creation
-           of a project plan. There will be no document in the wiki
-           called the "Project Plan". Project plan should be created in first or
-           second iteration. Also could be detected with field change view. If is
-           a lot of changes on issues in the beginning of the iteration so then could
-           indicate some planning.
-*/
-set @projectId = ?;
-set @firstIterationStartDate = (select startDate from iteration where superProjectId = @projectId ORDER BY startDate LIMIT 1 offset 0);
-set @secondIterationStartDate = (select startDate from iteration where superProjectId = @projectId ORDER BY startDate LIMIT 1 offset 1);
-set @numberOfIssuesForProjectPlan = (SELECT count(*) from workUnitView where projectId = @projectId  and (lower(workUnitView.name) like lower('§0§') or lower(workUnitView.description) like lower('§0§') or lower(workUnitView.name) like lower('§1§') or lower(workUnitView.description) like lower('§1§') or lower(workUnitView.name) like lower('§2§') or lower(workUnitView.description) like lower('§2§') or lower(workUnitView.name) like lower('§3§') or lower(workUnitView.description) like lower('§3§') or lower(workUnitView.name) like lower('§4§') or lower(workUnitView.description) like lower('§4§') or lower(workUnitView.name) like lower('§5§') or lower(workUnitView.description) like lower('§5§') or lower(workUnitView.name) like lower('§6§') or lower(workUnitView.description) like lower('§6§') or lower(workUnitView.name) like lower('§7§') or lower(workUnitView.description) like lower('§7§') or lower(workUnitView.name) like lower('§8§') or lower(workUnitView.description) like lower('§8§') or lower(workUnitView.name) like lower('§9§') or lower(workUnitView.description) like lower('§9§')) AND (iterationStartDate = @firstIterationStartDate OR iterationStartDate = @secondIterationStartDate));
-set @numberOfWikiPagesForProjectPlan = (SELECT count(*) from artifactView where projectId = @projectId AND artifactClass like 'WIKIPAGE' AND (lower(artifactView.name) like lower('§0§') or lower(artifactView.description) like lower('§0§') or lower(artifactView.name) like lower('§1§') or lower(artifactView.description) like lower('§1§') or lower(artifactView.name) like lower('§2§') or lower(artifactView.description) like lower('§2§') or lower(artifactView.name) like lower('§3§') or lower(artifactView.description) like lower('§3§') or lower(artifactView.name) like lower('§4§') or lower(artifactView.description) like lower('§4§') or lower(artifactView.name) like lower('§5§') or lower(artifactView.description) like lower('§5§') or lower(artifactView.name) like lower('§6§') or lower(artifactView.description) like lower('§6§') or lower(artifactView.name) like lower('§7§') or lower(artifactView.description) like lower('§7§') or lower(artifactView.name) like lower('§8§') or lower(artifactView.description) like lower('§8§') or lower(artifactView.name) like lower('§9§') or lower(artifactView.description) like lower('§9§')));
-select @projectId as `projectId`, @numberOfIssuesForProjectPlan as `numberOfIssuesForProjectPlan`, @numberOfWikiPagesForProjectPlan as `numberOfWikiPagesForProjectPlan`;
diff --git a/src/main/webapp/queries/select_all_activities_with_substrings_and_last_modified_date_as_end_date.sql b/src/main/webapp/queries/select_all_activities_with_substrings_and_last_modified_date_as_end_date.sql
new file mode 100644
index 0000000..2f39d78
--- /dev/null
+++ b/src/main/webapp/queries/select_all_activities_with_substrings_and_last_modified_date_as_end_date.sql
@@ -0,0 +1,2 @@
+/* Select all activities with substrings and with last modified date as end date */
+select wuv.id, wuv.iterationName, wuv.name, cast(max(fieldChangeView.created) as date) as 'endDate' from workUnitView as wuv inner join fieldChangeView on wuv.id = fieldChangeView.itemId where wuv.projectId = @projectId and (wuv.name like '§0§' or wuv.name like '§1§' or wuv.name like '§2§' or wuv.name like '§3§' or wuv.name like '§4§' or wuv.name like '§5§' or wuv.name like '§6§' or wuv.name like '§7§' or wuv.name like '§8§' or wuv.name like '§9§') GROUP by id order by fieldChangeView.created;
diff --git a/src/main/webapp/queries/select_all_iterations_that_contains_wikipages_with_substrings.sql b/src/main/webapp/queries/select_all_iterations_that_contains_wikipages_with_substrings.sql
new file mode 100644
index 0000000..b3c218a
--- /dev/null
+++ b/src/main/webapp/queries/select_all_iterations_that_contains_wikipages_with_substrings.sql
@@ -0,0 +1,2 @@
+/* Select all iterations that contains wiki pages which were created or updated in iteration and have name or description that mentions some key words for customer demo*/
+select iteration.name as 'iterationWithCustomerFeedback', cast(max(fieldChangeView.created) as date) as 'appointmentDate' from artifactView inner join fieldChangeView on artifactView.id = fieldChangeView.itemId inner join iteration on (fieldChangeView.created between iteration.startDate and iteration.endDate) and iteration.superProjectId = @projectId where artifactView.artifactClass like 'WIKIPAGE' and artifactView.projectId = @projectId and length(fieldChangeView.newValue) > length(fieldChangeView.oldValue) and (artifactView.name like '§0§' or artifactView.name like '§1§' or artifactView.name like '§2§' or artifactView.name like '§3§' or artifactView.name like '§4§' or artifactView.name like '§5§' or artifactView.name like '§6§' or artifactView.name like '§7§' or artifactView.name like '§8§' or artifactView.name like '§9§') group by iteration.name order by iteration.name;
diff --git a/src/main/webapp/queries/select_all_iterations_with_lengths_without_first_and_last.sql b/src/main/webapp/queries/select_all_iterations_with_lengths_without_first_and_last.sql
new file mode 100644
index 0000000..00b77b3
--- /dev/null
+++ b/src/main/webapp/queries/select_all_iterations_with_lengths_without_first_and_last.sql
@@ -0,0 +1,2 @@
+/* !Global variables must be set for proper behavior! Select all iterations with their length without first and last iterations */
+select datediff(endDate, startDate) as `iterationLength` from iteration where iteration.superProjectId = @projectId and iteration.id != @idOfFirstIteration and iteration.id != @idOfLastIteration order by iteration.name;
diff --git a/src/main/webapp/queries/select_all_iterations_with_sum_estimated_and_spent_time.sql b/src/main/webapp/queries/select_all_iterations_with_sum_estimated_and_spent_time.sql
new file mode 100644
index 0000000..f2cbee9
--- /dev/null
+++ b/src/main/webapp/queries/select_all_iterations_with_sum_estimated_and_spent_time.sql
@@ -0,0 +1,2 @@
+/* Select all activities for each iteration and sum estimated time and spent time */
+select iterationName, sum(estimatedTime) as 'estimatedTime', sum(spentTime) as 'spentTime', sum(spentTime)/sum(estimatedTime) as 'timeDivision',  abs(1-(sum(spentTime)/sum(estimatedTime))) as 'deviation' from workUnitView where projectid = @projectId and iterationName is not null group by iterationName order by iterationName;
diff --git a/src/main/webapp/queries/select_all_wikipages_that_is_updated_in_iteration.sql b/src/main/webapp/queries/select_all_wikipages_that_is_updated_in_iteration.sql
new file mode 100644
index 0000000..1a98374
--- /dev/null
+++ b/src/main/webapp/queries/select_all_wikipages_that_is_updated_in_iteration.sql
@@ -0,0 +1,2 @@
+/* Select all wikipages that were created or updated in iteration and have name with retr or revi*/
+select iteration.name as 'iterationName', count(distinct(artifactView.name)) as 'numberOfWikiPages' from artifactView inner join fieldChangeView on artifactView.id = fieldChangeView.itemId inner join iteration on (fieldChangeView.created between iteration.startDate and iteration.endDate) and iteration.superProjectId = @projectId where artifactView.projectId = @projectId and artifactView.artifactClass like 'WIKIPAGE' and (lower(artifactView.name) like lower('§0§') or lower(artifactView.name) like lower('§1§') or lower(artifactView.name) like lower('§2§') or lower(artifactView.name) like lower('§3§') or lower(artifactView.name) like lower('§4§') or lower(artifactView.name) like lower('§5§') or lower(artifactView.name) like lower('§6§') or lower(artifactView.name) like lower('§7§') or lower(artifactView.name) like lower('§8§') or lower(artifactView.name) like lower('§9§')) group by iteration.id order by iteration.name;
diff --git a/src/main/webapp/queries/select_average_iterations_length.sql b/src/main/webapp/queries/select_average_iterations_length.sql
new file mode 100644
index 0000000..db4fad6
--- /dev/null
+++ b/src/main/webapp/queries/select_average_iterations_length.sql
@@ -0,0 +1,2 @@
+/* Average iteration length */
+select avg(abs(dateDiff(iteration.endDate, iteration.startDate))) as 'averageIterationLength' from iteration where superProjectId = @projectId;
diff --git a/src/main/webapp/queries/select_iterations_with_substrings.sql b/src/main/webapp/queries/select_iterations_with_substrings.sql
new file mode 100644
index 0000000..957c941
--- /dev/null
+++ b/src/main/webapp/queries/select_iterations_with_substrings.sql
@@ -0,0 +1,2 @@
+/* Select all iteration with detected retrospective activities */
+select iterationName as 'iterationName', count(name) as 'numberOfIssues' from workUnitView where projectId = @projectId and (lower(name) like lower('§0§') or lower(name) like lower('§1§') or lower(name) like lower('§2§') or lower(name) like lower('§3§') or lower(name) like lower('§4§') or lower(name) like lower('§5§') or lower(name) like lower('§6§') or lower(name) like lower('§7§') or lower(name) like lower('§8§') or lower(name) like lower('§9§')) group by iterationName;
diff --git a/src/main/webapp/queries/select_number_of_activities_and_wiki_pages_with_substrings.sql b/src/main/webapp/queries/select_number_of_activities_and_wiki_pages_with_substrings.sql
new file mode 100644
index 0000000..2d0ad48
--- /dev/null
+++ b/src/main/webapp/queries/select_number_of_activities_and_wiki_pages_with_substrings.sql
@@ -0,0 +1,2 @@
+/* !Global variables must be set for proper behavior.! Select number of activities and wiki pages with given substrings and for given projects. */
+select @projectId as `projectId`, @numberOfActivitiesWithSubstrings as `numberOfActivitiesWithSubstrings`, @numberOfWikiPagesWithSubstrings as `numberOfWikiPagesWithSubstrings`;
diff --git a/src/main/webapp/queries/select_number_of_iterations.sql b/src/main/webapp/queries/select_number_of_iterations.sql
new file mode 100644
index 0000000..fbb36a4
--- /dev/null
+++ b/src/main/webapp/queries/select_number_of_iterations.sql
@@ -0,0 +1,2 @@
+/* Number of iterations for given project */
+select COUNT(id) as 'numberOfIterations' from iteration where superProjectId = @projectId and name like '%itera%';
diff --git a/src/main/webapp/queries/select_number_of_iterations_with_substrings_in_activity.sql b/src/main/webapp/queries/select_number_of_iterations_with_substrings_in_activity.sql
new file mode 100644
index 0000000..4333035
--- /dev/null
+++ b/src/main/webapp/queries/select_number_of_iterations_with_substrings_in_activity.sql
@@ -0,0 +1,2 @@
+/* Select number of iterations which with substring in activity */
+select count(*) over () as 'totalCountOfIterationsWithSubstringsInActivity' from workUnitView as wuv where wuv.projectId = @projectId and (wuv.name like '§0§' or wuv.name like '§1§' or wuv.name like '§2§' or wuv.name like '§3§' or wuv.name like '§4§' or wuv.name like '§5§' or wuv.name like '§6§' or wuv.name like '§7§' or wuv.name like '§8§' or wuv.name like '§9§') group by wuv.iterationName order by wuv.activityEndDate;
diff --git a/src/main/webapp/queries/select_project_end_date.sql b/src/main/webapp/queries/select_project_end_date.sql
new file mode 100644
index 0000000..f307cc7
--- /dev/null
+++ b/src/main/webapp/queries/select_project_end_date.sql
@@ -0,0 +1,2 @@
+/* Get project end date */
+select endDate as 'projectEndDate' from iteration where superProjectId = @projectId order by endDate desc limit 1;
diff --git a/src/main/webapp/queries/select_project_start_date.sql b/src/main/webapp/queries/select_project_start_date.sql
new file mode 100644
index 0000000..cf9ade2
--- /dev/null
+++ b/src/main/webapp/queries/select_project_start_date.sql
@@ -0,0 +1,2 @@
+/* Get project start date */
+select startDate as 'projectStartDate' from iteration where superProjectId = @projectId order by startDate limit 1;
diff --git a/src/main/webapp/queries/select_statistics_for_given_project.sql b/src/main/webapp/queries/select_statistics_for_given_project.sql
new file mode 100644
index 0000000..6186188
--- /dev/null
+++ b/src/main/webapp/queries/select_statistics_for_given_project.sql
@@ -0,0 +1,2 @@
+/* !Global variables must be set for proper behavior! Show number of wiki pages, number */
+select @projectId as `projectId`, @numberOfWikiPagesWithSubstrings as `numberOfWikiPagesWithSubstrings`, @numberOfActivitiesWithSubstrings as `numberOfActivitiesWithSubstrings`, @averageLengthOfIssueDescription as `averageLengthOfIssueDescription`;
diff --git a/src/main/webapp/queries/set_average_length_of_activities_description.sql b/src/main/webapp/queries/set_average_length_of_activities_description.sql
new file mode 100644
index 0000000..32a01d8
--- /dev/null
+++ b/src/main/webapp/queries/set_average_length_of_activities_description.sql
@@ -0,0 +1,2 @@
+/* Count average length of issues description */
+set @averageLengthOfIssueDescription = (select AVG(CHAR_LENGTH(workUnitView.description)) from workUnitView where workUnitView.projectId = @projectId);
diff --git a/src/main/webapp/queries/set_first_iteration_id.sql b/src/main/webapp/queries/set_first_iteration_id.sql
new file mode 100644
index 0000000..b290ba6
--- /dev/null
+++ b/src/main/webapp/queries/set_first_iteration_id.sql
@@ -0,0 +1,2 @@
+/* Id of first iteration */
+set @idOfFirstIteration = (select id from iteration where iteration.superProjectId = @projectId order by name limit 1);
diff --git a/src/main/webapp/queries/set_first_iteration_start_date.sql b/src/main/webapp/queries/set_first_iteration_start_date.sql
new file mode 100644
index 0000000..fcb1cba
--- /dev/null
+++ b/src/main/webapp/queries/set_first_iteration_start_date.sql
@@ -0,0 +1,2 @@
+/* set first iteration start date to the global values named @firstIterationStartDate */
+set @firstIterationStartDate = (select startDate from iteration where superProjectId = @projectId ORDER BY startDate LIMIT 1 offset 0);
diff --git a/src/main/webapp/queries/set_last_iteration_id.sql b/src/main/webapp/queries/set_last_iteration_id.sql
new file mode 100644
index 0000000..71bfb81
--- /dev/null
+++ b/src/main/webapp/queries/set_last_iteration_id.sql
@@ -0,0 +1,2 @@
+/* Id of last iteration */
+set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by name desc limit 1);
diff --git a/src/main/webapp/queries/set_number_of_activities_with_substrings.sql b/src/main/webapp/queries/set_number_of_activities_with_substrings.sql
new file mode 100644
index 0000000..31d88df
--- /dev/null
+++ b/src/main/webapp/queries/set_number_of_activities_with_substrings.sql
@@ -0,0 +1,2 @@
+/* Select number of activities with given substrings and set it to the global value named @numberOfActivitiesWithSubstrings */
+set @numberOfActivitiesWithSubstrings = (SELECT count(*) from workUnitView where projectId = @projectId  and (lower(workUnitView.name) like lower('§0§') or lower(workUnitView.description) like lower('§0§') or lower(workUnitView.name) like lower('§1§') or lower(workUnitView.description) like lower('§1§') or lower(workUnitView.name) like lower('§2§') or lower(workUnitView.description) like lower('§2§') or lower(workUnitView.name) like lower('§3§') or lower(workUnitView.description) like lower('§3§') or lower(workUnitView.name) like lower('§4§') or lower(workUnitView.description) like lower('§4§') or lower(workUnitView.name) like lower('§5§') or lower(workUnitView.description) like lower('§5§') or lower(workUnitView.name) like lower('§6§') or lower(workUnitView.description) like lower('§6§') or lower(workUnitView.name) like lower('§7§') or lower(workUnitView.description) like lower('§7§') or lower(workUnitView.name) like lower('§8§') or lower(workUnitView.description) like lower('§8§') or lower(workUnitView.name) like lower('§9§') or lower(workUnitView.description) like lower('§9§')) AND (iterationStartDate = @firstIterationStartDate OR iterationStartDate = @secondIterationStartDate));
diff --git a/src/main/webapp/queries/set_number_of_wiki_pages_with_substrings.sql b/src/main/webapp/queries/set_number_of_wiki_pages_with_substrings.sql
new file mode 100644
index 0000000..766ec19
--- /dev/null
+++ b/src/main/webapp/queries/set_number_of_wiki_pages_with_substrings.sql
@@ -0,0 +1,2 @@
+/* Select number of wiki pages with given substrings and set it to the global value named @numberOfWikiPagesWithSubstrings */
+set @numberOfWikiPagesWithSubstrings = (SELECT count(*) from artifactView where projectId = @projectId AND artifactClass like 'WIKIPAGE' AND (lower(artifactView.name) like lower('§0§') or lower(artifactView.description) like lower('§0§') or lower(artifactView.name) like lower('§1§') or lower(artifactView.description) like lower('§1§') or lower(artifactView.name) like lower('§2§') or lower(artifactView.description) like lower('§2§') or lower(artifactView.name) like lower('§3§') or lower(artifactView.description) like lower('§3§') or lower(artifactView.name) like lower('§4§') or lower(artifactView.description) like lower('§4§') or lower(artifactView.name) like lower('§5§') or lower(artifactView.description) like lower('§5§') or lower(artifactView.name) like lower('§6§') or lower(artifactView.description) like lower('§6§') or lower(artifactView.name) like lower('§7§') or lower(artifactView.description) like lower('§7§') or lower(artifactView.name) like lower('§8§') or lower(artifactView.description) like lower('§8§') or lower(artifactView.name) like lower('§9§') or lower(artifactView.description) like lower('§9§')));
diff --git a/src/main/webapp/queries/set_project_id.sql b/src/main/webapp/queries/set_project_id.sql
new file mode 100644
index 0000000..31226cf
--- /dev/null
+++ b/src/main/webapp/queries/set_project_id.sql
@@ -0,0 +1,2 @@
+/* Init project id */
+set @projectId = ?;
diff --git a/src/main/webapp/queries/set_second_iteration_start_date.sql b/src/main/webapp/queries/set_second_iteration_start_date.sql
new file mode 100644
index 0000000..8abc038
--- /dev/null
+++ b/src/main/webapp/queries/set_second_iteration_start_date.sql
@@ -0,0 +1,2 @@
+/* set second iteration start date to the global values named @firstIterationStartDate */
+set @secondIterationStartDate = (select startDate from iteration where superProjectId = @projectId ORDER BY startDate LIMIT 1 offset 1);
diff --git a/src/main/webapp/queries/specify_nothing.sql b/src/main/webapp/queries/specify_nothing.sql
deleted file mode 100644
index db0deb0..0000000
--- a/src/main/webapp/queries/specify_nothing.sql
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-Anti-pattern name: Specify nothing
-
-Description: The specification is not done intentionally. Programmers are
-             expected to work better without written specifications.
-
-Detection: No specification artifact. There is no issue that will have something
-           like "DSP, SPECIFICATIONS, ETC." in the title. Initially, meetings
-           with the customer should be more frequent to clarify the project framework.
-            No entry in the wiki with the project specification.
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Find number of wikipages with some project specification */
-set @numberOfWikiPages = (select count(name) from artifactView where projectId = @projectId and artifactClass = 'WIKIPAGE' and (lower(name) like lower('§0§') or lower(description) like lower('§0§') or lower(name) like lower('§1§') or lower(description) like lower('§1§') or lower(name) like lower('§2§') or lower(description) like lower('§2§') or lower(name) like lower('§3§') or lower(description) like lower('§3§') or lower(name) like lower('§4§') or lower(description) like lower('§4§') or lower(name) like lower('§5§') or lower(description) like lower('§5§') or lower(name) like lower('§6§') or lower(description) like lower('§6§') or lower(name) like lower('§7§') or lower(description) like lower('§7§') or lower(name) like lower('§8§') or lower(description) like lower('§8§') or lower(name) like lower('§9§') or lower(description) like lower('§9§')));
-/* Find activities for creating DSP or project specification */
-set @numberOfActivitiesForSpecification = (SELECT count(id) from workUnitView where projectId = @projectId and (lower(name) like lower('§0§') or lower(name) like lower('§1§') or lower(name) like lower('§2§') or lower(name) like lower('§3§') or lower(name) like lower('§4§') or lower(name) like lower('§5§') or lower(name) like lower('§6§') or lower(name) like lower('§7§') or lower(name) like lower('§8§') or lower(name) like lower('§9§')));
-/* Count average length of issues description */
-set @averageLengthOfIssueDescription = (select AVG(CHAR_LENGTH(workUnitView.description)) from workUnitView where workUnitView.projectId = @projectId);
-/* Show all statistics */
-select @projectId as `projectId`, @numberOfWikiPages as `numberOfWikiPages`, @numberOfActivitiesForSpecification as `numberOfActivitiesForSpecification`, @averageLengthOfIssueDescription as `averageLengthOfIssueDescription`;
diff --git a/src/main/webapp/queries/too_long_sprint.sql b/src/main/webapp/queries/too_long_sprint.sql
deleted file mode 100644
index 29803c7..0000000
--- a/src/main/webapp/queries/too_long_sprint.sql
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-Anti-pattern name: Too Long Sprint
-
-Description: Iterations too long. (ideal iteration length is about 1-2 weeks,
-             maximum 3 weeks). It could also be detected here if the length
-             of the iteration does not change often (It can change at the
-             beginning and at the end of the project, but it should not
-             change in the already started project).
-
-Detection: Detect the beginning and end of the iteration and what is
-           the interval between these time points. We should exclude
-           the initial and final iterations, as they could skew the result.
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Exclude first and last iteration? */
-set @excludeFirstAndLastIteration = true;
-/* Id of first iteration */
-set @idOfFirstIteration = (select id from iteration where iteration.superProjectId = @projectId order by name limit 1);
-/* Id of last iteration */
-set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by name desc limit 1);
-/* Select all iterations with their length */
-select datediff(endDate, startDate) as `iterationLength` from iteration where iteration.superProjectId = @projectId and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfFirstIteration, -1) and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfLastIteration, -1) order by iteration.name;
diff --git a/src/main/webapp/queries/varying_sprint_length.sql b/src/main/webapp/queries/varying_sprint_length.sql
deleted file mode 100644
index a78e35f..0000000
--- a/src/main/webapp/queries/varying_sprint_length.sql
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-Anti-pattern name: Varying Sprint Length
-
-Description: The length of the sprint changes very often.
-             It is clear that iterations will be different
-             lengths at the beginning and end of the project,
-             but the length of the sprint should not change
-             during the project.
-
-
-Detection: Detect sprint lengths throughout the project
-           and see if they are too different. Possibility to
-           eliminate the first and last sprint. It could be
-           otherwise long. Detection would be similar to
-           Too Long sprint anti-pattern.
-*/
-
-/* Init project id */
-set @projectId = ?;
-/* Exclude first and last iteration? */
-set @excludeFirstAndLastIteration = true;
-/* Id of first iteration */
-set @idOfFirstIteration = (select id from iteration where iteration.superProjectId = @projectId order by name limit 1);
-/* Id of last iteration */
-set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by name desc limit 1);
-/* Select all iterations with their length */
-select datediff(endDate, startDate) as `iterationLength` from iteration where iteration.superProjectId = @projectId and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfFirstIteration, -1) and iteration.id != if(@excludeFirstAndLastIteration = true, @idOfLastIteration, -1) order by iteration.name;
