use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.
the class EuropePMCDeserializer method getPublicatonInfo.
public Publication getPublicatonInfo(JsonNode info) {
Publication publication = new Publication();
JsonNode root = info.get("resultList").get("result").get(0);
System.out.println("Publication");
publication.setPubmedId(root.get("pmid").asText());
// publication.setPublicationDate(root.get("firstPublicationDate").asText());
publication.setPublication(root.get("journalInfo").get("journal").get("medlineAbbreviation").asText());
publication.setTitle(root.get("title").asText());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
/**
* Priority to eletronicDate. *
*/
String datePublication = "";
if (root.has("electronicPublicationDate")) {
datePublication = root.get("electronicPublicationDate").asText();
} else {
if (root.get("journalInfo").has("printPublicationDate")) {
datePublication = root.get("journalInfo").get("printPublicationDate").asText();
}
}
if (datePublication.contains("/")) {
datePublication = datePublication.replace("/", "-");
}
java.util.Date studyDate = null;
try {
studyDate = format.parse(datePublication);
} catch (ParseException e1) {
e1.printStackTrace();
}
publication.setPublicationDate(new Date(studyDate.getTime()));
return publication;
}
use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.
the class CurationSystemEmailToCurator method createBody.
public void createBody(Study study, String status) {
// Set up some of the values used in mail body
Publication publication = study.getPublicationId();
String studyTitle = publication.getTitle();
String pubmedLink = "http://europepmc.org/abstract/MED/" + publication.getPubmedId();
String currentCurator = study.getHousekeeping().getCurator().getLastName();
// These could be null so catch this case
String studyTrait = null;
if (study.getDiseaseTrait() != null && !study.getDiseaseTrait().getTrait().isEmpty()) {
studyTrait = study.getDiseaseTrait().getTrait();
}
StringBuilder notes = new StringBuilder();
Collection<StudyNote> studyNotes = study.getNotes();
if (!studyNotes.isEmpty()) {
studyNotes.forEach(studyNote -> {
notes.append(studyNote.toStringForEamil()).append("\n");
notes.append("-------------------------------------------------------------\n\n");
});
}
// Format dates
Date studyDate = publication.getPublicationDate();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
String bodyStudyDate = dateFormat.format(studyDate);
Date publishDate = study.getHousekeeping().getCatalogPublishDate();
String bodyPublishDate = null;
if (publishDate != null) {
bodyPublishDate = dateFormat.format(publishDate);
}
String editStudyLink = getLink() + "studies/" + study.getId();
this.setSubject(publication.getFirstAuthor().getFullnameShort(50) + " - " + status);
this.setBody("The GWAS paper by " + publication.getFirstAuthor().getFullname() + " with study date " + bodyStudyDate + " now has status " + status + "\n" + "Title: " + studyTitle + "\n" + "Trait: " + studyTrait + "\n" + "Pubmed link: " + pubmedLink + "\n" + "Edit link: " + editStudyLink + "\n" + "Current curator: " + currentCurator + "\n" + "Publish Date: " + bodyPublishDate + "\n" + "Notes: \n" + notes + "\n\n");
}
use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.
the class PussycatGOCIController method setDateFilter.
private Filter setDateFilter(String dateMin, String dateMax) {
Filter dateFilter;
DateFormat df_input = new SimpleDateFormat("yyyy-MM-dd");
Date to, from;
try {
if (dateMax != null) {
int endYearVar = Integer.parseInt(dateMax.split("-")[0]);
int endMonthVar = Integer.parseInt(dateMax.split("-")[1]);
String end_month, end_year;
// API call provides date for "up to and including the end of" - must increment month for query
if (endMonthVar == 12) {
end_month = "01";
endYearVar++;
end_year = Integer.toString(endYearVar);
} else {
endMonthVar++;
if (endMonthVar > 9) {
end_month = Integer.toString(endMonthVar);
} else {
end_month = "0".concat(Integer.toString(endMonthVar));
}
end_year = Integer.toString(endYearVar);
}
to = df_input.parse(end_year + "-" + end_month + "-01");
} else {
// change to use today's date
to = df_input.parse(df_input.format(new Date()));
}
if (dateMin != null) {
from = df_input.parse(dateMin + "-01");
} else {
from = df_input.parse("2005-01-01");
}
Calendar fromValue = Calendar.getInstance();
fromValue.setTime(from);
Calendar toValue = Calendar.getInstance();
toValue.setTime(to);
// Study study = template(Study.class);
// dateFilter = refine(study).on(study.getPublicationId().getPublicationDate()).hasRange(fromValue, toValue);
Publication publication = template(Publication.class);
dateFilter = refine(publication).on(publication.getPublicationDate()).hasRange(fromValue, toValue);
} catch (ParseException e) {
getLog().error("Bad date in URL for date range '" + dateMin + "' to '" + dateMax, e);
throw new RuntimeException("Bad date in URL for date range '" + dateMin + "' to '" + dateMax, e);
}
return dateFilter;
}
use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.
the class DataDeletionService method deleteStudy.
private void deleteStudy(Study study) {
System.out.println("Removing study \t" + study.getPublicationId().getFirstAuthor().getFullname() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
getLog().debug("Removing study \t" + study.getPublicationId().getFirstAuthor().getFullname() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
// THOR - Don't delete the publication and Author - OR check if there is just a publication.
Long publicationId = study.getPublicationId().getId();
study.setPublicationId(null);
studyService.setPublicationIdNull(study.getId());
Collection<Association> associations = study.getAssociations();
associations.forEach(this::deleteAssociation);
Collection<Ancestry> ancestries = ancestryRepository.findByStudyId(study.getId());
for (Ancestry ancestry : ancestries) {
ancestryRepository.delete(ancestry);
}
// WeeklyTracking, CuratorTracking and Note. Please use this method!
// Shared with === DataDeletionService ===
studyService.deleteRelatedInfoByStudy(study);
// Delete study
studyService.deleteByStudyId(study.getId());
// THOR - delete the publication if there are no studies related
Publication publication = publicationService.deepFindPublicationbyId(publicationId);
if (publication.getStudies().size() == 0) {
publicationAuthorsService.deleteByPublication(publication);
Boolean delete = publicationService.deletePublication(publication);
}
}
use of uk.ac.ebi.spot.goci.model.Publication in project goci by EBISPOT.
the class PublicationOperationsService method importSinglePublication.
public Publication importSinglePublication(String pubmedId, Boolean newImport) throws PubmedLookupException {
Publication addedPublication = null;
try {
EuropePMCData europePMCResult = europepmcPubMedSearchService.createStudyByPubmed(pubmedId);
addedPublication = addPublication(pubmedId, europePMCResult, newImport);
} catch (Exception exception) {
throw new PubmedLookupException(exception.getCause().getMessage());
}
return addedPublication;
}
Aggregations