Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2fe5ab7a

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

Removed unused utils

Zobrazit rozdíly:

src/main/java/cz/zcu/fav/kiv/antipatterndetectionapp/utils/Utils.java
23 23

  
24 24
    private final Logger LOGGER = LoggerFactory.getLogger(Utils.class);
25 25

  
26
    @Autowired
27
    ServletContext context;
28

  
29
    public void getJsonResource() {
30

  
31
        try {
32
            URL test = context.getResource(
33
                    "/queries/too_long_sprint.sql");
34
            LOGGER.error("URL: " + test.toString());
35
            BufferedReader read = new BufferedReader(
36
                    new InputStreamReader(test.openStream()));
37
            String i;
38
            while ((i = read.readLine()) != null) {
39
                LOGGER.error("SQL: " + i);
40
            }
41
            read.close();
42
        } catch (MalformedURLException e) {
43
            e.printStackTrace();
44
        } catch (IOException e) {
45
            e.printStackTrace();
46
        }
47
    }
48

  
49
    public static String bindValues(String query, List<String> parameters) {
50
        for (String parameter : parameters) {
51
            query = query.replace("?", parameter);
52
        }
53
        return query;
54
    }
55

  
56
    public static List<String> loadQueryFromFile(String fileName) {
57
        List<String> queries = new ArrayList<>();
58
        InputStream is = Utils.class.getClassLoader().getResourceAsStream("/queries/" + fileName);
59
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
60
        try {
61
            while (reader.ready()) {
62

  
63
                String line = reader.readLine();
64
                if (line.startsWith("select") || line.startsWith("set")) {
65
                    queries.add(line);
66
                }
67

  
68
            }
69
        } catch (IOException e) {
70
            e.printStackTrace();
71
        }
72
        return queries;
73
    }
74

  
75 26
    public static Long[] arrayOfStringsToArrayOfLongs(String[] strings) {
76 27
        Long[] longs = new Long[strings.length];
77 28
        for (int i = 0; i < strings.length; i++) {

Také k dispozici: Unified diff