commit 2964b75c1f9b8a5b27052b43aeb9e29bf51d6657
Author: Ondřej Váně <onry.vane@gmail.com>
Date:   Wed Apr 7 11:11:33 2021 +0200

    Migration project from local storage to git

diff --git a/pom.xml b/pom.xml
index bc659b4..49ce951 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,18 +20,34 @@
 	<dependencies>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-web</artifactId>
+			<artifactId>spring-boot-starter</artifactId>
 		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-tomcat</artifactId>
-			<scope>provided</scope>
+			<artifactId>spring-boot-starter-test</artifactId>
+			<scope>test</scope>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
-			<artifactId>spring-boot-starter-test</artifactId>
-			<scope>test</scope>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>mysql</groupId>
+			<artifactId>mysql-connector-java</artifactId>
+			<scope>runtime</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-web</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-thymeleaf</artifactId>
 		</dependency>
 	</dependencies>
 
@@ -42,6 +58,14 @@
 				<artifactId>spring-boot-maven-plugin</artifactId>
 			</plugin>
 		</plugins>
+		<resources>
+			<resource>
+				<directory>src/main/java/resources</directory>
+				<includes>
+					<include>queries/*.sql</include>
+				</includes>
+			</resource>
+		</resources>
 	</build>
 
 </project>
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/Utils.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/Utils.java
new file mode 100644
index 0000000..685f1c7
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/Utils.java
@@ -0,0 +1,48 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.sql.Date;
+import java.time.LocalDate;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Utils {
+
+    public static String bindValues(String query, List<String> parameters) {
+        for (String parameter : parameters) {
+            query = query.replace("?", parameter);
+        }
+        return query;
+    }
+
+    public static List<String> loadQueryFromFile(String fileName) {
+        List<String> queries = new ArrayList<>();
+        InputStream is = Utils.class.getClassLoader().getResourceAsStream(fileName);
+        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+        try {
+            while (reader.ready()) {
+
+                String line = reader.readLine();
+                if (line.startsWith("select") || line.startsWith("set")) {
+                    queries.add(line);
+                }
+
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return queries;
+    }
+
+    public static long daysBetween(Date firstDate, Date secondDate) {
+        //24-May-2017, change this to your desired Start Date
+        LocalDate dateBefore = firstDate.toLocalDate();
+        //29-July-2017, change this to your desired End Date
+        LocalDate dateAfter = secondDate.toLocalDate();
+        return ChronoUnit.DAYS.between(dateBefore, dateAfter);
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
new file mode 100644
index 0000000..e1fba1b
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
@@ -0,0 +1,127 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.controller;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.AntiPatternManager;
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.AntiPatternsEnum;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.AntiPattern;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Query;
+import cz.zcu.fav.kiv.antipatterndetectionapp.repository.ProjectRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+@Controller
+public class AppController {
+
+    @Autowired
+    private ProjectRepository projectRepository;
+
+    @Autowired
+    private AntiPatternManager antiPatternManager;
+
+    @GetMapping("/")
+    public String index(Model model) {
+        model.addAttribute("query", createQuery());
+        return "index";
+    }
+
+    @GetMapping("/projects/{id}")
+    public String getProjectById(@PathVariable Long id, Model model) {
+        Optional<Project> foundProject = projectRepository.findById(id);
+        if (foundProject.isPresent()) {
+            Project project = foundProject.get();
+            model.addAttribute("project", project);
+        }
+        return "project";
+    }
+
+    @GetMapping("/anti-patterns")
+    public @ResponseBody
+    List<AntiPattern> getAllAntiPatterns() {
+        List<AntiPattern> antiPatterns = new ArrayList<>();
+        for (AntiPatternsEnum antiPatternEnum : AntiPatternsEnum.values()) {
+            AntiPattern antiPattern = new AntiPattern(antiPatternEnum.id, antiPatternEnum.printName, antiPatternEnum.name, antiPatternEnum.description);
+            antiPatterns.add(antiPattern);
+        }
+        return antiPatterns;
+    }
+
+    @GetMapping("/anti-patterns/{id}")
+    public String getAntiPatternById(@PathVariable Long id, Model model) {
+        for (AntiPatternsEnum antiPatternEnum : AntiPatternsEnum.values()) {
+            if (antiPatternEnum.id.equals(id)) {
+                model.addAttribute("antiPattern", new AntiPattern(antiPatternEnum.id, antiPatternEnum.printName, antiPatternEnum.name, antiPatternEnum.description));
+            }
+        }
+        return "anti-pattern";
+    }
+
+    @PostMapping("/analyze")
+    public String analyze(Model model,
+                          @RequestParam(value = "selectedProjects", required = false) String[] selectedProjects,
+                          @RequestParam(value = "selectedAntiPatterns", required = false) String[] selectedAntiPatterns
+    ) {
+
+        if (selectedProjects == null) {
+            model.addAttribute("errorMessage", "No project selected." +
+                    " Select at least one project.");
+            model.addAttribute("query", createQuery());
+            return "index";
+        }
+
+        if (selectedAntiPatterns == null) {
+            model.addAttribute("errorMessage", "No anti-pattern selected." +
+                    " Select at least one anti-pattern.");
+            model.addAttribute("query", createQuery());
+            return "index";
+        }
+
+        model.addAttribute("queryResults", antiPatternManager.analyze(createQueryToAnalyze(selectedProjects, selectedAntiPatterns)));
+
+        return "result";
+    }
+
+    @GetMapping("/about")
+    public String about() {
+        return "about";
+    }
+
+    private Query createQuery() {
+        List<AntiPattern> antiPatterns = new ArrayList<>();
+        for (AntiPatternsEnum antiPatternEnum : AntiPatternsEnum.values()) {
+            AntiPattern antiPattern = new AntiPattern(antiPatternEnum.id, antiPatternEnum.printName, antiPatternEnum.name, antiPatternEnum.description);
+            antiPatterns.add(antiPattern);
+        }
+        List<Project> projects = new ArrayList<>();
+        for (Project project : projectRepository.findAll()) {
+            projects.add(project);
+        }
+
+        return new Query(projects, antiPatterns);
+    }
+
+    private Query createQueryToAnalyze(String[] selectedProjects, String[] selectedAntiPatterns) {
+        List<Project> projects = new ArrayList<>();
+        for (String selectedProject : selectedProjects) {
+            Optional<Project> project = projectRepository.findById(Long.parseLong(selectedProject));
+            project.ifPresent(projects::add);
+        }
+
+        List<AntiPattern> antiPatterns = new ArrayList<>();
+        for (String selectedAntiPattern : selectedAntiPatterns) {
+            for (AntiPatternsEnum antiPatternEnum : AntiPatternsEnum.values()) {
+                if (antiPatternEnum.id.equals(Long.parseLong(selectedAntiPattern))) {
+                    antiPatterns.add(new AntiPattern(antiPatternEnum.id, antiPatternEnum.printName, antiPatternEnum.name, antiPatternEnum.description));
+                }
+            }
+        }
+
+        return new Query(projects, antiPatterns);
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManager.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManager.java
new file mode 100644
index 0000000..a0d582b
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManager.java
@@ -0,0 +1,11 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Query;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResult;
+
+import java.util.List;
+
+public interface AntiPatternManager  {
+    List<QueryResult> analyze(Query query);
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManagerImpl.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManagerImpl.java
new file mode 100644
index 0000000..7aa3135
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternManagerImpl.java
@@ -0,0 +1,59 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors.*;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.*;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class AntiPatternManagerImpl implements AntiPatternManager {
+
+    public List<QueryResult> analyze(Query query) {
+        DatabaseConnection databaseConnection = new DatabaseConnection();
+
+        List<QueryResult> queryResults = new ArrayList<>();
+
+
+        for (Project project : query.getProjects()) {
+            QueryResult queryResult = new QueryResult();
+            queryResult.setProject(project);
+            List<QueryResultItem> queryResultItems = new ArrayList<>();
+            for (AntiPattern antiPattern : query.getAntiPatterns()) {
+                QueryResultItem queryResultItem = new QueryResultItem();
+                queryResultItem.setAntiPattern(antiPattern);
+                queryResultItem.setDetected(getAntiPatternService(antiPattern).analyze(project, databaseConnection));
+                queryResultItems.add(queryResultItem);
+            }
+            queryResult.setQueryResultItems(queryResultItems);
+            queryResults.add(queryResult);
+
+        }
+
+        databaseConnection.closeConnection();
+
+        return queryResults;
+    }
+
+    private AntiPatternDetector getAntiPatternService(AntiPattern antiPattern) {
+        switch (antiPattern.getName()) {
+            case "TooLongSprint":
+                return new TooLongSprintDetectorDetector();
+            case "BusinessAsUsual":
+                return new BusinessAsUsualDetector();
+            case "VaryingSprintLength":
+                return new VaryingSprintLengthDetector();
+            case "IndifferentSpecialist":
+                return new IndifferentSpecialistDetector();
+            case "LongOrNonExistentFeedbackLoops":
+                return new LongOrNonExistentFeedbackLoopsDetector();
+            case "RoadToNowhere":
+                return new RoadToNowhereDetector();
+            case "SpecifyNothing":
+                return new SpecifyNothingDetector();
+        }
+        return null;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternsEnum.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternsEnum.java
new file mode 100644
index 0000000..a1692f3
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/AntiPatternsEnum.java
@@ -0,0 +1,72 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting;
+
+public enum AntiPatternsEnum {
+
+    TooLongSprint(1L,
+            "TooLongSprint",
+            "Too Long Sprint - DONE",
+            "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)."),
+
+    VaryingSprintLength(2L,
+            "VaryingSprintLength",
+            "Varying Sprint Length - DONE",
+            "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."),
+
+    RoadToNowhere(3L,
+            "RoadToNowhere",
+            "Road To Nowhere - DONE",
+            "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."),
+
+    SpecifyNothing(4L,
+            "SpecifyNothing",
+            "Specify Nothing - DONE",
+            "The specification is not done intentionally. Programmers are " +
+                    "expected to work better without written specifications."),
+
+    BusinessAsUsual(5L,
+            "BusinessAsUsual",
+            "Business As Usual - DONE",
+            "Absence of a retrospective after individual " +
+                    "iterations or after the completion project."),
+
+    IndifferentSpecialist(6L,
+            "IndifferentSpecialist",
+            "Indifferent specialist",
+            "A team member who is a specialist in just one thing and does not want to learn new things. " +
+                    "He refuses to learn new things outside of his specialization. It often disparages other " +
+                    "\"technologies\". They reduce the seriousness of things that do not specialize in his specialization."),
+
+    LongOrNonExistentFeedbackLoops(7L,
+            "LongOrNonExistentFeedbackLoops",
+            "Long Or Non-Existent Feedback Loops",
+            "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. ");
+
+
+
+
+    public final Long id;
+    public final String name;
+    public final String printName;
+    public final String description;
+
+    AntiPatternsEnum(Long id, String name, String printName, String description) {
+        this.id = id;
+        this.name = name;
+        this.printName = printName;
+        this.description = description;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/DatabaseConnection.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/DatabaseConnection.java
new file mode 100644
index 0000000..e477e7d
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/DatabaseConnection.java
@@ -0,0 +1,41 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class DatabaseConnection {
+
+    private static final String connectionUrl = "jdbc:mysql://localhost:3306/ppicha";
+    private static final String user = "root";
+    private static final String password = "";
+
+    private Connection databaseConnection;
+
+    public DatabaseConnection() {
+        this.databaseConnection = createConnection();
+    }
+
+    private Connection createConnection() {
+        Connection conn = null;
+        try {
+             conn = DriverManager.getConnection(connectionUrl, user, password);
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return conn;
+    }
+
+    public void closeConnection() {
+        try {
+            this.databaseConnection.close();
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public Connection getDatabaseConnection() {
+        return databaseConnection;
+    }
+}
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
new file mode 100644
index 0000000..d0a6d45
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java
@@ -0,0 +1,41 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.Utils;
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Arrays;
+import java.util.List;
+
+
+public abstract class AntiPatternDetector {
+    public abstract boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection);
+
+    ResultSet executeQuery(Project project, String queryFileName, DatabaseConnection databaseConnection){
+        Statement stmt;
+        ResultSet resultSet = null;
+        try {
+            stmt = databaseConnection.getDatabaseConnection().createStatement();
+
+        List<String> queries = Utils.loadQueryFromFile(queryFileName);
+        ResultSet rs = null;
+        for (String query : queries) {
+            if(queries.indexOf(query) != queries.size()-1){
+                if(query.contains("?"))
+                    query = Utils.bindValues(query, Arrays.asList(project.getId().toString()));
+                stmt.executeQuery(query);
+            } else {
+                resultSet = stmt.executeQuery(query);
+            }
+
+        }
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return resultSet;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetector.java
new file mode 100644
index 0000000..3b2128a
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetector.java
@@ -0,0 +1,41 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class BusinessAsUsualDetector extends AntiPatternDetector {
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+
+        int numberOfIterations = 0;
+        int numberOfWikipageWithRetr = 0;
+        int numberOfRestrospectiveActivities = 0;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/business_as_usual.sql", databaseConnection);
+            if (rs != null) {
+                while (rs.next()) {
+                    numberOfIterations = rs.getInt("numberOfIterations");
+                    numberOfWikipageWithRetr = rs.getInt("numberOfWikipageWithRetr");
+                    numberOfRestrospectiveActivities = rs.getInt("numberOfRestrospectiveActivities");
+                    System.out.println("Project Id: " + analyzedProject.getId());
+                    System.out.println("numberOfWikipageWithRetr:" + numberOfWikipageWithRetr);
+                    System.out.println("numberOfRestrospectiveActivities:" + numberOfRestrospectiveActivities);
+
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        if((numberOfWikipageWithRetr > 0) && (numberOfRestrospectiveActivities > 0)){
+            return false;
+        } else {
+            return true;
+        }
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/IndifferentSpecialistDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/IndifferentSpecialistDetector.java
new file mode 100644
index 0000000..65d9618
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/IndifferentSpecialistDetector.java
@@ -0,0 +1,12 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+public class IndifferentSpecialistDetector extends AntiPatternDetector {
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+        return false;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetector.java
new file mode 100644
index 0000000..6f0bd5d
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/LongOrNonExistentFeedbackLoopsDetector.java
@@ -0,0 +1,51 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+public class LongOrNonExistentFeedbackLoopsDetector extends AntiPatternDetector {
+
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+        /*
+
+        int counter = 0;
+        long daysTolerance = 3;
+        boolean isFirstIteration = true;
+        int numberOfIterations = 0;
+        double averageLengthOfIteration = 0;
+        Date firstIterationDueDate = null;
+        Date secondIterationDueDate = null;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/long_or_non_existent_feedback_loops.sql", databaseConnection);
+            if (rs != null) {
+
+
+                while (rs.next()) {
+                    if (isFirstIteration) {
+                        numberOfIterations = rs.getInt("numberOfIterations");
+                        averageLengthOfIteration = rs.getDouble("averageIterationLength");
+                        firstIterationDueDate = rs.getDate("dueDate");
+                        isFirstIteration = false;
+                        continue;
+                    }
+
+                    secondIterationDueDate = rs.getDate("dueDate");
+                    long numberOfDatesBetween = Utils.daysBetween(firstIterationDueDate, secondIterationDueDate);
+                    firstIterationDueDate = secondIterationDueDate;
+                    if (Math.abs(numberOfDatesBetween - averageLengthOfIteration) <= daysTolerance) {
+                        counter++;
+                    }
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+
+        return counter != numberOfIterations;*/
+        return false;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetector.java
new file mode 100644
index 0000000..744e522
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/RoadToNowhereDetector.java
@@ -0,0 +1,32 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class RoadToNowhereDetector extends AntiPatternDetector {
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+
+        int numberOfIssuesForProjectPlan = 0;
+        int numberOfWikiPagesForProjectPlan = 0;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/road_to_nowhere.sql", databaseConnection);
+            if (rs != null) {
+                while (rs.next()) {
+                    numberOfIssuesForProjectPlan = rs.getInt("numberOfIssuesForProjectPlan");
+                    numberOfWikiPagesForProjectPlan = rs.getInt("numberOfWikiPagesForProjectPlan");
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return numberOfIssuesForProjectPlan <= 0 && numberOfWikiPagesForProjectPlan <= 0;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetector.java
new file mode 100644
index 0000000..3f8f37b
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/SpecifyNothingDetector.java
@@ -0,0 +1,44 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class SpecifyNothingDetector extends AntiPatternDetector {
+
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+
+        /* Settings */
+        int minimumNumberOfWikiPages = 1;
+        int minimumNumberOfActivities = 1;
+        double minimumAverageLengthOfIssueDescription = 200;
+
+        /* Init values */
+        int numberOfWikiPages = 0;
+        int numberOfActivitiesForSpecification = 0;
+        double averageLengthOfIssueDescription = 0;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/specify_nothing.sql", databaseConnection);
+            if (rs != null) {
+                while (rs.next()) {
+                    numberOfWikiPages = rs.getInt("numberOfWikiPages");
+                    numberOfActivitiesForSpecification = rs.getInt("numberOfActivitiesForSpecification");
+                    averageLengthOfIssueDescription = rs.getDouble("averageLengthOfIssueDescription");
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+
+        return numberOfWikiPages < minimumNumberOfWikiPages
+                && numberOfActivitiesForSpecification < minimumNumberOfActivities
+                && !(averageLengthOfIssueDescription >= minimumAverageLengthOfIssueDescription);
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorDetector.java
new file mode 100644
index 0000000..d4e7d15
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorDetector.java
@@ -0,0 +1,35 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class TooLongSprintDetectorDetector extends AntiPatternDetector {
+
+
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+
+        int counter = 0;
+        int maximumNumberOfTooLongIterations = 2;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/too_long_sprint.sql", databaseConnection);
+            if (rs != null) {
+                while (rs.next()) {
+                    boolean isTooLongSprint = rs.getBoolean("isTooLongSprint");
+                    if(isTooLongSprint) {
+                        counter++;
+                    }
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return counter >= maximumNumberOfTooLongIterations;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetector.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetector.java
new file mode 100644
index 0000000..308d37a
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetector.java
@@ -0,0 +1,49 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors;
+
+
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.DatabaseConnection;
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class VaryingSprintLengthDetector extends AntiPatternDetector {
+    @Override
+    public boolean analyze(Project analyzedProject, DatabaseConnection databaseConnection) {
+
+        // Settings
+        // Maximum difference between two iterations
+        int maximumDaysDifference = 5;
+        // How many times the length of the iteration can change
+        int maximumIterationChange = 2;
+
+        int counter = 0;
+
+        try {
+            ResultSet rs = super.executeQuery(analyzedProject, "./queries/varying_sprint_length.sql", databaseConnection);
+            if (rs != null) {
+                int firstIterationLength = Integer.MIN_VALUE;
+                int secondIterationLength;
+                while (rs.next()) {
+                    int iterationLength = rs.getInt("iterationLength");
+                    if (firstIterationLength == Integer.MIN_VALUE) {
+                        firstIterationLength = iterationLength;
+                        continue;
+                    } else {
+                        secondIterationLength = iterationLength;
+                    }
+
+                    if (Math.abs(firstIterationLength - secondIterationLength) >= maximumDaysDifference) {
+                        counter = counter + 1;
+                    }
+                    firstIterationLength = secondIterationLength;
+                }
+            }
+
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+        return counter >= maximumIterationChange;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/AntiPattern.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/AntiPattern.java
new file mode 100644
index 0000000..42513b6
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/AntiPattern.java
@@ -0,0 +1,58 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.model;
+
+public class AntiPattern {
+
+    private Long id;
+    private String printName;
+    private String name;
+    private String description;
+
+    public AntiPattern(Long id, String printName, String name, String description) {
+        this.id = id;
+        this.printName = printName;
+        this.name = name;
+        this.description = description;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getPrintName() {
+        return printName;
+    }
+
+    public void setPrintName(String printName) {
+        this.printName = printName;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "AntiPattern{" +
+                "id=" + id +
+                ", printName='" + printName + '\'' +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                '}';
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Project.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Project.java
new file mode 100644
index 0000000..38ae6bc
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Project.java
@@ -0,0 +1,57 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Project {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private Long id;
+    private String name;
+    private String description;
+
+    public Project() {
+    }
+
+    public Project(String name, String description) {
+        this.name = name;
+        this.description = description;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @Override
+    public String toString() {
+        return "Project{" +
+                "id=" + id +
+                ", name='" + name + '\'' +
+                ", description='" + description + '\'' +
+                '}';
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Query.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Query.java
new file mode 100644
index 0000000..5110007
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/Query.java
@@ -0,0 +1,29 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.model;
+
+import java.util.List;
+
+public class Query {
+    private List<Project> projects;
+    private List<AntiPattern> antiPatterns;
+
+    public Query(List<Project> projects, List<AntiPattern> antiPatterns) {
+        this.projects = projects;
+        this.antiPatterns = antiPatterns;
+    }
+
+    public List<Project> getProjects() {
+        return projects;
+    }
+
+    public void setProjects(List<Project> projects) {
+        this.projects = projects;
+    }
+
+    public List<AntiPattern> getAntiPatterns() {
+        return antiPatterns;
+    }
+
+    public void setAntiPatterns(List<AntiPattern> antiPatterns) {
+        this.antiPatterns = antiPatterns;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResult.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResult.java
new file mode 100644
index 0000000..0999784
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResult.java
@@ -0,0 +1,32 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.model;
+
+import java.util.List;
+
+public class QueryResult {
+    private Project project;
+    private List<QueryResultItem> queryResultItems;
+
+    public Project getProject() {
+        return project;
+    }
+
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    public List<QueryResultItem> getQueryResultItems() {
+        return queryResultItems;
+    }
+
+    public void setQueryResultItems(List<QueryResultItem> queryResultItems) {
+        this.queryResultItems = queryResultItems;
+    }
+
+    public QueryResult() {
+    }
+
+    public QueryResult(Project project, List<QueryResultItem> queryResultItems) {
+        this.project = project;
+        this.queryResultItems = queryResultItems;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResultItem.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResultItem.java
new file mode 100644
index 0000000..2ee70c8
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/model/QueryResultItem.java
@@ -0,0 +1,30 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.model;
+
+public class QueryResultItem {
+    private AntiPattern antiPattern;
+    private boolean isDetected;
+
+    public QueryResultItem() {
+    }
+
+    public QueryResultItem(AntiPattern antiPattern, boolean isDetected) {
+        this.antiPattern = antiPattern;
+        this.isDetected = isDetected;
+    }
+
+    public AntiPattern getAntiPattern() {
+        return antiPattern;
+    }
+
+    public void setAntiPattern(AntiPattern antiPattern) {
+        this.antiPattern = antiPattern;
+    }
+
+    public boolean isDetected() {
+        return isDetected;
+    }
+
+    public void setDetected(boolean detected) {
+        isDetected = detected;
+    }
+}
diff --git a/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/ProjectRepository.java b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/ProjectRepository.java
new file mode 100644
index 0000000..56c19fb
--- /dev/null
+++ b/src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/repository/ProjectRepository.java
@@ -0,0 +1,7 @@
+package cz.zcu.fav.kiv.antipatterndetectionapp.repository;
+
+import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
+import org.springframework.data.repository.CrudRepository;
+
+public interface ProjectRepository extends CrudRepository<Project, Long> {
+}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8b13789..2aa0be3 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1 +1,3 @@
-
+spring.datasource.url=jdbc:mysql://localhost:3306/ppicha
+spring.datasource.username=root
+spring.datasource.password=
diff --git a/src/main/resources/queries/business_as_usual.sql b/src/main/resources/queries/business_as_usual.sql
new file mode 100644
index 0000000..1039741
--- /dev/null
+++ b/src/main/resources/queries/business_as_usual.sql
@@ -0,0 +1,31 @@
+/*
+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 global variables */
+set @projectId = ?;
+/* Retrospective substring */
+set @restrospectiveSubstring = '%retr%';
+/* Number of developers in project */
+set @numberOfPeople =  (select count(DISTINCT assigneeId) from workunitview where projectId = @projectId and assigneeName != 'unknown');
+/* Number of iterations for given project */
+set @numberOfIterations = (select COUNT(*) from iteration where superProjectId = @projectId);
+/* Number of wikipages with substring retr */
+set @numberOfWikipageWithRetr = (select count(*) from artifactview where projectId = @projectId AND artifactClass like 'WIKIPAGE' AND (name like @restrospectiveSubstring OR description like @restrospectiveSubstring));
+/* Number of issues with retr root ends same day like iteration and all members of team are logging  time on this issue */
+set @numberOfRestrospectiveActivities = (select COUNT(distinct activityEndDate) from (select workunitview.id, workunitview.activityEndDate from workunitview INNER JOIN fieldchangeview on workunitview.id = fieldchangeview.itemId where workunitview.projectId = @projectId AND fieldchangeview.changeName LIKE 'LOGTIME' AND (abs(datediff(workunitview.activityEndDate, workunitview.iterationEndDate) = 0)) AND (workunitview.name like @restrospectiveSubstring OR workunitview.description LIKE @restrospectiveSubstring) GROUP by workunitview.id HAVING COUNT(DISTINCT fieldchangeview.authorId) = @numberOfPeople) as test);
+/* Show all statistics */
+select @projectId as `projectId`, @numberOfPeople as `numberOfPeople`, @numberOfIterations as `numberOfIterations`, @numberOfWikipageWithRetr as `numberOfWikipageWithRetr`, @numberOfRestrospectiveActivities as `numberOfRestrospectiveActivities`;
diff --git a/src/main/resources/queries/long_or_non_existent_feedback_loops.sql b/src/main/resources/queries/long_or_non_existent_feedback_loops.sql
new file mode 100644
index 0000000..388ea4d
--- /dev/null
+++ b/src/main/resources/queries/long_or_non_existent_feedback_loops.sql
@@ -0,0 +1,39 @@
+/*
+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.
+
+           POZNÁMKY:
+                     1) naléz aktivity, které mohou odpovídat schůzce se zákazníkem
+                     2) nalezené aktivity zgrupovat podle dueDate
+                     3) následně udělat časový rozdíl těchto aktivit (Python)
+                     4) a porovnat s průměrnou délkou iterace
+
+
+
+
+*/
+
+/* Init project id */
+set @projectId = ?;
+/* Number of iterations for project */
+set @numberOfIterations = (SELECT count(id) FROM `iteration` WHERE superProjectId = @projectId);
+/* Average iteration length */
+set @averageIterationLength = (SELECT AVG(abs(datediff(iteration.endDate, iteration.startDate))) FROM `iteration` WHERE superProjectId = @projectId);
+/* Look for issues that should indicate customer demo or customer feedback */
+select workunitview.duedate as `dueDate`, @numberOfIterations as `numberOfIterations`, @averageIterationLength as `averageIterationLength` FROM `workunitview` where workunitview.projectId = @projectId and (workunitview.name like '%demo%' or workunitview.description like '%demo%' or workunitview.name like '%zákazník%' or workunitview.description like '%zákazník%' or workunitview.name like '%cust%' or workunitview.description like '%cust%' or workunitview.name like '%zadavatel%' or workunitview.description like '%zadavatel%' or workunitview.name like '%předvedení%' or workunitview.description like '%předvedení%' or workunitview.name like '%presentation%' or workunitview.description like '%presentation%') group by workunitview.duedate;
+
+
+
diff --git a/src/main/resources/queries/road_to_nowhere.sql b/src/main/resources/queries/road_to_nowhere.sql
new file mode 100644
index 0000000..f318e26
--- /dev/null
+++ b/src/main/resources/queries/road_to_nowhere.sql
@@ -0,0 +1,20 @@
+/*
+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 (workunitview.name like '%plán%projektu%' or workunitview.description like '%plán%projektu%' or workunitview.name like '%project%plan%' or workunitview.description like '%project%plan%' or workunitview.name like '%plan%project%' or workunitview.description like '%plan%project%' or workunitview.name like '%proje%plán%' or workunitview.description like '%proje%plán%') AND (iterationStartDate = @firstIterationStartDate OR iterationStartDate = @secondIterationStartDate));
+set @numberOfWikiPagesForProjectPlan = (SELECT count(*) from artifactview where projectId = @projectId AND artifactClass like 'WIKIPAGE' AND (artifactview.name like '%plán%projektu%' or artifactview.description like '%plán%projektu%' or artifactview.name like '%project%plan%' or artifactview.description like '%project%plan%' or artifactview.name like '%plan%project%' or artifactview.description like '%plan%project%' or artifactview.name like '%proje%plán%' or artifactview.description like '%proje%plán%'));
+select @projectId as `projectId`, @numberOfIssuesForProjectPlan as `numberOfIssuesForProjectPlan`, @numberOfWikiPagesForProjectPlan as `numberOfWikiPagesForProjectPlan`;
diff --git a/src/main/resources/queries/specify_nothing.sql b/src/main/resources/queries/specify_nothing.sql
new file mode 100644
index 0000000..3077b6a
--- /dev/null
+++ b/src/main/resources/queries/specify_nothing.sql
@@ -0,0 +1,22 @@
+/*
+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 (name like '%DSP%' or name like '%specifikace%' or name like '%specification%' or description like '%DSP%' or description like '%specifikace%' or description like '%specification%'));
+/* Find activities for creating DSP or project specification */
+set @numberOfActivitiesForSpecification = (SELECT count(id) from workunitview where projectId = @projectId and (name like '%DSP%' or name like '%specifikace%' or name like '%specification%' or description like '%DSP%' or description like '%specifikace%' or description like '%specification%'));
+/* 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/resources/queries/too_long_sprint.sql b/src/main/resources/queries/too_long_sprint.sql
new file mode 100644
index 0000000..2a5d6c0
--- /dev/null
+++ b/src/main/resources/queries/too_long_sprint.sql
@@ -0,0 +1,26 @@
+/*
+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 = ?;
+/* Maximum iteration length in days */
+set @maxSprintLength = 20;
+/* Exclude first and last iteration? */
+set @excludeFirstAndLastIteration = true;
+/* Id of first iteration */
+set @idOfFirstIteration = (select id from iteration where iteration.superProjectId = @projectId order by startDate limit 1);
+/* Id of last iteration */
+set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by startDate desc limit 1);
+/* Select all too long iterations */
+select datediff(iteration.endDate, iteration.startDate) as `iterationLength`, if(datediff(iteration.endDate, iteration.startDate) > @maxSprintLength, true, false) as `isTooLongSprint`, iteration.startDate as `iterationStartDate` 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.startDate;
diff --git a/src/main/resources/queries/varying_sprint_length.sql b/src/main/resources/queries/varying_sprint_length.sql
new file mode 100644
index 0000000..e1a81cb
--- /dev/null
+++ b/src/main/resources/queries/varying_sprint_length.sql
@@ -0,0 +1,28 @@
+/*
+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 startDate limit 1);
+/* Id of last iteration */
+set @idOfLastIteration = (select id from iteration where iteration.superProjectId = @projectId order by startDate 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.startDate;
+
diff --git a/src/main/resources/templates/about.html b/src/main/resources/templates/about.html
new file mode 100644
index 0000000..40afe44
--- /dev/null
+++ b/src/main/resources/templates/about.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+    <title>Anti Pattern Detector - About</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+
+</head>
+<body>
+<!-- Navigation bar imported -->
+<div th:replace="fragments/navbar :: navBar"></div>
+<!-- ./Navigation bar imported -->
+<div class="container">
+    <h1>About</h1>
+    <p>
+        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean placerat. Vivamus luctus egestas leo. Aliquam ante. Praesent in mauris eu tortor porttitor accumsan. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Fusce consectetuer risus a nunc. Proin in tellus sit amet nibh dignissim sagittis. Fusce wisi. Maecenas lorem. Integer malesuada.
+
+        Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Integer imperdiet lectus quis justo. Aenean vel massa quis mauris vehicula lacinia. Integer in sapien. Maecenas fermentum, sem in pharetra pellentesque, velit turpis volutpat ante, in pharetra metus odio a lectus. Phasellus enim erat, vestibulum vel, aliquam a, posuere eu, velit. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Nulla non lectus sed nisl molestie malesuada. Nulla est. Cras elementum. Quisque tincidunt scelerisque libero. Nullam rhoncus aliquam metus. Vivamus luctus egestas leo. Aliquam erat volutpat. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Nullam dapibus fermentum ipsum. Etiam quis quam.
+
+        Nullam feugiat, turpis at pulvinar vulputate, erat libero tristique tellus, nec bibendum odio risus sit amet ante. Phasellus enim erat, vestibulum vel, aliquam a, posuere eu, velit. Quisque tincidunt scelerisque libero. Mauris dolor felis, sagittis at, luctus sed, aliquam non, tellus. Nullam sit amet magna in magna gravida vehicula. Phasellus faucibus molestie nisl. In enim a arcu imperdiet malesuada. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam lectus justo, vulputate eget mollis sed, tempor sed magna. Praesent id justo in neque elementum ultrices. In enim a arcu imperdiet malesuada. Aliquam ornare wisi eu metus. Morbi imperdiet, mauris ac auctor dictum, nisl ligula egestas nulla, et sollicitudin sem purus in lacus. Vestibulum erat nulla, ullamcorper nec, rutrum non, nonummy ac, erat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce tellus odio, dapibus id fermentum quis, suscipit id erat. Mauris metus. Nulla non lectus sed nisl molestie malesuada. Et harum quidem rerum facilis est et expedita distinctio. Ut tempus purus at lorem.
+
+        Phasellus enim erat, vestibulum vel, aliquam a, posuere eu, velit. Pellentesque sapien. Morbi leo mi, nonummy eget tristique non, rhoncus non leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Duis ante orci, molestie vitae vehicula venenatis, tincidunt ac pede. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum fermentum tortor id mi. Nullam sit amet magna in magna gravida vehicula. Aliquam id dolor. Donec quis nibh at felis congue commodo.
+
+        Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. Aenean fermentum risus id tortor. Etiam sapien elit, consequat eget, tristique non, venenatis quis, ante. Aenean id metus id velit ullamcorper pulvinar. Nunc auctor. Maecenas aliquet accumsan leo. Sed convallis magna eu sem. Mauris tincidunt sem sed arcu. Fusce consectetuer risus a nunc. Nulla turpis magna, cursus sit amet, suscipit a, interdum id, felis. Fusce tellus.
+    </p>
+
+</body>
+</html>
diff --git a/src/main/resources/templates/anti-pattern.html b/src/main/resources/templates/anti-pattern.html
new file mode 100644
index 0000000..48f773d
--- /dev/null
+++ b/src/main/resources/templates/anti-pattern.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <title>Anti Pattern Detector - Anti Pattern details</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+
+    <style>
+        .card {
+            margin-top: 40px;
+            margin-left: 5%;
+            margin-right: 5%;
+
+        }
+    </style>
+</head>
+<body>
+<!-- Navigation bar imported -->
+<div th:replace="fragments/navbar :: navBar"></div>
+<!-- ./Navigation bar imported -->
+<div class="card">
+    <h5 class="card-header">Anti Pattern</h5>
+    <div class="card-body">
+        <div class="form-group">
+            <label for="projectId">Anti Pattern Id:</label>
+            <input disabled type="text" class="form-control" id="projectId" th:value="${antiPattern.id}">
+        </div>
+        <div class="form-group">
+            <label for="projectId">Project id:</label>
+            <input disabled type="text" class="form-control" id="projectName" th:value="${antiPattern.printName}">
+        </div>
+        <div class="form-group">
+            <label for="projectId">Project id:</label>
+            <textarea disabled class="form-control" id="projectDescription" rows="5" th:text="${antiPattern.description}"></textarea>
+        </div>
+    </div>
+</div>
+
+</body>
+</html>
diff --git a/src/main/resources/templates/fragments/navbar.html b/src/main/resources/templates/fragments/navbar.html
new file mode 100644
index 0000000..8d44bdc
--- /dev/null
+++ b/src/main/resources/templates/fragments/navbar.html
@@ -0,0 +1,17 @@
+<div th:fragment="navBar" xmlns:th="http://www.w3.org/1999/xhtml">
+    <nav class="navbar navbar-expand-lg navbar-light bg-light">
+        <a class="navbar-brand">Anti Pattern Detector</a>
+        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
+            <span class="navbar-toggler-icon"></span>
+        </button>
+        <div class="collapse navbar-collapse" id="navbarSupportedContent">
+            <ul class="navbar-nav mr-auto">
+                <li class="nav-item active">
+                    <a class="nav-link" th:href="@{/}">Home</a>
+                </li>
+                <li class="nav-item active">
+                    <a class="nav-link" th:href="@{/about}">About</a>
+                </li>
+        </div>
+    </nav>
+</div>
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
new file mode 100644
index 0000000..ce0a2e5
--- /dev/null
+++ b/src/main/resources/templates/index.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+    <title>Anti Pattern Detector</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+
+    <style>
+        tbody tr:hover {
+            background-color: #F8F9FA;
+        }
+
+        .analyze-button-container {
+            margin-left: 40%;
+            margin-right: 40%;
+            margin-bottom: 40px;
+        }
+    </style>
+
+    <script>
+        function checkAllProjects(checkBox) {
+            var projects = document.querySelectorAll('*[id^="project_"]');
+            var i;
+            for (i = 0; i < projects.length; i++) {
+                projects[i].checked = !!checkBox.checked;
+            }
+        }
+
+        function checkAllAntiPatterns(checkBox) {
+            var antiPatterns = document.querySelectorAll('*[id^="anti-pattern"]');
+            var i;
+            for (i = 0; i < antiPatterns.length; i++) {
+                antiPatterns[i].checked = !!checkBox.checked;
+            }
+        }
+    </script>
+</head>
+<body>
+<!-- Navigation bar imported -->
+<div th:replace="fragments/navbar :: navBar"></div>
+<!-- ./Navigation bar imported -->
+<form action="#" th:action="@{/analyze}" th:object="${query}" method="post">
+    <div class="container">
+        <div class="row">
+            <div class="col">
+                <h1>Projects</h1>
+            </div>
+            <div class="col">
+                <h1>Anti Patterns</h1><br>
+            </div>
+        </div>
+
+        <div class="row">
+            <div class="col">
+                <table class="table">
+                    <thead>
+                    <tr>
+                        <th scope="col">#</th>
+                        <th scope="col">Project Name</th>
+                        <th scope="col">Detail</th>
+                        <th scope="col">Analyze?</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="project : ${query.projects}">
+                        <td th:text="${project.id}"></td>
+                        <td th:text="${project.name}"></td>
+                        <td><a th:href="@{/projects/} + ${project.id}">Show</a></td>
+                        <td style="text-align: center">
+                            <input checked type="checkbox" class="form-check-input" name="selectedProjects" th:value="${project.id}" th:id="@{project_} + ${project.id}">
+                        </td>
+                    </tr>
+                    <tr>
+                        <td></td>
+                        <td></td>
+                        <td></td>
+                        <td>
+                            <input checked type="checkbox" class="form-check-input" id="select_all_projects"
+                                   onclick="checkAllProjects(this)">
+                            <label class="form-check-label" for="select_all_projects">Select All</label>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+            <div class="col">
+                <table class="table">
+                    <thead>
+                    <tr>
+                        <th scope="col">#</th>
+                        <th scope="col">Anti Pattern</th>
+                        <th scope="col">Detail</th>
+                        <th scope="col">Analyze?</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <tr th:each="antiPattern : ${query.antiPatterns}">
+                        <td th:text="${antiPattern.id}"></td>
+                        <td th:text="${antiPattern.printName}"></td>
+                        <td><a th:href="@{/anti-patterns/} + ${antiPattern.id}">Show</a></td>
+                        <td style="text-align: center">
+                            <input checked type="checkbox" class="form-check-input" name="selectedAntiPatterns" th:value="${antiPattern.id}" th:id="@{anti-pattern_} + ${antiPattern.id}">
+                        </td>
+                    </tr>
+                    <tr>
+                        <td></td>
+                        <td></td>
+                        <td></td>
+                        <td>
+                            <input checked type="checkbox" class="form-check-input" id="select_all_anti_patterns"
+                                   onclick="checkAllAntiPatterns(this)">
+                            <label class="form-check-label" for="select_all_anti_patterns">Select All</label>
+                        </td>
+                    </tr>
+                    </tbody>
+                </table>
+            </div>
+        </div>
+
+    </div>
+    <div class="container">
+        <div th:if="${errorMessage}"  th:text="${errorMessage}" class="alert alert-danger" role="alert">
+        </div>
+    </div>
+    <div class="analyze-button-container">
+        <button type="submit" class="btn btn-primary btn-lg btn-block">Analyze</button>
+    </div>
+</form>
+</body>
+</html>
diff --git a/src/main/resources/templates/project.html b/src/main/resources/templates/project.html
new file mode 100644
index 0000000..1526105
--- /dev/null
+++ b/src/main/resources/templates/project.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <title>Anti Pattern Detector - Project details</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+
+    <style>
+        .card {
+            margin-top: 40px;
+            margin-left: 5%;
+            margin-right: 5%;
+
+        }
+    </style>
+</head>
+<body>
+<!-- Navigation bar imported -->
+<div th:replace="fragments/navbar :: navBar"></div>
+<!-- ./Navigation bar imported -->
+<div class="card">
+    <h5 class="card-header">Project</h5>
+    <div class="card-body">
+        <div class="form-group">
+            <label for="projectId">Project id:</label>
+            <input disabled type="text" class="form-control" id="projectId" th:value="${project.id}">
+        </div>
+        <div class="form-group">
+            <label for="projectId">Project id:</label>
+            <input disabled type="text" class="form-control" id="projectName" th:value="${project.name}">
+        </div>
+        <div class="form-group">
+            <label for="projectId">Project id:</label>
+            <textarea disabled class="form-control" id="projectDescription" rows="5" th:text="${project.description}"></textarea>
+        </div>
+    </div>
+</div>
+
+</body>
+</html>
diff --git a/src/main/resources/templates/result.html b/src/main/resources/templates/result.html
new file mode 100644
index 0000000..9f3ae7e
--- /dev/null
+++ b/src/main/resources/templates/result.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+    <title>Anti Pattern Detector - Results</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
+
+    <style>
+        .not-found-bg {
+            background-color: #D4EDDA;
+        }
+
+        .found-bg {
+            background-color: #F8D7DA;
+        }
+
+        .icon-style {
+            border-radius: 30px;
+        }
+    </style>
+
+</head>
+<body>
+<!-- Navigation bar imported -->
+<div th:replace="fragments/navbar :: navBar"></div>
+<!-- ./Navigation bar imported -->
+<div class="container">
+    <h1>Results</h1>
+    <table class="table table-bordered table-hover">
+        <thead>
+        <tr>
+            <th scope="col">#</th>
+            <th scope="col">Project Name</th>
+            <th scope="col" th:text="${antiPattern.getAntiPattern().printName}"
+                th:each="antiPattern: ${queryResults.get(0).getQueryResultItems()}"></th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr th:each="queryResult : ${queryResults}">
+            <td th:text="${queryResult.getProject().id}"></td>
+            <td th:text="${queryResult.getProject().name}"></td>
+            <td class="align-middle" th:each="resultItems: ${queryResult.getQueryResultItems()}">
+
+                <div th:if="${resultItems.isDetected()}">
+                    <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"
+                         fill="currentColor" class="bi bi-check my-center found-bg icon-style" viewBox="0 0 16 16">
+                        <path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z"/>
+                    </svg>
+                </div>
+                <div th:unless="${resultItems.isDetected()}">
+                    <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" class="bi bi-x not-found-bg icon-style" viewBox="0 0 16 16">
+                        <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
+                    </svg>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+    </table>
+    <h6>Legend:</h6>
+    <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"
+         fill="currentColor" class="bi bi-check my-center found-bg icon-style" viewBox="0 0 16 16">
+        <path d="M10.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.267.267 0 0 1 .02-.022z"/>
+    </svg>
+    - Anti-pattern detected
+    <br>
+    <svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="currentColor" class="bi bi-x not-found-bg icon-style" viewBox="0 0 16 16">
+        <path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
+    </svg>
+    - Anti-pattern NOT detected
+    <div class="analyze-button-container" style="margin-top: 10px">
+        <form method="get" action="#" th:action="@{/}">
+            <button type="submit" class="btn btn-primary btn-lg btn-block">Back Home</button>
+        </form>
+    </div>
+</div>
+
+</body>
+</html>
