Revize 46144508
Přidáno uživatelem Jiri Trefil před téměř 2 roky(ů)
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/AntiPatternDto.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public class AntiPatternDto { |
|
6 |
|
|
7 |
private String antiPattern; |
|
8 |
private List<ThresholdDto> thresholds; |
|
9 |
|
|
10 |
public String getAntiPattern() { |
|
11 |
return antiPattern; |
|
12 |
} |
|
13 |
|
|
14 |
public void setAntiPattern(String antiPattern) { |
|
15 |
this.antiPattern = antiPattern; |
|
16 |
} |
|
17 |
|
|
18 |
public List<ThresholdDto> getThresholds() { |
|
19 |
return thresholds; |
|
20 |
} |
|
21 |
|
|
22 |
public void setThresholds(List<ThresholdDto> thresholds) { |
|
23 |
this.thresholds = thresholds; |
|
24 |
} |
|
25 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/ConfigurationDto.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public class ConfigurationDto { |
|
6 |
private List<AntiPatternDto> configuration; |
|
7 |
|
|
8 |
public List<AntiPatternDto> getConfiguration() { |
|
9 |
return configuration; |
|
10 |
} |
|
11 |
|
|
12 |
public void setConfiguration(List<AntiPatternDto> configuration) { |
|
13 |
this.configuration = configuration; |
|
14 |
} |
|
15 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/ThresholdDto.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
public class ThresholdDto { |
|
4 |
|
|
5 |
private String thresholdName; |
|
6 |
private String value; |
|
7 |
|
|
8 |
public String getThresholdName() { |
|
9 |
return thresholdName; |
|
10 |
} |
|
11 |
|
|
12 |
public void setThresholdName(String thresholdName) { |
|
13 |
this.thresholdName = thresholdName; |
|
14 |
} |
|
15 |
|
|
16 |
public String getValue() { |
|
17 |
return value; |
|
18 |
} |
|
19 |
|
|
20 |
public void setValue(String value) { |
|
21 |
this.value = value; |
|
22 |
} |
|
23 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/model/UserDetectionDto.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.model; |
|
2 |
|
|
3 |
public class UserDetectionDto { |
|
4 |
|
|
5 |
private int configurationId; |
|
6 |
private String userName; |
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
private String[] selectedProjects; |
|
11 |
private String[] selectedAntipatterns; |
|
12 |
|
|
13 |
public UserDetectionDto(String userName,int configurationId, String[] selectedProjects, String[] selectedAntipatterns) { |
|
14 |
this.configurationId = configurationId; |
|
15 |
this.selectedProjects = selectedProjects; |
|
16 |
this.selectedAntipatterns = selectedAntipatterns; |
|
17 |
this.userName = userName; |
|
18 |
} |
|
19 |
public String getUserName(){ |
|
20 |
return this.userName; |
|
21 |
} |
|
22 |
public UserDetectionDto() { |
|
23 |
} |
|
24 |
|
|
25 |
public void setConfigurationId(int configurationId) { |
|
26 |
this.configurationId = configurationId; |
|
27 |
} |
|
28 |
|
|
29 |
public void setSelectedProjects(String[] selectedProjects) { |
|
30 |
this.selectedProjects = selectedProjects; |
|
31 |
} |
|
32 |
|
|
33 |
public void setSelectedAntipatterns(String[] selectedAntipatterns) { |
|
34 |
this.selectedAntipatterns = selectedAntipatterns; |
|
35 |
} |
|
36 |
public void setUserName(String userName) { |
|
37 |
this.userName = userName; |
|
38 |
} |
|
39 |
|
|
40 |
public int getConfigurationId() { |
|
41 |
return configurationId; |
|
42 |
} |
|
43 |
|
|
44 |
public String[] getSelectedProjects() { |
|
45 |
return selectedProjects; |
|
46 |
} |
|
47 |
|
|
48 |
public String[] getSelectedAntipatterns() { |
|
49 |
return selectedAntipatterns; |
|
50 |
} |
|
51 |
|
|
52 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionService.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service; |
|
2 |
|
|
3 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Query; |
|
4 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResult; |
|
5 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserDetectionDto; |
|
6 |
import org.springframework.stereotype.Service; |
|
7 |
|
|
8 |
import java.util.List; |
|
9 |
|
|
10 |
public interface DetectionService { |
|
11 |
Query getAllProjectsAndAntipatterns(); |
|
12 |
List<QueryResult> analyze(UserDetectionDto detectionRequest); |
|
13 |
|
|
14 |
} |
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/service/DetectionServiceImpl.java | ||
---|---|---|
1 |
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.service; |
|
2 |
|
|
3 |
import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.AntiPatternManager; |
|
4 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Query; |
|
5 |
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResult; |
|
6 |
import cz.zcu.fav.kiv.antipatterndetectionapp.service.AntiPatternService; |
|
7 |
import cz.zcu.fav.kiv.antipatterndetectionapp.service.ConfigurationService; |
|
8 |
import cz.zcu.fav.kiv.antipatterndetectionapp.service.ProjectService; |
|
9 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration; |
|
10 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User; |
|
11 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.UserDetectionDto; |
|
12 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.JSONBuilder; |
|
13 |
import org.springframework.beans.factory.annotation.Autowired; |
|
14 |
import org.springframework.stereotype.Service; |
|
15 |
|
|
16 |
import java.util.List; |
|
17 |
import java.util.Map; |
|
18 |
|
|
19 |
@Service |
|
20 |
public class DetectionServiceImpl implements DetectionService{ |
|
21 |
@Autowired |
|
22 |
ConfigService configService; |
|
23 |
|
|
24 |
@Autowired |
|
25 |
private ProjectService projectService; |
|
26 |
|
|
27 |
@Autowired |
|
28 |
private AntiPatternService antiPatternService; |
|
29 |
|
|
30 |
@Autowired |
|
31 |
private AntiPatternManager antiPatternManager; |
|
32 |
|
|
33 |
@Autowired |
|
34 |
private UserService userService; |
|
35 |
|
|
36 |
@Autowired |
|
37 |
private ConfigurationService configurationService; |
|
38 |
|
|
39 |
@Override |
|
40 |
public Query getAllProjectsAndAntipatterns() { |
|
41 |
Query q = new Query(projectService.getAllProjects(), antiPatternService.antiPatternsToModel(antiPatternService.getAllAntiPatterns())); |
|
42 |
return q; |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
public List<QueryResult> analyze(UserDetectionDto detectionRequest) { |
|
47 |
//User user = userService.getUserByName(detectionRequest.getUserName()); |
|
48 |
int configurationId = detectionRequest.getConfigurationId(); |
|
49 |
//String currentConfigurationName = this.configService.getConfigurationName(user.getId(), configurationId); |
|
50 |
Configuration cfg = this.configService.getConfigurationById(configurationId); |
|
51 |
|
|
52 |
//namapovat cfg do jsonu |
|
53 |
Map<String, Map<String,String>> currentConfiguration = JSONBuilder.createMapFromString(cfg.getConfig()); |
|
54 |
|
|
55 |
String[] selectedProjects = detectionRequest.getSelectedProjects(); |
|
56 |
String[] selectedAntiPatterns = detectionRequest.getSelectedAntipatterns(); |
|
57 |
List<QueryResult> results = antiPatternManager.analyze(selectedProjects, selectedAntiPatterns, currentConfiguration); |
|
58 |
return results; |
|
59 |
} |
|
60 |
} |
Také k dispozici: Unified diff
#10621 posílání výsledků detekce zpět na klienta