Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 8be7e897

Přidáno uživatelem stepanekp před asi 3 roky(ů)

#14 Configuration service and config dropdown added

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/AppController.java
6 6
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Query;
7 7
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResult;
8 8
import cz.zcu.fav.kiv.antipatterndetectionapp.service.AntiPatternService;
9
import cz.zcu.fav.kiv.antipatterndetectionapp.service.ConfigurationService;
9 10
import cz.zcu.fav.kiv.antipatterndetectionapp.service.ProjectService;
10 11
import cz.zcu.fav.kiv.antipatterndetectionapp.service.UserAccountService;
11 12
import org.slf4j.Logger;
......
28 29
import java.nio.file.Files;
29 30
import java.time.LocalTime;
30 31
import java.time.format.DateTimeFormatter;
32
import java.util.ArrayList;
33
import java.util.HashMap;
31 34
import java.util.List;
35
import java.util.Map;
32 36

  
33 37
/**
34 38
 * This class contains all endpoints of the web application.
......
50 54
    @Autowired
51 55
    private UserAccountService userAccountService;
52 56

  
57
    @Autowired
58
    private ConfigurationService configurationService;
59

  
53 60
    /**
54 61
     *  This method is called by the GET method and initializes
55 62
     *  the main page of the application (index). Loads all projects
......
390 397
        return "redirect:/";
391 398
    }
392 399

  
400
    @ModelAttribute("configList")
401
    public List<String> configurationsGetList(HttpSession session){
402
        List<String> configList;
403

  
404
        if(session.getAttribute("user") != null)
405
            configList = configurationService.getAllConfigurationNames();
406
        else
407
            configList = configurationService.getDefaultConfigurationNames();
408

  
409
        return configList;
410
    }
411

  
393 412

  
394 413
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/service/ConfigurationService.java
1
package cz.zcu.fav.kiv.antipatterndetectionapp.service;
2

  
3
import java.util.List;
4

  
5
public interface ConfigurationService {
6

  
7
    List<String> getAllConfigurationNames();
8

  
9
    List<String> getDefaultConfigurationNames();
10
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/service/ConfigurationServiceImpl.java
1
package cz.zcu.fav.kiv.antipatterndetectionapp.service;
2

  
3
import org.springframework.core.io.FileSystemResource;
4
import org.springframework.stereotype.Service;
5

  
6
import java.io.File;
7
import java.nio.file.Paths;
8
import java.util.ArrayList;
9
import java.util.List;
10

  
11
@Service
12
public class ConfigurationServiceImpl implements ConfigurationService {
13

  
14
    @Override
15
    public List<String> getAllConfigurationNames() {
16
        List<String> configList = new ArrayList<String>();
17
        File folder = new File(String.valueOf(Paths.get(new FileSystemResource("").getFile().getAbsolutePath() + "\\src\\main\\webapp\\configurations")));
18
        for (final File fileEntry : folder.listFiles()) {
19
            configList.add(fileEntry.getName().split("\\.")[0]);
20
        }
21
        return configList;
22
    }
23

  
24
    @Override
25
    public List<String> getDefaultConfigurationNames() {
26
        List<String> configList = new ArrayList<String>();
27
        configList.add("Default");
28
        return configList;
29
    }
30
}
src/main/webapp/WEB-INF/templates/fragments/navbar.html
1
<div th:fragment="navBar" xmlns:th="http://www.w3.org/1999/xhtml">
1
<div th:fragment="navBar" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:form="http://www.w3.org/1999/xhtml">
2 2
    <nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light" id="main-navbar">
3 3
        <a class="navbar-brand">Anti Pattern Detector</a>
4 4
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
......
22 22
                </li>
23 23
                <li class="nav-item active" id="current-configuration-box">
24 24
                    <select class="form-control">
25
                        <option value="1">Default</option>
26
                        <option value="2">test-config-1</option>
27
                        <option value="3">test-config-2</option>
25
                        <option th:each="config : ${configList}" th:value = ${config} th:text = ${config}></option>
28 26
                    </select>
29 27
                </li>
30 28
                <li class="nav-item active">
src/main/webapp/configurations/Default.json
1
{
2
    "name" : "Default",
3
    "default" : "1",
4
    "TooLongSprint": [
5
        {
6
            "thresholdName": "maxIterationLength",
7
            "value": "21"
8
        },
9
        {
10
            "thresholdName": "maxNumberOfTooLongIterations",
11
            "value": "0"
12
        }
13
    ],
14
    "VaryingSprintLength": [
15
        {
16
            "thresholdName": "maxDaysDifference",
17
            "value": "7"
18
        },
19
        {
20
            "thresholdName": "maxIterationChanged",
21
            "value": "1"
22
        }
23
    ],
24
    "BusinessAsUsual": [
25
        {
26
            "thresholdName": "divisionOfIterationsWithRetrospective",
27
            "value": "66.66f"
28
        },
29
        {
30
           "thresholdName": "searchSubstringsWithRetrospective",
31
            "value": "%retr%||%revi%||%week%scrum%"
32
        }
33
    ],
34
    "SpecifyNothing": [
35
        {
36
            "thresholdName": "minNumberOfWikiPagesWithSpecification",
37
            "value": "1"
38
        },
39
        {
40
            "thresholdName": "minNumberOfActivitiesWithSpecification",
41
            "value": "1"
42
        },
43
        {
44
            "thresholdName": "minAvgLengthOfActivityDescription",
45
            "value": "150"
46
        },
47
        {
48
            "thresholdName": "searchSubstringsWithProjectSpecification",
49
            "value": "%dsp%||%specifikace%||%specification%||%vize%proj%||%vize%produ%"
50
        }
51
    ],
52
    "RoadToNowhere": [
53
        {
54
            "thresholdName": "minNumberOfWikiPagesWithProjectPlan",
55
            "value": "1"
56
        },
57
        {
58
            "thresholdName": "minNumberOfActivitiesWithProjectPlan",
59
            "value": "1"
60
        },
61
        {
62
            "thresholdName": "searchSubstringsWithProjectPlan",
63
            "value": "%plán projektu%||%project plan%||%plan project%||%projektový plán%"
64
        }
65
    ],
66
    "LongOrNonExistentFeedbackLoops": [
67
        {
68
            "thresholdName": "divisionOfIterationsWithFeedbackLoop",
69
            "value": "50.00f"
70
        },
71
        {
72
            "thresholdName": "maxGapBetweenFeedbackLoopRate",
73
            "value": "2f"
74
        },
75
        {
76
            "thresholdName": "searchSubstringsWithFeedbackLoop",
77
            "value": "%schůz%zákazník%||%předvedení%zákazník%||%zákazn%demo%||%schůz%zadavat%||%inform%schůz%||%zákazn%||%zadavatel%"
78
        }
79
    ],
80
    "NinetyNinetyRule": [
81
        {
82
            "thresholdName": "maxDivisionRange",
83
            "value": "1.25f"
84
        },
85
        {
86
            "thresholdName": "maxBadDivisionLimit",
87
            "value": "2"
88
        }
89
    ]
90
}
src/main/webapp/resources/js/editor.js
178 178
    let S=window.getSelection().toString();
179 179
    if(S.length == 0)
180 180
        return;
181
    if(window.getSelection().anchorNode.parentNode.nodeName.toLowerCase() ===  'code'){
181
    if(window.getSelection().anchorNode.parentNode.nodeName.toLowerCase() ===  'pre'){
182 182
        document.execCommand('formatBlock', false, 'div');
183 183
        document.execCommand('insertHTML',false, S);
184 184
    }

Také k dispozici: Unified diff