use of uk.ac.ebi.spot.goci.model.PublishedStudy in project goci by EBISPOT.
the class ReleaseSummaryEmail method createBody.
public void createBody(List<PublishedStudy> studies) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String today = df.format(date);
this.setSubject("Studies added to the Solr index on " + today);
if (studies.size() != 0) {
this.setBody("The following studies were added to the Solr index on " + today + "\n");
for (PublishedStudy s : studies) {
StringBuilder line = new StringBuilder();
line.append(s.getAuthor());
line.append(" (");
line.append(s.getPubmedId());
line.append(") - ");
line.append(s.getTitle());
line.append(" (");
line.append(s.getPublicationDate());
line.append(", ");
line.append(s.getJournal());
line.append("); ");
line.append(s.getAssociationCount());
line.append(" associations.\n");
line.append("\n");
this.addToBody(line.toString());
}
} else {
this.setBody("No studies were added to the Solr index on " + today + "\n");
}
}
use of uk.ac.ebi.spot.goci.model.PublishedStudy in project goci by EBISPOT.
the class SolrDataProcessingService method processJson.
public List<PublishedStudy> processJson() throws IOException {
List<PublishedStudy> studies = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readTree(json);
JsonNode responseNode = node.get("response");
JsonNode docs = responseNode.get("docs");
for (JsonNode doc : docs) {
PublishedStudy study = processStudyJson(doc);
studies.add(study);
}
return studies;
}
use of uk.ac.ebi.spot.goci.model.PublishedStudy in project goci by EBISPOT.
the class SolrQueryService method processSolrResult.
public List<PublishedStudy> processSolrResult(HttpEntity entity) throws IOException {
List<PublishedStudy> studies = new ArrayList<>();
BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
String output;
while ((output = br.readLine()) != null) {
SolrDataProcessingService jsonProcessor = new SolrDataProcessingService(output);
studies = jsonProcessor.processJson();
}
EntityUtils.consume(entity);
return studies;
}
use of uk.ac.ebi.spot.goci.model.PublishedStudy in project goci by EBISPOT.
the class SolrQueryService method querySolr.
// public HttpEntity querySolr(String searchString) throws IOException{
public List<PublishedStudy> querySolr(String searchString) throws IOException {
System.out.println(searchString);
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(searchString);
if (System.getProperty("http.proxyHost") != null) {
HttpHost proxy;
if (System.getProperty("http.proxyPort") != null) {
proxy = new HttpHost(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort")));
} else {
proxy = new HttpHost(System.getProperty("http.proxyHost"));
}
httpGet.setConfig(RequestConfig.custom().setProxy(proxy).build());
}
// HttpEntity entity = null;
List<PublishedStudy> studies = new ArrayList<>();
try (CloseableHttpResponse response = httpclient.execute(httpGet)) {
getLog().debug("Received HTTP response: " + response.getStatusLine().toString());
HttpEntity entity = response.getEntity();
BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent()));
String output;
while ((output = br.readLine()) != null) {
SolrDataProcessingService jsonProcessor = new SolrDataProcessingService(output);
studies = jsonProcessor.processJson();
}
EntityUtils.consume(entity);
}
// return entity;
return studies;
}
Aggregations