blob: 9edd50cf34f003f4a162f960b01e280ebb92313c [file] [log] [blame]
Nils Diewalde4986d72015-02-27 17:35:00 +00001package de.ids_mannheim.korap.index;
Nils Diewaldf399a672013-11-18 17:55:22 +00002
3import java.util.*;
4
Nils Diewaldc383ed02015-02-26 21:35:22 +00005import de.ids_mannheim.korap.util.KrillDate;
Nils Diewaldf399a672013-11-18 17:55:22 +00006import de.ids_mannheim.korap.index.FieldDocument;
Nils Diewald0881e242015-02-27 17:31:01 +00007import de.ids_mannheim.korap.response.Response;
Akrone64cc162019-01-08 18:40:37 +01008import de.ids_mannheim.korap.response.MetaField;
Akron50e5f612019-01-16 12:52:39 +01009import de.ids_mannheim.korap.response.MetaFieldsObj;
Nils Diewaldf399a672013-11-18 17:55:22 +000010
Akron75ee2b82016-06-20 21:20:34 +020011import org.apache.lucene.document.Document;
12import org.apache.lucene.index.IndexableField;
13
Nils Diewaldf399a672013-11-18 17:55:22 +000014import com.fasterxml.jackson.annotation.*;
Akron7d45e6b2015-06-26 17:23:42 +020015import com.fasterxml.jackson.annotation.JsonInclude.Include;
16import com.fasterxml.jackson.databind.JsonNode;
17import com.fasterxml.jackson.databind.ObjectMapper;
18import com.fasterxml.jackson.databind.node.ObjectNode;
19
Akron32b95192019-01-11 13:58:55 +010020import com.fasterxml.jackson.databind.node.TextNode;
Nils Diewaldf399a672013-11-18 17:55:22 +000021
Nils Diewald44d5fa12015-01-15 21:31:52 +000022/*
23 * Todo:: Author and textClass may be arrays!
24 */
Nils Diewaldf399a672013-11-18 17:55:22 +000025
Nils Diewaldf399a672013-11-18 17:55:22 +000026/**
Nils Diewald44d5fa12015-01-15 21:31:52 +000027 * Abstract class representing a document in the
Nils Diewald15aa3482015-02-26 18:14:34 +000028 * Krill index.
Nils Diewaldbb33da22015-03-04 16:24:25 +000029 *
Nils Diewald44d5fa12015-01-15 21:31:52 +000030 * This model is rather specific to DeReKo data and
Akron8798be82016-06-23 23:10:25 +020031 * should be considered experimental. It will be replaced
Nils Diewald44d5fa12015-01-15 21:31:52 +000032 * by a more agnostic model.
Akron8798be82016-06-23 23:10:25 +020033 * string fields, e.g. will be combined with a prefix.
34 * For example d:pubDate will mean: A field with the key "pubDate"
35 * of type date.
Nils Diewaldbb33da22015-03-04 16:24:25 +000036 *
Nils Diewald44d5fa12015-01-15 21:31:52 +000037 * @author diewald
Nils Diewaldf399a672013-11-18 17:55:22 +000038 */
Akrond7d7b1f2016-06-25 00:31:16 +020039@JsonInclude(Include.NON_EMPTY)
Akron74107462019-01-10 11:32:54 +010040// @JsonIgnoreProperties(ignoreUnknown = true)
Akronbe9638d2019-02-07 17:09:42 +010041
Nils Diewald0881e242015-02-27 17:31:01 +000042public abstract class AbstractDocument extends Response {
Akron7d45e6b2015-06-26 17:23:42 +020043 ObjectMapper mapper = new ObjectMapper();
Akron2b921a62019-01-14 18:52:45 +010044
Nils Diewald3e3cbf32015-02-06 21:30:49 +000045 private String primaryData;
Akron2b921a62019-01-14 18:52:45 +010046
Akron74107462019-01-10 11:32:54 +010047 private static HashSet<String> legacyStringFields =
48 new HashSet<String>(Arrays.asList(
49 "pubPlace",
50 "textSigle",
51 "docSigle",
52 "corpusSigle",
53 "textType",
54 "textTypeArt",
55 "textTypeRef",
56 "textColumn",
57 "textDomain",
58 "availability",
59 "language",
60 "corpusID", // Deprecated!
61 "ID" // Deprecated!
62 ));
63
64 private static HashSet<String> legacyTextFields =
65 new HashSet<String>(Arrays.asList(
66 "author",
67 "title",
68 "subTitle",
69 "corpusTitle",
70 "corpusSubTitle",
71 "corpusAuthor",
72 "docTitle",
73 "docSubTitle",
74 "docAuthor"
75 ));
76
77 private static HashSet<String> legacyKeywordsFields =
78 new HashSet<String>(Arrays.asList(
79 "textClass",
80 "foundries",
81 "keywords"
82 ));
83
84 private static HashSet<String> legacyStoredFields =
85 new HashSet<String>(Arrays.asList(
86 "docEditor",
87 "tokenSource",
88 "layerInfos",
89 "publisher",
90 "editor",
91 "fileEditionStatement",
92 "biblEditionStatement",
93 "reference",
94 "corpusEditor"
95 ));
96
97 private static HashSet<String> legacyDateFields =
98 new HashSet<String>(Arrays.asList(
99 "pubDate",
100 "creationDate"
Akron32b95192019-01-11 13:58:55 +0100101 ));
Akron74107462019-01-10 11:32:54 +0100102
Nils Diewaldf399a672013-11-18 17:55:22 +0000103 @JsonIgnore
Nils Diewaldbb33da22015-03-04 16:24:25 +0000104 public int internalDocID, localDocID, UID;
Nils Diewaldf399a672013-11-18 17:55:22 +0000105
Akrona6dabb72019-01-09 13:09:41 +0100106 @JsonIgnore
Akron50e5f612019-01-16 12:52:39 +0100107 public MetaFieldsObj mFields = new MetaFieldsObj();
Akron08f4ceb2016-08-03 23:53:32 +0200108
Akron75ee2b82016-06-20 21:20:34 +0200109 /**
110 * Populate document meta information with information coming from
111 * the index.
112 *
113 * @param doc
114 * Document object.
115 * @param field
116 * Primary data field.
117 */
118 public void populateDocument (Document doc, String field) {
Akron1a8bb762019-01-18 15:48:59 +0100119 List<String> fieldList = new ArrayList<>(32);
Akron75ee2b82016-06-20 21:20:34 +0200120 Iterator<IndexableField> fieldIterator = doc.getFields().iterator();
121 while (fieldIterator.hasNext())
122 fieldList.add(fieldIterator.next().name());
123
124 this.populateDocument(doc, field, fieldList);
125 };
126
Akron50e5f612019-01-16 12:52:39 +0100127 /**
128 * Populate document meta information with information coming from
129 * the index.
130 *
131 * @param doc
132 * Document object.
133 * @param field
134 * Primary data field.
135 * @param fields
136 * Hash object with all supported fields.
137 */
138 public void populateDocument (Document doc, String field,
Akron1a8bb762019-01-18 15:48:59 +0100139 List<String> fields) {
Akronfbc76162019-06-04 15:51:09 +0200140 if (field != null)
141 this.setPrimaryData(doc.get(field));
Akron50e5f612019-01-16 12:52:39 +0100142 this.populateFields(doc, fields);
143 };
144
Akron08f4ceb2016-08-03 23:53:32 +0200145
Akron75ee2b82016-06-20 21:20:34 +0200146 public void populateFields (Document doc) {
Akron1a8bb762019-01-18 15:48:59 +0100147 ArrayList<String> fieldList = new ArrayList<>(32);
Akron75ee2b82016-06-20 21:20:34 +0200148 Iterator<IndexableField> fieldIterator = doc.getFields().iterator();
Akron1a8bb762019-01-18 15:48:59 +0100149 while (fieldIterator.hasNext()) {
Akron75ee2b82016-06-20 21:20:34 +0200150 fieldList.add(fieldIterator.next().name());
Akron1a8bb762019-01-18 15:48:59 +0100151 };
Akron75ee2b82016-06-20 21:20:34 +0200152
Akron1a8bb762019-01-18 15:48:59 +0100153 // TODO: Sort alphabetically!
154
Akron75ee2b82016-06-20 21:20:34 +0200155 this.populateFields(doc, fieldList);
156 };
157
Akron08f4ceb2016-08-03 23:53:32 +0200158
Akron1a8bb762019-01-18 15:48:59 +0100159 public void populateFields (Document doc, List<String> fields) {
Akronde4f0852019-01-16 16:29:44 +0100160 Iterator<String> fieldsIter = fields.iterator();
Akron1a8bb762019-01-18 15:48:59 +0100161
162 if (fields.contains("UID")) {
Akron75ee2b82016-06-20 21:20:34 +0200163 this.setUID(doc.get("UID"));
Akron1a8bb762019-01-18 15:48:59 +0100164 };
Akronde4f0852019-01-16 16:29:44 +0100165
Akronbe9638d2019-02-07 17:09:42 +0100166 // fieldsIter = fields.iterator();
Akron1a8bb762019-01-18 15:48:59 +0100167 mFields.fieldsOrder = new ArrayList<>(16);
Akron75ee2b82016-06-20 21:20:34 +0200168
Akron2b921a62019-01-14 18:52:45 +0100169 while (fieldsIter.hasNext()) {
170 String name = fieldsIter.next();
Akron75ee2b82016-06-20 21:20:34 +0200171
Akron2b921a62019-01-14 18:52:45 +0100172 // Remember - never serialize "tokens"
Akron1a975d12019-02-05 13:13:06 +0100173 if (name.equals("tokens") || name.equals("UID"))
Akron2b921a62019-01-14 18:52:45 +0100174 continue;
Akron75ee2b82016-06-20 21:20:34 +0200175
Akron1a8bb762019-01-18 15:48:59 +0100176 mFields.fieldsOrder.add(name);
177
Akronbe9638d2019-02-07 17:09:42 +0100178 // Ignore fields already set
179 if (mFields.contains(name)) {
180 continue;
181 };
182
Akron2b921a62019-01-14 18:52:45 +0100183 IndexableField iField = doc.getField(name);
184
185 if (iField == null)
186 continue;
Akron2b921a62019-01-14 18:52:45 +0100187
188 MetaField mf = mFields.add(iField);
Akrone64cc162019-01-08 18:40:37 +0100189
Akron2b921a62019-01-14 18:52:45 +0100190 // Legacy
Akron1a975d12019-02-05 13:13:06 +0100191 if (name.equals("license"))
Akron2b921a62019-01-14 18:52:45 +0100192 this.addString("availability", doc.get("license"));
193
194 };
Akron75ee2b82016-06-20 21:20:34 +0200195 };
Akron75ee2b82016-06-20 21:20:34 +0200196
Nils Diewaldf399a672013-11-18 17:55:22 +0000197
198 /**
Nils Diewald44d5fa12015-01-15 21:31:52 +0000199 * Get the unique identifier of the document.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000200 *
Nils Diewald44d5fa12015-01-15 21:31:52 +0000201 * @return The unique identifier of the document as an integer.
202 */
Nils Diewaldff6f7662014-09-21 15:08:52 +0000203 @JsonProperty("UID")
204 public int getUID () {
Nils Diewald44d5fa12015-01-15 21:31:52 +0000205 return this.UID;
206 };
Nils Diewaldbb33da22015-03-04 16:24:25 +0000207
Nils Diewald44d5fa12015-01-15 21:31:52 +0000208
209 /**
210 * Set the unique identifier of the document.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000211 *
212 * @param UID
213 * The unique identifier of the document as an integer.
Nils Diewaldd37f7e42015-02-27 21:08:22 +0000214 * @return The invocant for chaining.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000215 */
216 public void setUID (int UID) {
Akrona6dabb72019-01-09 13:09:41 +0100217 if (UID != 0) {
218 this.UID = UID;
219 this.addString("UID", new Integer(UID).toString());
220 }
Nils Diewaldff6f7662014-09-21 15:08:52 +0000221 };
222
Nils Diewald44d5fa12015-01-15 21:31:52 +0000223
224 /**
225 * Set the unique identifier of the document.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000226 *
227 * @param UID
228 * The unique identifier of the document as a
229 * string representing an integer.
Nils Diewaldd37f7e42015-02-27 21:08:22 +0000230 * @return The invocant for chaining.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000231 * @throws NumberFormatException
232 */
233 public void setUID (String UID) throws NumberFormatException {
Akrond7d7b1f2016-06-25 00:31:16 +0200234 if (UID != null) {
Nils Diewald44d5fa12015-01-15 21:31:52 +0000235 this.UID = Integer.parseInt(UID);
Akrona6dabb72019-01-09 13:09:41 +0100236 this.addString("UID", new Integer(this.UID).toString());
Akrond7d7b1f2016-06-25 00:31:16 +0200237 };
Nils Diewaldf399a672013-11-18 17:55:22 +0000238 };
239
Nils Diewald44d5fa12015-01-15 21:31:52 +0000240
241 /**
Nils Diewald44d5fa12015-01-15 21:31:52 +0000242 * Get the primary data of the document.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000243 *
Nils Diewald44d5fa12015-01-15 21:31:52 +0000244 * @return The primary data of the document as a string.
245 */
Akrond504f212015-06-20 00:27:54 +0200246 @JsonIgnore
Nils Diewald44d5fa12015-01-15 21:31:52 +0000247 public String getPrimaryData () {
248 if (this.primaryData == null)
249 return "";
Nils Diewald3e3cbf32015-02-06 21:30:49 +0000250 return this.primaryData;
Nils Diewald44d5fa12015-01-15 21:31:52 +0000251 };
252
253
254 /**
255 * Get the primary data of the document,
256 * starting with a given character offset.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000257 *
258 * @param startOffset
259 * The starting character offset.
260 * @return The substring of primary data of the document as a
261 * string.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000262 */
Akrond504f212015-06-20 00:27:54 +0200263 @JsonIgnore
Nils Diewald44d5fa12015-01-15 21:31:52 +0000264 public String getPrimaryData (int startOffset) {
265 return this.primaryData.substring(startOffset);
266 };
267
268
269 /**
270 * Get the primary data of the document,
271 * starting with a given character offset and ending
272 * with a given character offset.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000273 *
274 * @param startOffset
275 * The starting character offset.
276 * @param endOffset
277 * The ending character offset.
278 * @return The substring of the primary data of the document as a
279 * string.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000280 */
Akrond504f212015-06-20 00:27:54 +0200281 @JsonIgnore
Nils Diewald44d5fa12015-01-15 21:31:52 +0000282 public String getPrimaryData (int startOffset, int endOffset) {
283 return this.primaryData.substring(startOffset, endOffset);
284 };
285
286
287 /**
288 * Set the primary data of the document.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000289 *
290 * @param primary
291 * The primary data of the document
292 * as a string.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000293 */
Nils Diewald3e3cbf32015-02-06 21:30:49 +0000294 public void setPrimaryData (String primary) {
Akron75d0f382019-03-15 14:56:03 +0100295 // Java can't work with utf-8 substrings as defined in the input data,
296 // That's why substringing fails on surrogates. This is a workaround
297 // to remove surrogates to make substringing work again.
298 // It would probably be better to fix this before the data hits the index,
299 // but we have to work with old indices as well.
300 this.primaryData = primary.replaceAll("[^\u0000-\uffff]", "?");
Nils Diewaldf399a672013-11-18 17:55:22 +0000301 };
302
Nils Diewald44d5fa12015-01-15 21:31:52 +0000303 /**
304 * Get the length of the primary data of the document
305 * (i.e. the number of characters).
Nils Diewaldbb33da22015-03-04 16:24:25 +0000306 *
307 * @return The length of the primary data of the document as an
308 * integer.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000309 */
Nils Diewaldf399a672013-11-18 17:55:22 +0000310 @JsonIgnore
311 public int getPrimaryDataLength () {
Nils Diewald44d5fa12015-01-15 21:31:52 +0000312 return this.primaryData.length();
Nils Diewaldf399a672013-11-18 17:55:22 +0000313 };
Nils Diewald49729942013-11-27 20:30:07 +0000314
Nils Diewald49729942013-11-27 20:30:07 +0000315
Nils Diewald44d5fa12015-01-15 21:31:52 +0000316 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000317 * Get the text sigle as a string.
318 *
Nils Diewald44d5fa12015-01-15 21:31:52 +0000319 * @return The text sigle as a string.
320 */
Akronbe9638d2019-02-07 17:09:42 +0100321 @JsonIgnore
Nils Diewaldba197f22014-11-01 17:21:46 +0000322 public String getTextSigle () {
Akrone64cc162019-01-08 18:40:37 +0100323 return this.getFieldValue("textSigle");
Nils Diewaldba197f22014-11-01 17:21:46 +0000324 };
325
Nils Diewald44d5fa12015-01-15 21:31:52 +0000326
Nils Diewald44d5fa12015-01-15 21:31:52 +0000327 /**
Nils Diewaldbb33da22015-03-04 16:24:25 +0000328 * Get the document sigle as a string.
329 *
Nils Diewald44d5fa12015-01-15 21:31:52 +0000330 * @return The document sigle as a string.
331 */
Akronbe9638d2019-02-07 17:09:42 +0100332 @JsonIgnore
Nils Diewaldba197f22014-11-01 17:21:46 +0000333 public String getDocSigle () {
Akrone64cc162019-01-08 18:40:37 +0100334 return this.getFieldValue("docSigle");
Nils Diewaldba197f22014-11-01 17:21:46 +0000335 };
336
Nils Diewald44d5fa12015-01-15 21:31:52 +0000337
338 /**
Akron32b95192019-01-11 13:58:55 +0100339 * Get the corpus sigle as a string.
Nils Diewaldbb33da22015-03-04 16:24:25 +0000340 *
Akron32b95192019-01-11 13:58:55 +0100341 * @return The corpus sigle as a string.
Nils Diewald44d5fa12015-01-15 21:31:52 +0000342 */
Akronbe9638d2019-02-07 17:09:42 +0100343 @JsonIgnore
Akron32b95192019-01-11 13:58:55 +0100344 public String getCorpusSigle () {
345 return this.getFieldValue("corpusSigle");
Nils Diewaldba197f22014-11-01 17:21:46 +0000346 };
347
Nils Diewald44d5fa12015-01-15 21:31:52 +0000348
Nils Diewald44d5fa12015-01-15 21:31:52 +0000349 @Deprecated
Akronbe9638d2019-02-07 17:09:42 +0100350 @JsonIgnore
Akronbb117b32019-01-21 13:57:55 +0100351 public String getAvailability () {
352 return this.getFieldValue("availability");
353 };
354
355
356 @Deprecated
Nils Diewald44d5fa12015-01-15 21:31:52 +0000357 @JsonProperty("corpusID")
358 public String getCorpusID () {
Akrona6dabb72019-01-09 13:09:41 +0100359 return this.getFieldValue("corpusID");
Nils Diewald44d5fa12015-01-15 21:31:52 +0000360 };
361
Nils Diewald44d5fa12015-01-15 21:31:52 +0000362 @Deprecated
363 @JsonProperty("ID")
364 public String getID () {
Akrona6dabb72019-01-09 13:09:41 +0100365 return this.getFieldValue("ID");
Nils Diewald44d5fa12015-01-15 21:31:52 +0000366 };
367
Akron32b95192019-01-11 13:58:55 +0100368 @JsonAnyGetter
369 public Map<String, JsonNode> getLegacyMetaFields () {
Akron2b921a62019-01-14 18:52:45 +0100370
371 Iterator<MetaField> mfIterator = mFields.iterator();
Akron32b95192019-01-11 13:58:55 +0100372
373 HashMap<String, JsonNode> map = new HashMap<>();
374
Akron2b921a62019-01-14 18:52:45 +0100375 while (mfIterator.hasNext()) {
Akron1a8bb762019-01-18 15:48:59 +0100376 MetaField mf = mfIterator.next();
377 if (mf == null)
378 continue;
379 String mfs = mf.key;
Akronbe9638d2019-02-07 17:09:42 +0100380
Akron1a8bb762019-01-18 15:48:59 +0100381 String value = this.getFieldValue(mfs);
382 if (value != null && (
383 legacyDateFields.contains(mfs) ||
384 legacyStoredFields.contains(mfs) ||
385 legacyTextFields.contains(mfs) ||
386 legacyStringFields.contains(mfs) ||
387 legacyKeywordsFields.contains(mfs) ||
388 legacyDateFields.contains(mfs)
389 )
Akron2b921a62019-01-14 18:52:45 +0100390 ) {
Akron1a8bb762019-01-18 15:48:59 +0100391 map.put(mfs, new TextNode(value));
Akron2b921a62019-01-14 18:52:45 +0100392 }
Akron32b95192019-01-11 13:58:55 +0100393 };
394
395 return map;
396 }
397
398
Akron74107462019-01-10 11:32:54 +0100399 @JsonAnySetter
400 public void setLegacyMetaField (String name, JsonNode value) {
401
402 // Treat legacy string fields
403 if (legacyStringFields.contains(name)) {
404 this.addString(name, value.asText());
405 }
Nils Diewald44d5fa12015-01-15 21:31:52 +0000406
Akron74107462019-01-10 11:32:54 +0100407 // Treat legacy text fields
408 else if (legacyTextFields.contains(name)) {
409 this.addText(name, value.asText());
410 }
411
412 // Treat legacy keyword fields
413 else if (legacyKeywordsFields.contains(name)) {
414 this.addKeywords(name, value.asText());
415 }
416
417 // Treat legacy stored fields
418 else if (legacyStoredFields.contains(name)) {
419 this.addStored(name, value.asText());
420 }
421
422 // Treat legacy date fields
423 else if (legacyDateFields.contains(name)) {
424 this.addDate(name, value.asText());
425 }
Akron32b95192019-01-11 13:58:55 +0100426
Akron74107462019-01-10 11:32:54 +0100427 else if (name.equals("license")) {
428 this.addString("availability", value.asText());
429 }
430
431 // Temporarily - treat legacy store values introduced for Sgbr
432 else if (name.equals("store")) {
433 // TODO: Store all values
434 };
435 //
436 // else {
437 // System.err.println("Unknown field: " + name);
438 // };
Nils Diewaldba197f22014-11-01 17:21:46 +0000439 };
Akron74107462019-01-10 11:32:54 +0100440
Akron08f4ceb2016-08-03 23:53:32 +0200441
Akron7d45e6b2015-06-26 17:23:42 +0200442 /**
443 * Serialize response as a {@link JsonNode}.
444 *
445 * @return {@link JsonNode} representation of the response
446 */
447 @Override
448 public JsonNode toJsonNode () {
449 ObjectNode json = (ObjectNode) super.toJsonNode();
450 json.putAll((ObjectNode) mapper.valueToTree(this));
Akrond7d7b1f2016-06-25 00:31:16 +0200451
452 if (this.getUID() == 0)
453 json.remove("UID");
454
Akron7d45e6b2015-06-26 17:23:42 +0200455 return json;
456 };
Akrone64cc162019-01-08 18:40:37 +0100457
458 @JsonIgnore
Akron32b95192019-01-11 13:58:55 +0100459 public String getFieldValue (String field) {
Akrona6dabb72019-01-09 13:09:41 +0100460 MetaField mf = mFields.get(field);
Akrone64cc162019-01-08 18:40:37 +0100461
Akron2b921a62019-01-14 18:52:45 +0100462 if (mf != null && mf.values.size() > 0) {
463 return String.join(
464 " ",
465 mf.values
466 );
Akrone64cc162019-01-08 18:40:37 +0100467 };
468
469 return null;
470 };
471
Akron32b95192019-01-11 13:58:55 +0100472
473 @JsonIgnore
474 public KrillDate getFieldValueAsDate (String field) {
475 String date = this.getFieldValue(field);
476
477 if (date == null)
478 return null;
479
480 return new KrillDate(date);
481 };
482
Akrone64cc162019-01-08 18:40:37 +0100483 @JsonIgnore
Akrona6dabb72019-01-09 13:09:41 +0100484 public void addString (String key, String value) {
Akron2b921a62019-01-14 18:52:45 +0100485 if (value == null)
486 return;
487
Akrona6dabb72019-01-09 13:09:41 +0100488 mFields.add(
Akrone64cc162019-01-08 18:40:37 +0100489 new MetaField(
490 key,
491 "type:string",
492 value
493 )
494 );
495 };
Akron4376e742019-01-16 15:02:30 +0100496
497
498 @JsonIgnore
499 public void addInt (String key, String value) {
500 if (value == null)
501 return;
502
503 mFields.add(
504 new MetaField(
505 key,
506 "type:integer",
507 value
508 )
509 );
510 };
511
512 @JsonIgnore
513 public void addInt (String key, int value) {
514 this.addInt(key, new Integer(value).toString());
515 };
516
Akrone64cc162019-01-08 18:40:37 +0100517
518 @JsonIgnore
Akrona6dabb72019-01-09 13:09:41 +0100519 public void addStored (String key, String value) {
Akron2b921a62019-01-14 18:52:45 +0100520 if (value == null)
521 return;
522
Akrona6dabb72019-01-09 13:09:41 +0100523 mFields.add(
Akrone64cc162019-01-08 18:40:37 +0100524 new MetaField(
525 key,
Akrona6dabb72019-01-09 13:09:41 +0100526 "type:store",
Akrone64cc162019-01-08 18:40:37 +0100527 value
528 )
529 );
530 };
Akron4376e742019-01-16 15:02:30 +0100531
532
533 @JsonIgnore
534 public void addAttachement (String key, String value) {
535 if (value == null)
536 return;
537
538 mFields.add(
539 new MetaField(
540 key,
541 "type:attachement",
542 value
543 )
544 );
545 };
546
Akron2b921a62019-01-14 18:52:45 +0100547
Akrone64cc162019-01-08 18:40:37 +0100548 @JsonIgnore
Akrona6dabb72019-01-09 13:09:41 +0100549 public void addKeywords (String key, String value) {
Akron2b921a62019-01-14 18:52:45 +0100550 if (value == null)
551 return;
552
Akrona6dabb72019-01-09 13:09:41 +0100553 mFields.add(
Akrone64cc162019-01-08 18:40:37 +0100554 new MetaField(
555 key,
556 "type:keywords",
557 value
558 )
559 );
560 };
561
562 @JsonIgnore
Akrona6dabb72019-01-09 13:09:41 +0100563 public void addText (String key, String value) {
Akron2b921a62019-01-14 18:52:45 +0100564 if (value == null)
565 return;
566
Akrona6dabb72019-01-09 13:09:41 +0100567 mFields.add(
Akrone64cc162019-01-08 18:40:37 +0100568 new MetaField(
569 key,
570 "type:text",
571 value
572 )
573 );
574 };
575
576 @JsonIgnore
Akrona6dabb72019-01-09 13:09:41 +0100577 public void addDate (String key, String value) {
Akron2b921a62019-01-14 18:52:45 +0100578 if (value == null)
579 return;
580
Akron32b95192019-01-11 13:58:55 +0100581 KrillDate date = new KrillDate(value);
Akronc7a2abc2019-01-17 14:21:34 +0100582
583 if (date == null)
584 return;
585
Akrona6dabb72019-01-09 13:09:41 +0100586 mFields.add(
Akrone64cc162019-01-08 18:40:37 +0100587 new MetaField(
588 key,
589 "type:date",
Akron32b95192019-01-11 13:58:55 +0100590 date.toDisplay()
Akrone64cc162019-01-08 18:40:37 +0100591 )
592 );
593 };
Akronc7a2abc2019-01-17 14:21:34 +0100594
595 @JsonIgnore
596 public void addDate (String key, int value) {
597 this.addDate(key, new Integer(value).toString());
598 };
Nils Diewaldf399a672013-11-18 17:55:22 +0000599};