Search in sources :

Example 1 with WorkExternalIdentifier

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

the class T2OrcidApiServiceDelegatorTest method testAddWorkToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddWorkToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWork work = new OrcidWork();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("Title"));
    work.setWorkTitle(title);
    WorkExternalIdentifiers weis = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("00000001"));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    weis.getWorkExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) 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) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with WorkExternalIdentifier

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewWork.

@Test
@Transactional
public void testUpdateWithNewWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Added by works update"));
    orcidWork.setWorkTitle(workTitle);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
    workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
    assertNotNull(response);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
    List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
    boolean foundWorkFromAnotherSource = false;
    boolean foundExisting = false;
    boolean foundNew = false;
    boolean foundExistingPrivate = false;
    // another source
    for (OrcidWork retrievedWork : retreivedWorksList) {
        if ("6".equals(retrievedWork.getPutCode())) {
            assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
            foundWorkFromAnotherSource = true;
        } else if ("7".equals(retrievedWork.getPutCode())) {
            // Existing private work
            assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExisting = true;
        } else if ("8".equals(retrievedWork.getPutCode())) {
            // Existing private work added by the user
            assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExistingPrivate = true;
        } else {
            // The added work
            assertEquals("Added by works update", retrievedWork.getWorkTitle().getTitle().getContent());
            foundNew = true;
        }
    }
    assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
    assertTrue("New work should be there", foundNew);
    assertTrue("Existing private work should be there", foundExisting);
    assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
    assertEquals(4, retreivedWorksList.size());
}
Also used : 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) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with WorkExternalIdentifier

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWorkWhenNotSource.

@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateWorkWhenNotSource() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    orcidWork.setPutCode("6");
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Updated by works update"));
    orcidWork.setWorkTitle(workTitle);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
    workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) 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) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with WorkExternalIdentifier

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

the class OrcidProfileManagerBaseTest method createWork1Identifiers.

protected WorkExternalIdentifiers createWork1Identifiers() {
    WorkExternalIdentifiers work1ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work1ExternalIdentifier1 = new WorkExternalIdentifier();
    work1ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work1ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-doi1"));
    WorkExternalIdentifier work1ExternalIdentifier2 = new WorkExternalIdentifier();
    work1ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    work1ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
    WorkExternalIdentifier work1ExternalIdentifier3 = new WorkExternalIdentifier();
    work1ExternalIdentifier3.setWorkExternalIdentifierType(WorkExternalIdentifierType.SOURCE_WORK_ID);
    work1ExternalIdentifier3.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-source-id"));
    work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier1);
    work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier2);
    work1ExternalIdentifiers.getWorkExternalIdentifier().add(work1ExternalIdentifier3);
    return work1ExternalIdentifiers;
}
Also used : WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Example 5 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier 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)

Aggregations

WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)28 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)20 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)19 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)15 Title (org.orcid.jaxb.model.message.Title)13 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)12 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)10 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)10 Test (org.junit.Test)9 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)8 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)7 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)6 Source (org.orcid.jaxb.model.message.Source)5 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)4 WorkExternalIdentifierType (org.orcid.jaxb.model.message.WorkExternalIdentifierType)4 DBUnitTest (org.orcid.test.DBUnitTest)4 Transactional (org.springframework.transaction.annotation.Transactional)4 ArrayList (java.util.ArrayList)3 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)3 Email (org.orcid.jaxb.model.message.Email)3