| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap; |
| 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | import de.ids_mannheim.korap.util.KorapDate; |
| 6 | import de.ids_mannheim.korap.document.KorapPrimaryData; |
| 7 | import de.ids_mannheim.korap.index.FieldDocument; |
| 8 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 9 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 10 | import com.fasterxml.jackson.annotation.*; |
| 11 | |
| 12 | /* Todo:: Author and textClass may be arrays! */ |
| 13 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 14 | /** |
| 15 | * Abstract class representing a document in the KorAP index. |
| 16 | * |
| 17 | * @author ndiewald |
| 18 | */ |
| Nils Diewald | 010c10f | 2013-12-17 01:58:31 +0000 | [diff] [blame] | 19 | @JsonIgnoreProperties(ignoreUnknown = true) |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 20 | public abstract class KorapDocument { |
| 21 | private KorapPrimaryData primaryData; |
| 22 | |
| 23 | @JsonIgnore |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 24 | public int internalDocID, localDocID, UID; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 25 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 26 | private String author, textClass, corpusID, |
| Nils Diewald | 4972994 | 2013-11-27 20:30:07 +0000 | [diff] [blame] | 27 | pubPlace, ID, title, subTitle, |
| Nils Diewald | 010c10f | 2013-12-17 01:58:31 +0000 | [diff] [blame] | 28 | foundries, tokenization, |
| Nils Diewald | 2cd1c3d | 2014-01-08 22:53:08 +0000 | [diff] [blame] | 29 | layerInfo, field; |
| 30 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 31 | private KorapDate pubDate; |
| 32 | |
| 33 | /** |
| 34 | * Set the publication date of the document the match occurs in. |
| 35 | * |
| 36 | * @param date The date as a KorapDate compatible string representation. |
| 37 | * @return A KorapDate object for chaining. |
| 38 | * @see KorapDate#Constructor(String) |
| 39 | */ |
| 40 | public KorapDate setPubDate (String date) { |
| 41 | // ObjectMapper mapper = new ObjectMapper(); |
| 42 | this.pubDate = new KorapDate(date); |
| 43 | return this.pubDate; |
| 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * Set the publication date of the document the match occurs in. |
| 48 | * |
| 49 | * @param date The date as a KorapDate object. |
| 50 | * @return A KorapDate object for chaining. |
| 51 | * @see KorapDate |
| 52 | */ |
| 53 | public KorapDate setPubDate (KorapDate date) { |
| 54 | return (this.pubDate = date); |
| 55 | }; |
| 56 | |
| 57 | /** |
| 58 | * Get the publication date of the document the match occurs in as a KorapDate object. |
| 59 | */ |
| 60 | @JsonIgnore |
| 61 | public KorapDate getPubDate () { |
| 62 | return this.pubDate; |
| 63 | }; |
| 64 | |
| 65 | @JsonProperty("pubDate") |
| 66 | public String getPubDateString () { |
| Nils Diewald | cde6908 | 2014-01-16 15:46:48 +0000 | [diff] [blame] | 67 | if (this.pubDate != null) |
| 68 | return this.pubDate.toDisplay(); |
| 69 | return null; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | public void setAuthor (String author) { |
| 73 | this.author = author; |
| 74 | }; |
| 75 | |
| 76 | public String getAuthor () { |
| 77 | return this.author; |
| 78 | }; |
| 79 | |
| 80 | public void setTextClass (String textClass) { |
| 81 | this.textClass = textClass; |
| 82 | }; |
| 83 | |
| 84 | public String getTextClass () { |
| 85 | return this.textClass; |
| 86 | }; |
| 87 | |
| 88 | public void setPubPlace (String pubPlace) { |
| 89 | this.pubPlace = pubPlace; |
| 90 | }; |
| 91 | |
| 92 | public String getPubPlace () { |
| 93 | return this.pubPlace; |
| 94 | }; |
| 95 | |
| 96 | public void setCorpusID (String corpusID) { |
| 97 | this.corpusID = corpusID; |
| 98 | }; |
| 99 | |
| 100 | @JsonProperty("corpusID") |
| 101 | public String getCorpusID () { |
| 102 | return this.corpusID; |
| 103 | }; |
| 104 | |
| 105 | public void setID (String ID) { |
| 106 | this.ID = ID; |
| 107 | }; |
| 108 | |
| Nils Diewald | 7cbcfe9 | 2014-09-22 22:01:51 +0000 | [diff] [blame] | 109 | @JsonProperty("ID") |
| 110 | public String getID () { |
| 111 | return this.ID; |
| 112 | }; |
| 113 | |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 114 | public void setUID (int UID) { |
| 115 | this.UID = UID; |
| 116 | }; |
| 117 | |
| Nils Diewald | 7cbcfe9 | 2014-09-22 22:01:51 +0000 | [diff] [blame] | 118 | public void setUID (String UID) { |
| 119 | if (UID != null) |
| 120 | this.UID = Integer.parseInt(UID); |
| 121 | }; |
| 122 | |
| 123 | |
| Nils Diewald | ff6f766 | 2014-09-21 15:08:52 +0000 | [diff] [blame] | 124 | @JsonProperty("UID") |
| 125 | public int getUID () { |
| 126 | return this.UID; |
| 127 | }; |
| 128 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 129 | public void setTitle (String title) { |
| 130 | this.title = title; |
| 131 | }; |
| 132 | |
| 133 | public String getTitle () { |
| 134 | return this.title; |
| 135 | }; |
| 136 | |
| 137 | public void setSubTitle (String subTitle) { |
| 138 | this.subTitle = subTitle; |
| 139 | }; |
| 140 | |
| 141 | public String getSubTitle () { |
| 142 | return this.subTitle; |
| 143 | }; |
| 144 | |
| 145 | @JsonIgnore |
| 146 | public void setPrimaryData (String primary) { |
| 147 | this.primaryData = new KorapPrimaryData(primary); |
| 148 | }; |
| 149 | |
| 150 | public void setPrimaryData (KorapPrimaryData primary) { |
| 151 | this.primaryData = primary; |
| 152 | }; |
| 153 | |
| 154 | public String getPrimaryData () { |
| 155 | if (this.primaryData == null) |
| 156 | return ""; |
| 157 | return this.primaryData.toString(); |
| 158 | }; |
| 159 | |
| 160 | public String getPrimaryData (int startOffset) { |
| 161 | return this.primaryData.substring(startOffset); |
| 162 | }; |
| 163 | |
| 164 | public String getPrimaryData (int startOffset, int endOffset) { |
| 165 | return this.primaryData.substring(startOffset, endOffset); |
| 166 | }; |
| 167 | |
| 168 | @JsonIgnore |
| 169 | public int getPrimaryDataLength () { |
| 170 | return this.primaryData.length(); |
| 171 | }; |
| Nils Diewald | 4972994 | 2013-11-27 20:30:07 +0000 | [diff] [blame] | 172 | |
| 173 | public void setFoundries (String foundries) { |
| 174 | this.foundries = foundries; |
| 175 | }; |
| 176 | |
| 177 | public String getFoundries () { |
| 178 | return this.foundries; |
| 179 | }; |
| 180 | |
| 181 | public void setTokenization (String tokenization) { |
| 182 | this.tokenization = tokenization; |
| 183 | }; |
| 184 | |
| 185 | public String getTokenization () { |
| 186 | return this.tokenization; |
| 187 | }; |
| Nils Diewald | 010c10f | 2013-12-17 01:58:31 +0000 | [diff] [blame] | 188 | |
| 189 | public void setLayerInfo (String layerInfo) { |
| 190 | this.layerInfo = layerInfo; |
| 191 | }; |
| 192 | |
| 193 | public String getLayerInfo () { |
| 194 | return this.layerInfo; |
| 195 | }; |
| Nils Diewald | 2cd1c3d | 2014-01-08 22:53:08 +0000 | [diff] [blame] | 196 | |
| 197 | public void setField (String field) { |
| 198 | this.field = field; |
| 199 | }; |
| 200 | |
| 201 | public String getField () { |
| 202 | return this.field; |
| 203 | }; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 204 | }; |