use of uk.ac.ebi.spot.goci.model.Author in project goci by EBISPOT.
the class EuropePMCDeserializer method getAuthorsInfo.
public ArrayList<Author> getAuthorsInfo(JsonNode info) {
ArrayList<Author> authors = new ArrayList<Author>();
JsonNode root = info.get("resultList").get("result").get(0);
Boolean noAuthor = true;
getLog().debug("Authors: ");
ArrayNode authorList = (ArrayNode) root.get("authorList").get("author");
for (JsonNode author : authorList) {
Author newAuthor = new Author();
String fullname;
if (author.has("collectiveName")) {
fullname = author.get("collectiveName").asText();
newAuthor.setFullname(fullname);
newAuthor.setFullnameStandart(Junidecode.unidecode(fullname));
} else {
noAuthor = false;
fullname = author.get("fullName").asText();
newAuthor.setFullname(fullname);
newAuthor.setFullnameStandart(Junidecode.unidecode(fullname));
newAuthor.setLastName(author.has("lastName") ? author.get("lastName").asText() : null);
newAuthor.setFirstName(author.has("firstName") ? author.get("firstName").asText() : null);
newAuthor.setInitials(author.has("initials") ? author.get("initials").asText() : null);
if (author.has("affiliation")) {
if (author.get("affiliation").asText().length() > 700) {
newAuthor.setAffiliation(author.get("affiliation").asText().substring(0, 699));
} else {
newAuthor.setAffiliation(author.get("affiliation").asText());
}
}
}
if (author.has("authorId")) {
newAuthor.setOrcid(author.get("authorId").get("value").asText());
}
authors.add(newAuthor);
}
// investigatorList
if (noAuthor) {
if (root.has("investigatorList")) {
getLog().debug("Investigator: ");
ArrayNode investigatorList = (ArrayNode) root.get("investigatorList").get("investigator");
for (JsonNode author : investigatorList) {
Author newAuthor = new Author();
String fullname = author.get("fullName").asText();
newAuthor.setFullname(fullname);
newAuthor.setFullnameStandart(Junidecode.unidecode(fullname));
newAuthor.setLastName(author.has("lastName") ? author.get("lastName").asText() : null);
newAuthor.setFirstName(author.has("firstName") ? author.get("firstName").asText() : null);
newAuthor.setInitials(author.has("initials") ? author.get("initials").asText() : null);
if (author.has("affiliation")) {
if (author.get("affiliation").asText().length() > 700) {
newAuthor.setAffiliation(author.get("affiliation").asText().substring(0, 699));
} else {
newAuthor.setAffiliation(author.get("affiliation").asText());
}
}
getLog().debug(newAuthor.getFullname());
if (author.has("authorId")) {
newAuthor.setOrcid(author.get("authorId").get("value").asText());
}
authors.add(newAuthor);
}
}
}
return authors;
}
use of uk.ac.ebi.spot.goci.model.Author in project goci by EBISPOT.
the class PublicationOperationsService method changeFirstAuthorByStudyId.
public Boolean changeFirstAuthorByStudyId(Long studyId, Long authorId) {
Boolean success = false;
Publication publication = publicationService.findByStudyId(studyId);
if (publication != null) {
Author author = authorService.findById(authorId);
if (author != null) {
publicationService.updatePublicationFirstAuthor(publication, author);
success = true;
}
}
return success;
}
use of uk.ac.ebi.spot.goci.model.Author in project goci by EBISPOT.
the class PublicationOperationsService method addFirstAuthorToPublication.
public void addFirstAuthorToPublication(Publication publication, EuropePMCData europePMCResult) {
Author firstAuthor = europePMCResult.getFirstAuthor();
Author firstAuthorDB = authorService.findUniqueAuthor(firstAuthor.getFullname(), firstAuthor.getFirstName(), firstAuthor.getLastName(), firstAuthor.getInitials(), firstAuthor.getAffiliation());
publication.setFirstAuthor(firstAuthorDB);
publicationService.save(publication);
}
use of uk.ac.ebi.spot.goci.model.Author in project goci by EBISPOT.
the class AuthorOperationsService method addAuthorsToPublication.
public void addAuthorsToPublication(Publication publication, EuropePMCData europePMCResult) {
Collection<Author> authorList = europePMCResult.getAuthors();
Integer order = 0;
for (Author author : authorList) {
Author authorDB = authorService.findUniqueAuthor(author.getFullname(), author.getFirstName(), author.getLastName(), author.getInitials(), author.getAffiliation());
order += 1;
if (authorDB == null) {
authorService.addPublication(author, publication, order);
} else {
authorService.addPublication(authorDB, publication, order);
}
}
}
use of uk.ac.ebi.spot.goci.model.Author in project goci by EBISPOT.
the class EuropePMCDeserializer method deserialize.
@Override
public EuropePMCData deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
EuropePMCData record = new EuropePMCData();
JsonNode node = jp.getCodec().readTree(jp);
// node.get("resultList");
if (node.get("resultList").get("result").size() > 0) {
JsonNode root = node.get("resultList").get("result").get(0);
record.setError(false);
record.setPublication(getPublicatonInfo(node));
ArrayList<Author> listAuthors = getAuthorsInfo(node);
record.setAuthors(listAuthors);
Author firstAuthor = listAuthors.get(0);
record.setFirstAuthor(firstAuthor);
if (root.get("doi") != null)
record.setDoi(root.get("doi").asText());
else
record.setDoi("");
} else {
record.setError(true);
}
System.out.println("Deserialize done");
return record;
}
Aggregations