• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

opensrp / opensrp-server-core / #162

pending completion
#162

Pull #621

Github

web-flow
Merge b5d4652eb into 68d7f3ff3
Pull Request #621: update selectStructureAndFamilyWithinRadius query

8286 of 10652 relevant lines covered (77.79%)

0.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/opensrp/util/DataQuery.java
1
package org.opensrp.util;
2

3
import java.io.BufferedReader;
4
import java.io.IOException;
5
import java.io.InputStream;
6
import java.io.InputStreamReader;
7
import java.lang.reflect.Field;
8
import java.lang.reflect.Modifier;
9

10
public class DataQuery {
×
11
        
12
        public static final String LUCENE_CLIENT_QUERY = new String("lucene-client-query");
×
13
        
14
        static {
15
                for (Field field : DataQuery.class.getDeclaredFields()) {
×
16
                        if (field.getName().toLowerCase().endsWith("_query")) {
×
17
                                try {
18
                                        field.setAccessible(true);
×
19
                                        Field modifiers = field.getClass().getDeclaredField("modifiers");
×
20
                                        modifiers.setAccessible(true);
×
21
                                        modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
×
22
                                        field.set(null, getQuery(field.get(null).toString()));
×
23
                                }
24
                                catch (IllegalArgumentException | IllegalAccessException e) {
×
25
                                        e.printStackTrace();
×
26
                                }
27
                                catch (NoSuchFieldException e) {
×
28
                                        e.printStackTrace();
×
29
                                }
30
                                catch (SecurityException e) {
×
31
                                        e.printStackTrace();
×
32
                                }
×
33
                        }
34
                }
35
        }
×
36
        
37
        private static String getQuery(String fileName) {
38
                try {
39
                        InputStream in = DataQuery.class.getResourceAsStream("/queries/" + fileName);
×
40
                        BufferedReader r = new BufferedReader(new InputStreamReader(in));
×
41
                        StringBuilder stringJson = new StringBuilder();
×
42
                        
43
                        int chunksize = 1024;
×
44
                        char[] charBuffer = new char[chunksize];
×
45
                        int count = 0;
×
46
                        
47
                        do {
48
                                count = r.read(charBuffer, 0, chunksize);
×
49
                                
50
                                if (count >= 0) {
×
51
                                        stringJson.append(charBuffer, 0, count);
×
52
                                }
53
                        } while (count > 0);
×
54
                        
55
                        r.close();
×
56
                        
57
                        return stringJson.toString();
×
58
                }
59
                catch (IOException e) {
×
60
                        e.printStackTrace();
×
61
                }
62
                return null;
×
63
        }
64
        
65
        public static void main(String[] args) {
66
                System.out.println(LUCENE_CLIENT_QUERY);
×
67
        }
×
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc