Projekt

Obecné

Profil

« Předchozí | Další » 

Revize cc21ed5c

Přidáno uživatelem Jitka Poubová před téměř 5 roky(ů)

Re #7807: Nahrávání souborů přes frontend (upload)
- více souborů najednou lze nahrávat přes /upload (vždy XML+obrázek)
- přidání přes /add zrušeno
- přidáno posílání DocumentSize (rozměry obrázku)
- do Solru se ukládají i slova (tag Word)

Zobrazit rozdíly:

be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/IndexController.java
28 28

  
29 29
    @PostMapping("/upload")
30 30
    public ResponseEntity<ResponseMessage> uploadFile(@RequestParam("file") List<MultipartFile> files) {
31
        String message = "";
31
        String message;
32 32
        try {
33
            // TODO: Převést MultipartFile na normální file a pak ho dále zpracovat
34

  
35
            message = "Successfully uploaded " + files.size() + " files";
33
            int uploaded = solrService.uploadFiles(files);
34
            message = "Successfully uploaded " + uploaded + " files";
36 35
            return ResponseEntity.status(HttpStatus.OK).body(new ResponseMessage(message));
37 36
        } catch (Exception e) {
37
            e.printStackTrace();
38 38
            message = "Could not upload the files! " + e.toString();
39 39
            return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseMessage(message));
40 40
        }
41 41
    }
42 42

  
43 43
    @GetMapping("/documents")
