use of edu.uci.ics.texera.dataflow.resource.dictionary.DictionaryManager in project textdb by TextDB.
the class FileUploadResource method uploadDictionaryFile.
@POST
@Path("/dictionary")
public TexeraWebResponse uploadDictionaryFile(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) throws Exception {
StringBuilder dictionary = new StringBuilder();
String line = "";
try (BufferedReader br = new BufferedReader(new InputStreamReader(uploadedInputStream))) {
while ((line = br.readLine()) != null) {
dictionary.append(line);
}
} catch (IOException e) {
throw new TexeraWebException("Error occurred whlie uploading dictionary");
}
String fileName = fileDetail.getFileName();
// save the dictionary
DictionaryManager dictionaryManager = DictionaryManager.getInstance();
dictionaryManager.addDictionary(fileName, dictionary.toString());
return new TexeraWebResponse(0, "Dictionary is uploaded");
}
use of edu.uci.ics.texera.dataflow.resource.dictionary.DictionaryManager in project textdb by TextDB.
the class SystemResource method getDictionary.
/**
* Get the content of dictionary
*/
@GET
@Path("/dictionary")
public TexeraWebResponse getDictionary(@QueryParam("name") String name) {
DictionaryManager dictionaryManager = DictionaryManager.getInstance();
String dictionaryContent = dictionaryManager.getDictionary(name);
return new TexeraWebResponse(0, dictionaryContent);
}
use of edu.uci.ics.texera.dataflow.resource.dictionary.DictionaryManager in project textdb by TextDB.
the class SystemResource method getDictionaries.
/**
* Get the list of dictionaries
*/
@GET
@Path("/dictionaries")
public TexeraWebResponse getDictionaries() throws StorageException, JsonProcessingException {
DictionaryManager dictionaryManager = DictionaryManager.getInstance();
List<String> dictionaries = dictionaryManager.getDictionaries();
return new TexeraWebResponse(0, new ObjectMapper().writeValueAsString(dictionaries));
}
Aggregations