| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 1 | package de.ids_mannheim.korap.plkexport; |
| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 2 | |
| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 3 | import com.fasterxml.jackson.databind.JsonNode; |
| 4 | import javax.ws.rs.core.Response; |
| 5 | import javax.ws.rs.core.Response.ResponseBuilder; |
| 6 | import java.io.IOException; |
| 7 | import java.io.Writer; |
| Akron | af145eb | 2020-11-24 16:55:47 +0100 | [diff] [blame] | 8 | import org.glassfish.jersey.media.sse.EventOutput; |
| Akron | b91c303 | 2020-11-23 19:24:40 +0100 | [diff] [blame] | 9 | |
| Akron | 984fe8f | 2020-11-25 15:21:37 +0100 | [diff] [blame] | 10 | /** |
| 11 | * Exporter interface every exporter needs to satisfy. |
| 12 | */ |
| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 13 | interface Exporter { |
| 14 | |
| 15 | // Implemented by MatchAggregator |
| Akron | 62d90a3 | 2020-11-18 20:45:38 +0100 | [diff] [blame] | 16 | public boolean init (String s) throws IOException; |
| Akron | 3588101 | 2020-11-24 20:05:06 +0100 | [diff] [blame] | 17 | public Exporter finish () throws IOException; |
| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 18 | public void setMeta(JsonNode n); |
| 19 | public void setQuery(JsonNode n); |
| 20 | public void setCollection(JsonNode n); |
| Akron | eedac91 | 2020-11-16 12:54:42 +0100 | [diff] [blame] | 21 | public JsonNode getMeta(); |
| 22 | public JsonNode getQuery(); |
| 23 | public JsonNode getCollection(); |
| Akron | 62d90a3 | 2020-11-18 20:45:38 +0100 | [diff] [blame] | 24 | public boolean appendMatches (String s) throws IOException; |
| Akron | 7412271 | 2020-11-17 09:41:21 +0100 | [diff] [blame] | 25 | public String getFileName (); |
| 26 | public void setFileName (String s); |
| Akron | 3588101 | 2020-11-24 20:05:06 +0100 | [diff] [blame] | 27 | public void setFile (String id); |
| Akron | 7412271 | 2020-11-17 09:41:21 +0100 | [diff] [blame] | 28 | public String getQueryString (); |
| 29 | public void setQueryString (String s); |
| Akron | d2072ee | 2020-11-17 16:12:41 +0100 | [diff] [blame] | 30 | public String getCorpusQueryString (); |
| 31 | public void setCorpusQueryString (String s); |
| Akron | 820dc64 | 2020-11-19 13:11:50 +0100 | [diff] [blame] | 32 | public String getSource (); |
| 33 | public void setSource (String h, String p); |
| Akron | 5405dec | 2020-11-26 20:39:24 +0100 | [diff] [blame^] | 34 | public void setSource (String v); |
| Akron | c1c1824 | 2020-11-18 18:24:12 +0100 | [diff] [blame] | 35 | public int getTotalResults (); |
| 36 | public boolean hasTimeExceeded (); |
| Akron | 62d90a3 | 2020-11-18 20:45:38 +0100 | [diff] [blame] | 37 | public void setMaxResults (int m); |
| Akron | af145eb | 2020-11-24 16:55:47 +0100 | [diff] [blame] | 38 | public void setSse (EventOutput sse); |
| Akron | 3588101 | 2020-11-24 20:05:06 +0100 | [diff] [blame] | 39 | public void forceFile (); |
| 40 | public String getExportID (); |
| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 41 | public ResponseBuilder serve(); |
| 42 | |
| 43 | // Needs to be overwritten |
| 44 | public void writeHeader (Writer w) throws IOException; |
| 45 | public void addMatch (JsonNode n, Writer w) throws IOException; |
| 46 | public void writeFooter (Writer w) throws IOException; |
| Akron | e57937b | 2020-11-17 08:49:31 +0100 | [diff] [blame] | 47 | public String getMimeType (); |
| 48 | public String getSuffix (); |
| Akron | 8154dbe | 2020-11-13 17:52:53 +0100 | [diff] [blame] | 49 | }; |