44
    public List<DocumentResponse> uploadFile() {
44
    public List<DocumentResponse> listDocuments() {
45 45
        List<DocumentResponse> response = new ArrayList<>();
46 46

  
47 47
        try {
......
57 57
        return response;
58 58
    }
59 59

  
60

  
61

  
62
    @GetMapping("/add")
63
    public String add() {
64
        String response;
65

  
66
        try {
67
            solrService.addAllDocuments();
68
            response = "All documents have been added.";
69
        } catch (Exception e) {
70
            response = "Unknown exception";
71
            e.printStackTrace();
72
        }
73

  
74
        return response;
75
    }
76

  
77 60
    @GetMapping("/delete")
78 61
    public String delete() {
79 62
        String response;
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/SolrService.java
20 20
public class SolrService {
21 21

  
22 22
    // for docker
23
    public static final String DATA_DIR = "/data/";
24 23
    private static final String URL = "http://fulltextsearch-solr";
25 24

  
26 25
    // for localhost
27
    //public static final String DATA_DIR = "data/";
28 26
    //private static final String URL = "http://localhost";
29 27

  
30
    private static final String CORE_NAME = "documents";
28
    private static final String CORE_NAME_DOCUMENTS = "documents";
29
    private static final String CORE_NAME_FILES = "files";
31 30

  
32 31
    private static final String PREFIX_TEXT_LINE = "text_line_";
32
    private static final String PREFIX_TEXT_WORD = "text_word_";
33 33
    private static final String SUFFIX_COORDS = "_coords";
34 34

  
35 35
    private static final String FIELD_DOC_FILENAME = "doc_filename";
36 36
    private static final String FIELD_IMG_FILENAME = "img_filename";
37 37
    private static final String FIELD_TEXT_REGION = "text_region";
38 38
    private static final String FIELD_TEXT_REGION_COORDS = "text_region" + SUFFIX_COORDS;
39
    private static final String FIELD_DOC_CONTENT = "doc_content";
40
    private static final String FIELD_IMG_CONTENT = "img_content";
39 41

  
40
    private HttpSolrClient solrClient;
41
    private List<String> fieldNames = new ArrayList<>();
42
    private static final int SEARCH_QUERY_ROWS = 100;
43

  
44
    private HttpSolrClient solrClientDocuments;
45
    private HttpSolrClient solrClientFiles;
46
    private List<String> fieldNamesDocumentCore = new ArrayList<>();
42 47

  
43 48
    public SolrService() {
44 49
        connect();
45 50
    }
46 51

  
47 52
    private void connect() {
48
        String urlString = URL + ":8983/solr/" + CORE_NAME;
49
        solrClient = new HttpSolrClient.Builder(urlString).build();
53
        String urlString = URL + ":8983/solr/" + CORE_NAME_DOCUMENTS;
54
        solrClientDocuments = new HttpSolrClient.Builder(urlString).build();
55

  
56
        urlString = URL + ":8983/solr/" + CORE_NAME_FILES;
57
        solrClientFiles = new HttpSolrClient.Builder(urlString).build();
58
    }
59

  
60
    public int uploadFiles(List<MultipartFile> files) throws IOException, SolrServerException, JAXBException {
61
        Map<String, List<MultipartFile>> pairs = new HashMap<>();
62

  
63
        for (MultipartFile file: files) {
64
            String filename = file.getOriginalFilename();
65
            if (filename == null) {
66
                System.out.println("Skipping file with empty filename.");
67
                continue;
68
            }
69

  
70
            String type = file.getContentType();
71
            if (type == null) {
72
                System.out.println("Skipping file " + filename + " (unknown type).");
73
                continue;
74
            }
75

  
76
            int index = filename.lastIndexOf('.');
77
            String filenameWithoutExtension = filename;
78
            if (index >= 0) {
79
                filenameWithoutExtension = filename.substring(0, index);
80
            }
81

  
82
            if (type.equals(MediaType.IMAGE_JPEG_VALUE) || type.equals(MediaType.IMAGE_PNG_VALUE)
83
                    || type.equals(MediaType.APPLICATION_XML_VALUE)) {
84

  
85
                List<MultipartFile> list = pairs.get(filenameWithoutExtension);
86
                if (list == null) {
87
                    list = new LinkedList<>();
88
                    list.add(file);
89
                    pairs.put(filenameWithoutExtension, list);
90
                } else {
91
                    list.add(file);
92
                }
93

  
94
            } else {
95
                System.out.println("Not supported type of file! File " + filename + " is type " + type + ".");
96
            }
97
        }
98

  
99
        return addFiles(pairs);
50 100
    }
51 101

  
52
    public void addAllDocuments() throws IOException, SolrServerException, JAXBException {
53
        getFieldNamesFromSolr();
54
        addBasicFieldsToSolr();
102
    private int addFiles(Map<String, List<MultipartFile>> pairs) throws IOException, SolrServerException, JAXBException {
103
        getFieldNamesFromDocumentCore();
104
        addBasicFieldsToDocumentsCore();
105

  
106
        addAllFieldsToFilesCore();
107

  
108
        int count = 0;
109
        Set<String> keys = pairs.keySet();
110
        for (String key: keys) {
111
            List<MultipartFile> pair = pairs.get(key);
112
            if (pair.size() != 2) continue;
113

  
114
            MultipartFile first = pair.get(0);
115
            if (first.getContentType().equals(MediaType.APPLICATION_XML_VALUE)) {
116
                addToFilesCore(first, pair.get(1));
117
            } else {
118
                addToFilesCore(pair.get(1), first);
119
            }
120

  
121
            count += 2;
122
        }
123

  
124
        solrClientFiles.commit();
125
        solrClientDocuments.commit();
126

  
127
        return count;
128
    }
129

  
130
    private void addToFilesCore(MultipartFile xmlFile, MultipartFile imageFile) throws IOException, SolrServerException, JAXBException {
131
        SolrInputDocument solrInputDocument = new SolrInputDocument();
132

  
133
        solrInputDocument.addField(FIELD_DOC_FILENAME, xmlFile.getOriginalFilename());
134
        solrInputDocument.addField(FIELD_IMG_FILENAME, imageFile.getOriginalFilename());
135
        solrInputDocument.addField(FIELD_DOC_CONTENT, xmlFile.getBytes());
136
        solrInputDocument.addField(FIELD_IMG_CONTENT, Base64.getEncoder().encode(imageFile.getBytes()));
137

  
138
        solrClientFiles.add(solrInputDocument);
55 139

  
56 140
        XMLLoader xmlLoader = new XMLLoader();
141
        PcGts doc = xmlLoader.loadFile(xmlFile.getInputStream(), xmlFile.getOriginalFilename());
142
        addToDocumentsCore(doc, imageFile.getOriginalFilename());
143
    }
144

  
145
    private void addAllFieldsToFilesCore() throws IOException, SolrServerException {
146
        List<String> fieldNamesFilesCore = new ArrayList<>();
147

  
148
        SchemaRequest.Fields fieldRequest = new SchemaRequest.Fields();
149
        SchemaResponse.FieldsResponse fieldsResponse = fieldRequest.process(solrClientFiles);
150
        List<Map<String, Object>> fields = fieldsResponse.getFields();
151

  
152
        for (Map<String, Object> field: fields) {
153
            fieldNamesFilesCore.add(field.get("name").toString());
154
        }
155

  
156
        String[] filenames = new String[]{ FIELD_DOC_FILENAME, FIELD_IMG_FILENAME };
157
        String[] contents = new String[]{ FIELD_DOC_CONTENT, FIELD_IMG_CONTENT };
158

  
159
        for (String name: filenames) {
160
            if (fieldNamesFilesCore.contains(name)) continue;
57 161

  
58
        // temporary solution: - TODO
59
        String[] files = new String[]{
60
                "soap-ch_knihovna_ascher-zeitung-1866-01-06-n1_0035_bin_rot.xml",
61
                "soap-ch_knihovna_ascher-zeitung-1866-01-06-n1_0040_bin_rot.xml",
62
                "soap-ch_knihovna_ascher-zeitung-1866-01-06-n1_0070_bin_rot.xml",
63
                "soap-ch_knihovna_ascher-zeitung-1866-02-03-n5_0155_bin_rot.xml",
64
                "soap-ch_knihovna_ascher-zeitung-1866-02-03-n5_0160_bin_rot.xml",
65
                "soap-ch_knihovna_ascher-zeitung-1866-02-03-n5_0190_bin_rot.xml",
66
                "soap-ch_knihovna_ascher-zeitung-1866-03-10-n10_0355_bin_rot.xml",
67
                "soap-ch_knihovna_ascher-zeitung-1866-03-10-n10_0360_bin_rot.xml",
68
                "soap-ch_knihovna_ascher-zeitung-1866-03-10-n10_0390_bin_rot.xml",
69
                "soap-ch_knihovna_ascher-zeitung-1866-07-28-n30_1085_bin_rot.xml"
70
        };
71
        for (String filename: files) {
72
            PcGts doc = xmlLoader.loadFile(filename);
73
            System.out.println("Doc " + filename + " has been loaded from resources.");
74
            addDocument(doc);
162
            try {
163
                SchemaRequest.Update request = getAddTextFieldRequest(name);
164
                request.process(solrClientFiles);
165
            } catch (Exception e) {
166
                System.out.println("Couldn't add field = " + name);
167
                e.printStackTrace();
168
            }
169
        }
170

  
171
        for (String name: contents) {
172
            if (fieldNamesFilesCore.contains(name)) continue;
173

  
174
            try {
175
                Map<String, Object> fieldAttributes = new LinkedHashMap<>();
176
                fieldAttributes.put("name", name);
177
                fieldAttributes.put("type", "binary");
178
                fieldAttributes.put("indexed", false);
179
                fieldAttributes.put("stored", true);
180
                fieldAttributes.put("multiValued", false);
181
                SchemaRequest.Update request = new SchemaRequest.AddField(fieldAttributes);
182
                request.process(solrClientFiles);
183
            } catch (Exception e) {
184
                System.out.println("Couldn't add field = " + name);
185
                e.printStackTrace();
186
            }
75 187
        }
76 188
    }
77 189

  
78
    private void addBasicFieldsToSolr() {
79
        addFieldToSolr(FIELD_DOC_FILENAME);
80
        addFieldToSolr(FIELD_IMG_FILENAME);
81
        addFieldToSolr(FIELD_TEXT_REGION);
82
        addFieldToSolr(FIELD_TEXT_REGION_COORDS);
190
    private void addBasicFieldsToDocumentsCore() {
191
        addFieldToDocumentCore(FIELD_DOC_FILENAME);
192
        addFieldToDocumentCore(FIELD_IMG_FILENAME);
193
        addFieldToDocumentCore(FIELD_TEXT_REGION);
194
        addFieldToDocumentCore(FIELD_TEXT_REGION_COORDS);
83 195
    }
84 196

  
85
    private void getFieldNamesFromSolr() throws IOException, SolrServerException {
197
    private void getFieldNamesFromDocumentCore() throws IOException, SolrServerException {
86 198
        SchemaRequest.Fields fieldRequest = new SchemaRequest.Fields();
87
        SchemaResponse.FieldsResponse fieldsResponse = fieldRequest.process(solrClient);
199
        SchemaResponse.FieldsResponse fieldsResponse = fieldRequest.process(solrClientDocuments);
88 200
        List<Map<String, Object>> fields = fieldsResponse.getFields();
89 201

  
90 202
        for (Map<String, Object> field: fields) {
91
            fieldNames.add(field.get("name").toString());
203
            fieldNamesDocumentCore.add(field.get("name").toString());
92 204
        }
93 205
    }
94 206

  
95 207

  
96
    private void addFieldToSolr(String name) {
97
        if (fieldNames.contains(name)) return;
208
    private void addFieldToDocumentCore(String name) {
209
        if (fieldNamesDocumentCore.contains(name)) return;
98 210

  
99 211
        try {
100
            Map<String, Object> fieldAttributes = new LinkedHashMap<>();
101
            fieldAttributes.put("name", name);
102
            fieldAttributes.put("type", "text_general");
103
            fieldAttributes.put("stored", true);
104
            fieldAttributes.put("multiValued", false);
105
            SchemaRequest.Update addFieldRequest = new SchemaRequest.AddField(fieldAttributes);
106
            addFieldRequest.process(solrClient);
107

  
108
            fieldNames.add(name);
212
            SchemaRequest.Update request = getAddTextFieldRequest(name);
213
            request.process(solrClientDocuments);
214
            fieldNamesDocumentCore.add(name);
109 215
        } catch (Exception e) {
110 216
            System.out.println("Couldn't add field = " + name);
111 217
            e.printStackTrace();
112 218
        }
113 219
    }
114 220

  
221
    private SchemaRequest.Update getAddTextFieldRequest(String name) {
222
        Map<String, Object> fieldAttributes = new LinkedHashMap<>();
223
        fieldAttributes.put("name", name);
224
        fieldAttributes.put("type", "text_general");
225
        fieldAttributes.put("stored", true);
226
        fieldAttributes.put("multiValued", false);
227
        return new SchemaRequest.AddField(fieldAttributes);
228
    }
229

  
115 230
    public void deleteAll() throws IOException, SolrServerException {
116
        solrClient.deleteByQuery("*:*");
117
        solrClient.commit();
231
        solrClientDocuments.deleteByQuery("*:*");
232
        solrClientDocuments.commit();
233

  
234
        solrClientFiles.deleteByQuery("*:*");
235
        solrClientFiles.commit();
236
    }
237

  
238
    public byte[] getImageFromFilesCore(String filename) throws IOException, SolrServerException {
239
        SolrQuery solrQuery = new SolrQuery();
240
        solrQuery.set("q", FIELD_IMG_FILENAME + ":" + "\"" + filename + "\"");
241
        SolrDocumentList results = solrClientFiles.query(solrQuery).getResults();
242
        if (results.getNumFound() < 1) {
243
            System.out.println("Image " + filename + " not found!");
244
        } else if (results.getNumFound() > 1) {
245
            System.out.println("Image " + filename + " has multiple files. Using first one...");
246
        }
247

  
248
        SolrDocument result = results.get(0);
249
        return (byte[]) result.getFieldValue(FIELD_IMG_CONTENT);
118 250
    }
119 251

  
120 252
    public SearchResponse query(String query) throws IOException, SolrServerException  {
......
122 254
        solrQuery.set("q", FIELD_TEXT_REGION + ":" + query);
123 255
        solrQuery.setHighlight(true);
124 256
        solrQuery.addHighlightField(PREFIX_TEXT_LINE +  "*");
125
        QueryResponse response = solrClient.query(solrQuery);
257
        solrQuery.addHighlightField(PREFIX_TEXT_WORD +  "*");
258
        solrQuery.setRows(SEARCH_QUERY_ROWS);
259
        QueryResponse response = solrClientDocuments.query(solrQuery);
126 260

  
127 261
        SolrDocumentList docList = response.getResults();
128 262
        Map<String, Map<String, List<String>>> highlight = response.getHighlighting();
......
144 278
            String documentName = ((String) solrDocument.getFieldValue(FIELD_DOC_FILENAME)).replaceAll(".xml", "");
145 279
            textRegion.setDocumentName(documentName);
146 280

  
147
            // text lines
281
            // text lines and text words
148 282
            Map<String, List<String>> map = highlight.get(solrDocument.getFieldValue("id").toString());
149
            Set<String> linesNames = map.keySet();
150
            List<TextLine> textLines = new LinkedList<>();
283
            Set<String> linesAndWordsNames = map.keySet();
284

  
285
            Set<String> linesNames = linesAndWordsNames.stream().filter(name -> name.startsWith(PREFIX_TEXT_LINE)).collect(Collectors.toSet());
286
            Set<String> wordNames = linesAndWordsNames.stream().filter(name -> name.startsWith(PREFIX_TEXT_WORD)).collect(Collectors.toSet());
287

  
288
            Map<String, TextLine> textLines = new HashMap<>();
151 289
            for (String lineName: linesNames) {
152 290
                TextLine textLine = new TextLine();
153 291

  
154 292
                textLine.setLineText((String) solrDocument.getFieldValue(lineName));
155

  
156 293
                String coordsValue = (String) solrDocument.getFieldValue(lineName + SUFFIX_COORDS);
157 294
                Point[] linePoints = Coords.parsePointString(coordsValue);
158 295
                textLine.setLineCoords(new Coords(linePoints));
159 296

  
160
                textLines.add(textLine);
297
                textLines.put(lineName, textLine);
161 298
            }
162 299

  
163
            textRegion.setTextLines(textLines.toArray(new TextLine[0]));
300
            Map<String, List<TextWord>> textWords = new HashMap<>();
301
            for (String wordName: wordNames) {
302
                TextWord textWord = new TextWord();
303

  
304
                textWord.setWordText((String) solrDocument.getFieldValue(wordName));
305
                String coordsValue = (String) solrDocument.getFieldValue(wordName + SUFFIX_COORDS);
306
                Point[] wordPoints = Coords.parsePointString(coordsValue);
307
                textWord.setWordCoords(new Coords(wordPoints));
308

  
309
                String lineName = wordName.substring(wordName.indexOf(PREFIX_TEXT_LINE));
310

  
311
                List<TextWord> lineWords = textWords.get(lineName);
312
                if (lineWords == null) {
313
                    lineWords = new LinkedList<>();
314
                }
315

  
316
                lineWords.add(textWord);
317
                textWords.put(lineName, lineWords);
318
            }
319

  
320
            for (String lineName: textWords.keySet()) {
321
                TextLine line = textLines.get(lineName);
322
                line.setTextWords(textWords.get(lineName).toArray(new TextWord[0]));
323
            }
324

  
325
            textRegion.setTextLines(textLines.values().toArray(new TextLine[0]));
164 326

  
165 327
            // image
166 328
            String imgFilename = (String) solrDocument.getFieldValue(FIELD_IMG_FILENAME);
167
            InputStream is = getClass().getClassLoader().getResourceAsStream(SolrService.DATA_DIR + imgFilename);
168
            String encodedImage = Base64.getEncoder().encodeToString(is.readAllBytes());
169
            textRegion.setImageCut(encodedImage); // todo - only temporary - setting imageCut to whole document image
329
            byte[] imageBytes = getImageFromFilesCore(imgFilename);
330
            textRegion.setImageCut(new String(imageBytes));
331

  
332
            // image size
333
            BufferedImage image = ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(imageBytes)));
334
            DocumentSize documentSize = new DocumentSize(image.getHeight(), image.getWidth());
335
            textRegion.setDocumentSize(documentSize);
170 336

  
171 337
            textRegions.add(textRegion);
172 338
        }
......
176 342
        return searchResponse;
177 343
    }
178 344

  
179
    private void addDocument(PcGts document) throws IOException, SolrServerException {
345
    private void addToDocumentsCore(PcGts document, String imageFilename) throws IOException, SolrServerException {
180 346
        List<TextRegion> regions = document.getPage().getTextRegions();
181 347
        if (regions == null || regions.size() == 0) return;
182 348

  
......
185 351
            SolrInputDocument solrInputDocument = new SolrInputDocument();
186 352

  
187 353
            solrInputDocument.addField(FIELD_DOC_FILENAME, document.getFilename());
188
            solrInputDocument.addField(FIELD_IMG_FILENAME, document.getFilename().replaceAll(".xml", ".png")); // todo
354
            solrInputDocument.addField(FIELD_IMG_FILENAME, imageFilename);
189 355
            solrInputDocument.addField(FIELD_TEXT_REGION, textRegion.getTextEquiv().getUnicode());
190 356
            solrInputDocument.addField(FIELD_TEXT_REGION_COORDS, textRegion.getRegionCoords().getPointsString());
191 357

  
......
195 361
                TextLine textLine = textLines[j];
196 362
                String prefix = PREFIX_TEXT_LINE + j;
197 363

  
198
                addFieldToSolr(prefix);
364
                addFieldToDocumentCore(prefix);
199 365
                solrInputDocument.addField(prefix, textLine.getTextEquiv().getUnicode());
200 366

  
201
                addFieldToSolr(prefix + SUFFIX_COORDS);
367
                addFieldToDocumentCore(prefix + SUFFIX_COORDS);
202 368
                solrInputDocument.addField(prefix + SUFFIX_COORDS, textLine.getLineCoords().getPointsString());
369

  
370
                TextWord[] textWords = textLine.getTextWords();
371
                if (textWords == null || textWords.length == 0) continue;
372
                for (int k = 0; k < textWords.length; k++) {
373
                    TextWord textWord = textWords[k];
374
                    String wordPrefix = PREFIX_TEXT_WORD + k + "_" + prefix;
375

  
376
                    addFieldToDocumentCore(wordPrefix);
377
                    solrInputDocument.addField(wordPrefix, textWord.getTextEquiv().getUnicode());
378

  
379
                    addFieldToDocumentCore(wordPrefix + SUFFIX_COORDS);
380
                    solrInputDocument.addField(wordPrefix + SUFFIX_COORDS, textWord.getWordCoords().getPointsString());
381
                }
203 382
            }
204 383

  
205
            solrClient.add(solrInputDocument);
384
            solrClientDocuments.add(solrInputDocument);
206 385
        }
207

  
208
        solrClient.commit();
209 386
    }
210 387

  
211 388
    public String info() throws IOException, SolrServerException {
212 389
        SolrQuery q = new SolrQuery("*:*");
213 390
        q.setRows(0);  // don't actually request any data
214
        return "Number of documents in core: " + solrClient.query(q).getResults().getNumFound();
391
        return "Number of documents in " + CORE_NAME_DOCUMENTS + " core: " + solrClientDocuments.query(q).getResults().getNumFound() +
392
                "\nNumber of documents in " + CORE_NAME_FILES + " core: " + solrClientFiles.query(q).getResults().getNumFound();
215 393
    }
216 394

  
217 395
    public List<String> listAllFiles() throws IOException, SolrServerException {
218 396
        SolrQuery solrQuery = new SolrQuery();
219 397
        solrQuery.set("q", FIELD_DOC_FILENAME + ":*");
220 398
        solrQuery.setRows(500); // todo not a magic number!
221
        SolrDocumentList docList = solrClient.query(solrQuery).getResults();
222

  
223
        Set<String> ids = getUniqueIds(docList);
224
        return new ArrayList<>(ids);
399
        SolrDocumentList docList = solrClientFiles.query(solrQuery).getResults();
400
        return docList.stream().map(doc -> doc.getFieldValue(FIELD_DOC_FILENAME).toString()).collect(Collectors.toList());
225 401
    }
226 402

  
227
    private Set<String> getUniqueIds(SolrDocumentList documents) {
228
        Set<String> ids = new HashSet<>();
229
        for (SolrDocument document: documents) {
230
            String id = document.getFieldValue(FIELD_DOC_FILENAME).toString();
231
            ids.add(id);
232
        }
233

  
234
        return ids;
235
    }
236 403
}
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/XMLLoader.java
10 10

  
11 11
public class XMLLoader {
12 12

  
13
    public PcGts loadFile(String filename) throws JAXBException {
14
        InputStream file = getClass().getClassLoader().getResourceAsStream(SolrService.DATA_DIR + filename);
15

  
13
    public PcGts loadFile(InputStream file, String filename) throws JAXBException {
16 14
        JAXBContext jaxbContext = JAXBContext.newInstance(PcGts.class);
17 15
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
18 16

  
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/document/DocumentSize.java
1
package cz.zcu.kiv.aswi.fulltextsearch.document;
2

  
3
public class DocumentSize {
4

  
5
    private int height;
6
    private int width;
7

  
8
    public DocumentSize(int height, int width) {
9
        this.height = height;
10
        this.width = width;
11
    }
12

  
13
    public int getHeight() {
14
        return height;
15
    }
16

  
17
    public int getWidth() {
18
        return width;
19
    }
20
}
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/document/TextRegion.java
14 14
    private String regionText;
15 15
    private TextLine[] textLines;
16 16
    private String documentName;
17
    private DocumentSize documentSize;
17 18

  
18 19
    @JsonIgnore
19 20
    private TextEquiv textEquiv;
......
68 69
    public void setRegionText(String regionText) {
69 70
        this.regionText = regionText;
70 71
    }
72

  
73
    public DocumentSize getDocumentSize() {
74
        return documentSize;
75
    }
76

  
77
    public void setDocumentSize(DocumentSize documentSize) {
78
        this.documentSize = documentSize;
79
    }
71 80
}
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/document/TextWord.java
1 1
package cz.zcu.kiv.aswi.fulltextsearch.document;
2 2

  
3
import com.fasterxml.jackson.annotation.JsonIgnore;
4

  
3 5
import javax.xml.bind.annotation.XmlAccessType;
4 6
import javax.xml.bind.annotation.XmlAccessorType;
5 7
import javax.xml.bind.annotation.XmlElement;
......
8 10
public class TextWord {
9 11

  
10 12
    private Coords wordCoords;
13
    private String wordText;
14

  
15
    @JsonIgnore
11 16
    private TextEquiv textEquiv;
12 17

  
13 18
    public Coords getWordCoords() {
......
28 33
        this.textEquiv = textEquiv;
29 34
    }
30 35

  
36
    public String getWordText() {
37
        return wordText;
38
    }
39

  
40
    public void setWordText(String wordText) {
41
        this.wordText = wordText;
42
    }
31 43
}
be/fulltextsearch/src/main/java/cz/zcu/kiv/aswi/fulltextsearch/model/QueryResponse.java
1
package cz.zcu.kiv.aswi.fulltextsearch.model;
2

  
3
public class QueryResponse {
4

  
5
    private String response;
6

  
7
    public QueryResponse(String response) {
8
        this.response = response;
9
    }
10

  
11
    public String getResponse() {
12
        return response;
13
    }
14

  
15
    public void setResponse(String response) {
16
        this.response = response;
17
    }
18
}
be/fulltextsearch/src/test/java/cz/zcu/kiv/aswi/fulltextsearch/HttpRequestTest.java
26 26
                String.class)).contains(controller.info());
27 27
    }
28 28

  
29
    @Test
30
    public void addTest() throws Exception {
31
        assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/add",
32
                String.class)).contains(controller.add());
33
    }
34 29
}

Také k dispozici: Unified diff