1 |
1 |
package cz.zcu.kiv.aswi.fulltextsearch;
|
2 |
2 |
|
3 |
3 |
import cz.zcu.kiv.aswi.fulltextsearch.document.*;
|
|
4 |
import cz.zcu.kiv.aswi.fulltextsearch.model.DocumentResponse;
|
4 |
5 |
import cz.zcu.kiv.aswi.fulltextsearch.model.SearchRequest;
|
5 |
6 |
import cz.zcu.kiv.aswi.fulltextsearch.model.SearchResponse;
|
6 |
7 |
import javaxt.io.Image;
|
... | ... | |
26 |
27 |
import java.awt.image.BufferedImage;
|
27 |
28 |
import java.io.ByteArrayInputStream;
|
28 |
29 |
import java.io.IOException;
|
|
30 |
import java.text.ParseException;
|
|
31 |
import java.text.SimpleDateFormat;
|
29 |
32 |
import java.util.*;
|
30 |
33 |
import java.util.stream.Collectors;
|
31 |
34 |
|
... | ... | |
51 |
54 |
private static final String FIELD_UPLOADED_DATE = "uploadedDate";
|
52 |
55 |
|
53 |
56 |
private static final float IMG_OUTPUT_QUALITY = 0.5f;
|
|
57 |
private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd");
|
54 |
58 |
|
55 |
59 |
private static final int DEFAULT_LINE_FIELD_COUNT = 150;
|
56 |
60 |
private static final int DEFAULT_WORD_FIELD_COUNT = 30;
|
... | ... | |
196 |
200 |
solrInputDocument.addField(FIELD_IMG_FILENAME, imageFile.getOriginalFilename());
|
197 |
201 |
solrInputDocument.addField(FIELD_DOC_CONTENT, xmlFile.getBytes());
|
198 |
202 |
solrInputDocument.addField(FIELD_IMG_CONTENT, Base64.getEncoder().encode(imageFile.getBytes()));
|
|
203 |
solrInputDocument.addField(FIELD_UPLOADED_DATE, FORMAT.format(new Date()));
|
199 |
204 |
|
200 |
205 |
// adding to core files
|
201 |
206 |
solrClientFiles.add(solrInputDocument);
|
... | ... | |
254 |
259 |
* @throws IOException if IO problem occurs
|
255 |
260 |
* @throws SolrServerException if SolrServer problem occurs
|
256 |
261 |
*/
|
257 |
|
public byte[] getImageFromFilesCore(String filename) throws IOException, SolrServerException {
|
|
262 |
private byte[] getImageFromFilesCore(String filename) throws IOException, SolrServerException {
|
258 |
263 |
LOG.trace("SolrService method getImageFromFilesCore called");
|
259 |
264 |
LOG.debug("Getting an image from Files core");
|
260 |
265 |
SolrQuery solrQuery = new SolrQuery();
|
... | ... | |
519 |
524 |
}
|
520 |
525 |
}
|
521 |
526 |
|
522 |
|
public List<String> listAllFiles() throws IOException, SolrServerException {
|
|
527 |
public List<DocumentResponse> listAllFiles() throws IOException, SolrServerException, ParseException {
|
523 |
528 |
LOG.trace("SolrService method listAllFiles called");
|
524 |
529 |
LOG.debug("Displaying ALL files in Solr");
|
525 |
530 |
SolrQuery solrQuery = new SolrQuery();
|
526 |
531 |
solrQuery.set("q", FIELD_DOC_FILENAME + ":*");
|
527 |
532 |
SolrDocumentList docList = solrClientFiles.query(solrQuery).getResults();
|
528 |
|
return docList.stream().map(doc -> doc.getFieldValue(FIELD_DOC_FILENAME).toString().replaceAll(".xml", "")).collect(Collectors.toList());
|
|
533 |
|
|
534 |
int id = 0;
|
|
535 |
List<DocumentResponse> responses = new LinkedList<>();
|
|
536 |
for (SolrDocument doc: docList) {
|
|
537 |
String filename = doc.getFieldValue(FIELD_DOC_FILENAME).toString().replaceAll(".xml", "");
|
|
538 |
String dateStr = doc.getFieldValue(FIELD_UPLOADED_DATE).toString();
|
|
539 |
Date date = FORMAT.parse(dateStr);
|
|
540 |
responses.add(new DocumentResponse(filename, id++, date));
|
|
541 |
}
|
|
542 |
|
|
543 |
return responses;
|
529 |
544 |
}
|
530 |
545 |
|
531 |
546 |
public String listSingleFile(String documentName) throws IOException, SolrServerException {
|
Re #8031: Programová příručka BE
- uploadedDate ukazuje správné datum (a ukládá se do core files)