Search in sources :

Example 11 with WorkTitle

use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testCheckWorkExternalIdentifiersAreNotDuplicated3.

@Test
@Transactional
public void testCheckWorkExternalIdentifiersAreNotDuplicated3() {
    List<OrcidWork> newOrcidWorksList = new ArrayList<OrcidWork>();
    List<OrcidWork> existingWorkList = new ArrayList<OrcidWork>();
    OrcidWork newWork1 = getOrcidWork("work1", false);
    OrcidWork newWork2 = getOrcidWork("work2", false);
    OrcidWork newWork3 = getOrcidWork("work3", false);
    OrcidWork newWork3_fixed = getOrcidWork("work3", false);
    WorkTitle updatedTitle = new WorkTitle();
    updatedTitle.setTitle(new Title("updated title"));
    newWork3_fixed.setWorkTitle(updatedTitle);
    //Check #3: Check duplicates in new works
    newOrcidWorksList.add(newWork1);
    newOrcidWorksList.add(newWork2);
    newOrcidWorksList.add(newWork3);
    newOrcidWorksList.add(newWork3_fixed);
    try {
        orcidProfileManager.checkWorkExternalIdentifiersAreNotDuplicated(newOrcidWorksList, existingWorkList);
        fail();
    } catch (IllegalArgumentException iae) {
        assertEquals("Works \"Title for work3->updated\" and \"updated title\" have the same external id \"doi-work3\"", iae.getMessage());
    }
}
Also used : WorkTitle(org.orcid.jaxb.model.message.WorkTitle) ArrayList(java.util.ArrayList) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with WorkTitle

use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.

the class Api12Helper method addWork.

protected static void addWork(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
    String id = String.valueOf(System.currentTimeMillis());
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    orcidWork.setWorkType(WorkType.JOURNAL_ARTICLE);
    orcidWork.setVisibility(Visibility.LIMITED);
    WorkTitle workTitle = new WorkTitle();
    orcidWork.setWorkTitle(workTitle);
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId(id));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
    extIds.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(extIds);
    workTitle.setTitle(new Title(title));
    ClientResponse clientResponse = oauthT2Client.addWorksXml(userOrcid, orcidMessage, token);
    assertEquals(201, clientResponse.getStatus());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 13 with WorkTitle

use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method getWorkEntity.

public WorkEntity getWorkEntity(OrcidWork orcidWork, WorkEntity workEntity) {
    if (orcidWork != null) {
        if (workEntity == null) {
            String putCode = orcidWork.getPutCode();
            if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
                throw new IllegalArgumentException("Invalid put-code was supplied: " + putCode);
            }
            workEntity = new WorkEntity();
        } else {
            workEntity.clean();
        }
        Citation workCitation = orcidWork.getWorkCitation();
        if (workCitation != null && StringUtils.isNotBlank(workCitation.getCitation()) && workCitation.getWorkCitationType() != null) {
            workEntity.setCitation(workCitation.getCitation());
            workEntity.setCitationType(CitationType.fromValue(workCitation.getWorkCitationType().value()));
        }
        // New way of doing work contributors
        workEntity.setContributorsJson(getWorkContributorsJson(orcidWork.getWorkContributors()));
        workEntity.setDescription(orcidWork.getShortDescription() != null ? orcidWork.getShortDescription() : null);
        // New way of doing work external ids
        workEntity.setExternalIdentifiersJson(getWorkExternalIdsJson(orcidWork));
        workEntity.setPublicationDate(getWorkPublicationDate(orcidWork));
        WorkTitle workTitle = orcidWork.getWorkTitle();
        if (workTitle != null) {
            workEntity.setSubtitle(workTitle.getSubtitle() != null ? workTitle.getSubtitle().getContent() : null);
            workEntity.setTitle(workTitle.getTitle() != null ? workTitle.getTitle().getContent().trim() : null);
            TranslatedTitle translatedTitle = workTitle.getTranslatedTitle();
            if (translatedTitle != null) {
                workEntity.setTranslatedTitle(StringUtils.isEmpty(translatedTitle.getContent()) ? null : translatedTitle.getContent());
                workEntity.setTranslatedTitleLanguageCode(StringUtils.isEmpty(translatedTitle.getLanguageCode()) ? null : translatedTitle.getLanguageCode());
            }
        }
        workEntity.setJournalTitle(orcidWork.getJournalTitle() != null ? orcidWork.getJournalTitle().getContent() : null);
        workEntity.setLanguageCode(orcidWork.getLanguageCode() != null ? orcidWork.getLanguageCode() : null);
        if (orcidWork.getCountry() != null && orcidWork.getCountry().getValue() != null) {
            workEntity.setIso2Country(org.orcid.jaxb.model.common_v2.Iso3166Country.fromValue(orcidWork.getCountry().getValue().value()));
        }
        workEntity.setWorkUrl(orcidWork.getUrl() != null ? orcidWork.getUrl().getValue() : null);
        if (orcidWork.getWorkType() != null) {
            workEntity.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.fromValue(orcidWork.getWorkType().value()));
        }
        if (orcidWork.getVisibility() != null) {
            workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(orcidWork.getVisibility().value()));
        } else {
            workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
        }
        workEntity.setAddedToProfileDate(new Date());
        //Set source
        setSource(orcidWork.getSource(), workEntity);
        if (workEntity.getDisplayIndex() == null) {
            workEntity.setDisplayIndex(0L);
        }
        return workEntity;
    }
    return null;
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) TranslatedTitle(org.orcid.jaxb.model.message.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Citation(org.orcid.jaxb.model.message.Citation) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) PublicationDate(org.orcid.jaxb.model.message.PublicationDate) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate)

