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;
}
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);
}
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);
}
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());
}
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);
}
}
Aggregations