Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1e41f6ff

Přidáno uživatelem Ondřej Váně před asi 4 roky(ů)

Refactor loading query from file

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/AntiPatternDetector.java
4 4
import cz.zcu.fav.kiv.antipatterndetectionapp.model.AntiPattern;
5 5
import cz.zcu.fav.kiv.antipatterndetectionapp.model.Project;
6 6
import cz.zcu.fav.kiv.antipatterndetectionapp.model.QueryResultItem;
7
import cz.zcu.fav.kiv.antipatterndetectionapp.utils.Utils;
7 8

  
8
public interface AntiPatternDetector {
9
import java.util.List;
9 10

  
10
    AntiPattern getAntiPatternModel();
11
public abstract class AntiPatternDetector {
11 12

  
12
    QueryResultItem analyze(Project project, DatabaseConnection databaseConnection);
13
    public abstract AntiPattern getAntiPatternModel();
14

  
15
    public abstract String getAntiPatternSqlFileName();
16

  
17
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection) {
18
        return this.analyze(project, databaseConnection, Utils.loadQueryFromFile(getAntiPatternSqlFileName()));
19
    }
20

  
21
    public abstract QueryResultItem analyze(Project project, DatabaseConnection databaseConnection, List<String> sql);
13 22
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/BusinessAsUsualDetectorImpl.java
7 7
import org.slf4j.Logger;
8 8
import org.slf4j.LoggerFactory;
9 9

  
10
public class BusinessAsUsualDetectorImpl implements AntiPatternDetector {
10
import java.util.List;
11

  
12
public class BusinessAsUsualDetectorImpl extends AntiPatternDetector {
11 13

  
12 14
    private final Logger LOGGER = LoggerFactory.getLogger(BusinessAsUsualDetectorImpl.class);
13 15

  
......
25 27
    }
26 28

  
27 29
    @Override
28
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection) {
29
        return new QueryResultItem(this.antiPattern, true, null);
30
    public String getAntiPatternSqlFileName() {
31
        return this.sqlFileName;
32
    }
33

  
34
    @Override
35
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection, List<String> sql) {
36

  
37
        return new QueryResultItem(this.antiPattern, false, null);
30 38
    }
31 39
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/TooLongSprintDetectorImpl.java
7 7
import org.slf4j.Logger;
8 8
import org.slf4j.LoggerFactory;
9 9

  
10
public class TooLongSprintDetectorImpl implements AntiPatternDetector {
10
import java.util.List;
11

  
12
public class TooLongSprintDetectorImpl extends AntiPatternDetector {
11 13

  
12 14
    private final Logger LOGGER = LoggerFactory.getLogger(TooLongSprintDetectorImpl.class);
13 15

  
......
28 30
    }
29 31

  
30 32
    @Override
31
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection) {
33
    public String getAntiPatternSqlFileName() {
34
        return this.sqlFileName;
35
    }
36

  
37
    @Override
38
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection, List<String> sql) {
32 39
        return new QueryResultItem(this.antiPattern, false, null);
33 40
    }
34 41
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/detecting/detectors/VaryingSprintLengthDetectorImpl.java
7 7
import org.slf4j.Logger;
8 8
import org.slf4j.LoggerFactory;
9 9

  
10
public class VaryingSprintLengthDetectorImpl implements AntiPatternDetector {
10
import java.util.List;
11

  
12
public class VaryingSprintLengthDetectorImpl extends AntiPatternDetector {
11 13

  
12 14
    private final Logger LOGGER = LoggerFactory.getLogger(VaryingSprintLengthDetectorImpl.class);
13 15

  
......
28 30
    }
29 31

  
30 32
    @Override
31
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection) {
33
    public String getAntiPatternSqlFileName() {
34
        return this.sqlFileName;
35
    }
36

  
37
    @Override
38
    public QueryResultItem analyze(Project project, DatabaseConnection databaseConnection, List<String> sql) {
32 39
        return new QueryResultItem(this.antiPattern, true, null);
33 40
    }
34 41
}
src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/utils/Utils.java
21 21

  
22 22
    public static List<String> loadQueryFromFile(String fileName) {
23 23
        List<String> queries = new ArrayList<>();
24
        InputStream is = Utils.class.getClassLoader().getResourceAsStream(fileName);
24
        InputStream is = Utils.class.getClassLoader().getResourceAsStream("./queries/" + fileName);
25 25
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
26 26
        try {
27 27
            while (reader.ready()) {

Také k dispozici: Unified diff