Search in sources :

Example 1 with Author

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;
}
Also used : ArrayList(java.util.ArrayList) Author(uk.ac.ebi.spot.goci.model.Author) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with Author

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;
}
Also used : Publication(uk.ac.ebi.spot.goci.model.Publication) Author(uk.ac.ebi.spot.goci.model.Author)

Example 3 with Author

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);
}
Also used : Author(uk.ac.ebi.spot.goci.model.Author)

Example 4 with Author

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);
        }
    }
}
Also used : Author(uk.ac.ebi.spot.goci.model.Author)

Example 5 with Author

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;
}
Also used : Author(uk.ac.ebi.spot.goci.model.Author) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

Author (uk.ac.ebi.spot.goci.model.Author)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ArrayList (java.util.ArrayList)1 Publication (uk.ac.ebi.spot.goci.model.Publication)1