Search in sources :

Example 41 with OrcidWorks

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

the class OrcidProfileManagerImplTest method getWorkInsideOrcidProfile.

private OrcidProfile getWorkInsideOrcidProfile(String defaultTitle, String orcid) {
    OrcidWork orcidWork = new OrcidWork();
    // Set title
    WorkTitle title = new WorkTitle();
    if (defaultTitle != null)
        title.setTitle(new Title(defaultTitle));
    else
        title.setTitle(new Title("Title"));
    orcidWork.setWorkTitle(title);
    // Set external identifiers
    WorkExternalIdentifier extId1 = new WorkExternalIdentifier();
    extId1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("doi-" + defaultTitle));
    extId1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    WorkExternalIdentifier extId2 = new WorkExternalIdentifier();
    if (defaultTitle != null)
        extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + defaultTitle));
    else
        extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + System.currentTimeMillis()));
    extId2.setWorkExternalIdentifierType(WorkExternalIdentifierType.ISSN);
    WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
    extIds.getWorkExternalIdentifier().add(extId1);
    extIds.getWorkExternalIdentifier().add(extId2);
    orcidWork.setWorkExternalIdentifiers(extIds);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    OrcidProfile profile = new OrcidProfile();
    profile.setOrcidIdentifier(orcid);
    List<OrcidWork> workList = new ArrayList<OrcidWork>();
    workList.add(orcidWork);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidWorks.setOrcidWork(workList);
    profile.setOrcidWorks(orcidWorks);
    return profile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) ArrayList(java.util.ArrayList) 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) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 42 with OrcidWorks

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

the class OrcidProfileManagerImpl_NonTransactionalTest method addDataToTestRecord.

