blob: c779cc15da3eab65be6ff7d62671e36214f77d34 [file] [log] [blame]
Akron8154dbe2020-11-13 17:52:53 +01001package de.ids_mannheim.korap.plkexport;
Akron984fe8f2020-11-25 15:21:37 +01002
Akron8154dbe2020-11-13 17:52:53 +01003import com.fasterxml.jackson.databind.JsonNode;
4import javax.ws.rs.core.Response;
5import javax.ws.rs.core.Response.ResponseBuilder;
6import java.io.IOException;
7import java.io.Writer;
Akronaf145eb2020-11-24 16:55:47 +01008import org.glassfish.jersey.media.sse.EventOutput;
Akronb91c3032020-11-23 19:24:40 +01009
Akron984fe8f2020-11-25 15:21:37 +010010/**
11 * Exporter interface every exporter needs to satisfy.
12 */
Akron8154dbe2020-11-13 17:52:53 +010013interface Exporter {
14
15 // Implemented by MatchAggregator
Akron62d90a32020-11-18 20:45:38 +010016 public boolean init (String s) throws IOException;
Akron35881012020-11-24 20:05:06 +010017 public Exporter finish () throws IOException;
Akron8154dbe2020-11-13 17:52:53 +010018 public void setMeta(JsonNode n);
19 public void setQuery(JsonNode n);
20 public void setCollection(JsonNode n);
Akroneedac912020-11-16 12:54:42 +010021 public JsonNode getMeta();
22 public JsonNode getQuery();
23 public JsonNode getCollection();
Akron62d90a32020-11-18 20:45:38 +010024 public boolean appendMatches (String s) throws IOException;
Akron74122712020-11-17 09:41:21 +010025 public String getFileName ();
26 public void setFileName (String s);
Akron35881012020-11-24 20:05:06 +010027 public void setFile (String id);
Akron74122712020-11-17 09:41:21 +010028 public String getQueryString ();
29 public void setQueryString (String s);
Akrond2072ee2020-11-17 16:12:41 +010030 public String getCorpusQueryString ();
31 public void setCorpusQueryString (String s);
Akron820dc642020-11-19 13:11:50 +010032 public String getSource ();
33 public void setSource (String h, String p);
Akron5405dec2020-11-26 20:39:24 +010034 public void setSource (String v);
Akronc1c18242020-11-18 18:24:12 +010035 public int getTotalResults ();
36 public boolean hasTimeExceeded ();
Akron62d90a32020-11-18 20:45:38 +010037 public void setMaxResults (int m);
Akronaf145eb2020-11-24 16:55:47 +010038 public void setSse (EventOutput sse);
Akron35881012020-11-24 20:05:06 +010039 public void forceFile ();
40 public String getExportID ();
Akron8154dbe2020-11-13 17:52:53 +010041 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;
Akrone57937b2020-11-17 08:49:31 +010047 public String getMimeType ();
48 public String getSuffix ();
Akron8154dbe2020-11-13 17:52:53 +010049};