Example 14 with WorkTitle

use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.

the class OrcidIndexManagerImplTest method getStandardOrcid.

private OrcidProfile getStandardOrcid() {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier("1234");
    OrcidBio orcidBio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    Email email = new Email("email");
    email.setVisibility(Visibility.PUBLIC);
    contactDetails.addOrReplacePrimaryEmail(email);
    orcidBio.setContactDetails(contactDetails);
    Keywords bioKeywords = new Keywords();
    bioKeywords.getKeyword().add(new Keyword("Pavement Studies", Visibility.PUBLIC));
    bioKeywords.getKeyword().add(new Keyword("Advanced Tea Making", Visibility.PUBLIC));
    bioKeywords.setVisibility(Visibility.PUBLIC);
    orcidBio.setKeywords(bioKeywords);
    PersonalDetails personalDetails = new PersonalDetails();
    CreditName creditName = new CreditName("credit name");
    creditName.setVisibility(Visibility.PUBLIC);
    personalDetails.setCreditName(creditName);
    FamilyName familyName = new FamilyName("familyName");
    familyName.setVisibility(Visibility.PUBLIC);
    personalDetails.setFamilyName(familyName);
    OtherNames otherNames = new OtherNames();
    otherNames.setVisibility(Visibility.PUBLIC);
    otherNames.getOtherName().add(new OtherName("Other 1", Visibility.PUBLIC));
    otherNames.getOtherName().add(new OtherName("Other 2", Visibility.PUBLIC));
    personalDetails.setOtherNames(otherNames);
    GivenNames givenNames = new GivenNames("givenNames");
    givenNames.setVisibility(Visibility.PUBLIC);
    personalDetails.setGivenNames(givenNames);
    orcidBio.setPersonalDetails(personalDetails);
    ExternalIdentifiers externalIdentifiers = new ExternalIdentifiers();
    externalIdentifiers.setVisibility(Visibility.PUBLIC);
    orcidBio.setExternalIdentifiers(externalIdentifiers);
    ExternalIdentifier externalIdentifier1 = createExternalIdentifier("45678", "defghi");
    externalIdentifiers.getExternalIdentifier().add(externalIdentifier1);
    ExternalIdentifier externalIdentifier2 = createExternalIdentifier("54321", "abc123");
    externalIdentifiers.getExternalIdentifier().add(externalIdentifier2);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    FundingList fundings = new FundingList();
    orcidActivities.setFundings(fundings);
    OrcidWorks orcidWorks = new OrcidWorks();
    OrcidWork orcidWork1 = new OrcidWork();
    orcidWork1.setVisibility(Visibility.PUBLIC);
    OrcidWork orcidWork2 = new OrcidWork();
    orcidWork2.setVisibility(Visibility.PUBLIC);
    OrcidWork orcidWork3 = new OrcidWork();
    orcidWork3.setVisibility(Visibility.LIMITED);
    WorkTitle workTitle1 = new WorkTitle();
    Title title1 = new Title("Work title 1");
    workTitle1.setTitle(title1);
    workTitle1.setSubtitle(null);
    orcidWork1.setWorkTitle(workTitle1);
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    orcidWork1.setWorkExternalIdentifiers(new WorkExternalIdentifiers(Arrays.asList(wei)));
    WorkTitle workTitle2 = new WorkTitle();
    Title title2 = new Title("Work title 2");
    workTitle2.setSubtitle(null);
    workTitle2.setTitle(title2);
    orcidWork2.setWorkTitle(workTitle2);
    WorkTitle workTitle3 = new WorkTitle();
    Title title3 = new Title("Work Title 3");
    workTitle3.setSubtitle(null);
    workTitle3.setTitle(title3);
    orcidWork3.setWorkTitle(workTitle3);
    orcidWorks.setOrcidWork(new ArrayList<OrcidWork>(Arrays.asList(new OrcidWork[] { orcidWork1, orcidWork2, orcidWork3 })));
    orcidProfile.setOrcidWorks(orcidWorks);
    orcidProfile.setOrcidBio(orcidBio);
    return orcidProfile;
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Keyword(org.orcid.jaxb.model.message.Keyword) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Example 15 with WorkTitle

use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPublic.

@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsPublic() {
    OrcidProfile profile1 = createBasicProfile();
    OrcidHistory history = new OrcidHistory();
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile1.setOrcidHistory(history);
    history.setClaimed(new Claimed(true));
    profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(TEST_ORCID);
    OrcidWorks orcidWorks = new OrcidWorks();
    profile2.setOrcidWorks(orcidWorks);
    WorkTitle workTitle1 = new WorkTitle();
    workTitle1.setTitle(new Title("Another Title"));
    workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
    OrcidWork work1 = createWork1(workTitle1);
    Source source = new Source(TEST_ORCID);
    work1.setSource(source);
    orcidWorks.getOrcidWork().add(work1);
    WorkTitle workTitle2 = new WorkTitle();
    workTitle2.setTitle(new Title("New Title"));
    workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
    OrcidWork work2 = createWork2(workTitle2);
    orcidWorks.getOrcidWork().add(work2);
    // Try to add a duplicate
    WorkTitle workTitle3 = new WorkTitle();
    workTitle3.setTitle(new Title("Further Title"));
    workTitle3.setSubtitle(new Subtitle("Further subtitle"));
    OrcidWork work3 = createWork3(workTitle3);
    work3.setVisibility(Visibility.LIMITED);
    orcidWorks.getOrcidWork().add(work3);
    orcidProfileManager.addOrcidWorks(profile2);
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
    assertEquals(4, works.size());
    assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
    assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
    for (OrcidWork work : works) {
        if ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
            assertEquals(Visibility.PRIVATE, work.getVisibility());
        else
            assertEquals(Visibility.PUBLIC, work.getVisibility());
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Claimed(org.orcid.jaxb.model.message.Claimed) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

WorkTitle (org.orcid.jaxb.model.message.WorkTitle)22 Title (org.orcid.jaxb.model.message.Title)21 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)18 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)16 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)13 Test (org.junit.Test)12 Subtitle (org.orcid.jaxb.model.message.Subtitle)11 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)10 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)10 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)10 Transactional (org.springframework.transaction.annotation.Transactional)10 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 Source (org.orcid.jaxb.model.message.Source)6 Date (java.util.Date)5 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)5 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)5 Rollback (org.springframework.test.annotation.Rollback)5 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)4 Claimed (org.orcid.jaxb.model.message.Claimed)4