private void addDataToTestRecord() {
    OrcidProfile profile1 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    OrcidWork work1 = createWork1();
    profile1.setOrcidActivities(new OrcidActivities());
    profile1.getOrcidActivities().setOrcidWorks(new OrcidWorks());
    profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
    orcidProfileManager.updateOrcidProfile(profile1);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Example 43 with OrcidWorks

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

the class OrcidProfileManagerImpl_NonTransactionalTest method testAddOrcidWorkToUnclaimedProfile.

@Test
public void testAddOrcidWorkToUnclaimedProfile() {
    String orcid = "0000-0000-0000-0003";
    OrcidProfile profile1 = createBasicProfile();
    profile1.setOrcidIdentifier(orcid);
    profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(orcid);
    OrcidWorks orcidWorks = new OrcidWorks();
    profile2.setOrcidWorks(orcidWorks);
    OrcidWork work1 = createWork1();
    work1.setVisibility(Visibility.PUBLIC);
    orcidWorks.getOrcidWork().add(work1);
    OrcidWork work2 = createWork2();
    work2.setVisibility(Visibility.LIMITED);
    orcidWorks.getOrcidWork().add(work2);
    OrcidWork work3 = createWork3();
    work3.setVisibility(Visibility.PRIVATE);
    orcidWorks.getOrcidWork().add(work3);
    orcidProfileManager.addOrcidWorks(profile2);
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
    assertEquals(3, resultProfile.retrieveOrcidWorks().getOrcidWork().size());
    for (OrcidWork work : resultProfile.retrieveOrcidWorks().getOrcidWork()) {
        if ("Test Title".equals(work.getWorkTitle().getTitle().getContent())) {
            assertEquals(Visibility.PUBLIC, work.getVisibility());
        } else if ("Test Title # 2".equals(work.getWorkTitle().getTitle().getContent())) {
            assertEquals(Visibility.LIMITED, work.getVisibility());
        } else if ("Test Title # 2".equals(work.getWorkTitle().getTitle().getContent())) {
            assertEquals(Visibility.PRIVATE, work.getVisibility());
        }
    }
    workManager.removeAllWorks(orcid);
    orcidProfileManager.deleteProfile(orcid);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test)

Example 44 with OrcidWorks

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

the class OrcidSearchManagerImplTest method orcidRetrievalAllDataPresentInDb.

@Test
@Rollback
public void orcidRetrievalAllDataPresentInDb() throws Exception {
    when(mockSolrDao.findByOrcid("1434")).thenReturn(getOrcidSolrResult("5678", new Float(37.2)));
    when(mockOrcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfileAllIndexFieldsPopulated());
    String orcid = "1434";
    // demonstrate that the mapping from solr (profile 1234) and dao (5678)
    // are truly seperate - the search results only return a subset of the
    // full orcid
    // because we want to keep the payload down.
    OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById(orcid);
    assertNotNull(retrievedOrcidMessage);
    assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
    OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
    assertTrue(new Float(37.2).compareTo(result.getRelevancyScore().getValue()) == 0);
    OrcidProfile retrievedProfile = result.getOrcidProfile();
    assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
    OrcidBio orcidBio = retrievedProfile.getOrcidBio();
    assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
    assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
    assertEquals("Stanley Higgins", orcidBio.getPersonalDetails().getCreditName().getContent());
    List<String> otherNames = orcidBio.getPersonalDetails().getOtherNames().getOtherNamesAsStrings();
    assertTrue(otherNames.contains("Edward Bass"));
    assertTrue(otherNames.contains("Gareth Dove"));
    OrcidWorks orcidWorks = retrievedProfile.retrieveOrcidWorks();
    OrcidWork orcidWork1 = orcidWorks.getOrcidWork().get(0);
    OrcidWork orcidWork2 = orcidWorks.getOrcidWork().get(1);
    assertTrue(orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 1);
    assertEquals("work1-doi1", orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
    assertTrue(orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 2);
    assertEquals("work2-doi1", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
    assertEquals("work2-doi2", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(1).getWorkExternalIdentifierId().getContent());
    List<Funding> fundings = retrievedProfile.retrieveFundings().getFundings();
    Funding funding1 = fundings.get(0);
    Funding funding2 = fundings.get(1);
    // check returns a reduced payload
    assertNotNull(funding1.getTitle());
    assertNotNull(funding1.getTitle().getTitle());
    assertEquals("grant1", funding1.getTitle().getTitle().getContent());
    assertEquals("Grant 1 - a short description", funding1.getDescription());
    assertNull(funding1.getPutCode());
    assertNotNull(funding2.getTitle());
    assertNotNull(funding2.getTitle().getTitle());
    assertEquals("grant2", funding2.getTitle().getTitle().getContent());
    assertEquals("Grant 2 - a short description", funding2.getDescription());
    assertNull(funding2.getPutCode());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Funding(org.orcid.jaxb.model.message.Funding) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 45 with OrcidWorks

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

the class Jaxb2JpaAdapterImpl method setActivityDetails.

private void setActivityDetails(ProfileEntity profileEntity, OrcidActivities orcidActivities, UpdateOptions updateOptions) {
    Affiliations affiliations = null;
    FundingList orcidFundings = null;
    OrcidWorks orcidWorks = null;
    if (orcidActivities != null) {
        affiliations = orcidActivities.getAffiliations();
        orcidFundings = orcidActivities.getFundings();
        orcidWorks = orcidActivities.getOrcidWorks();
    }
    if (updateOptions.isUpdateAffiliations()) {
        setOrgAffiliationRelations(profileEntity, affiliations);
    }
    if (updateOptions.isUpdateFundings()) {
        setFundings(profileEntity, orcidFundings);
    }
}
Also used : FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)46 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)35 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)32 Test (org.junit.Test)24 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)19 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)15 Title (org.orcid.jaxb.model.message.Title)15 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)13 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)13 Transactional (org.springframework.transaction.annotation.Transactional)12 FundingList (org.orcid.jaxb.model.message.FundingList)9 Funding (org.orcid.jaxb.model.message.Funding)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)8 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)8 DBUnitTest (org.orcid.test.DBUnitTest)8 Rollback (org.springframework.test.annotation.Rollback)8 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 Date (java.util.Date)6 Affiliations (org.orcid.jaxb.model.message.Affiliations)6 Subtitle (org.orcid.jaxb.model.message.Subtitle)6