use of org.orcid.jaxb.model.message.OrcidWork 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;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidWorks.
private void checkOrcidWorks(OrcidWorks orcidWorks) {
assertNotNull(orcidWorks);
List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
assertEquals(3, orcidWorkList.size());
boolean putCode1Found = false;
boolean putCode4Found = false;
for (OrcidWork orcidWork : orcidWorkList) {
if (orcidWork.getPutCode().equals("1")) {
putCode1Found = true;
assertEquals("1", orcidWork.getPutCode());
Citation workCitation = orcidWork.getWorkCitation();
assertNotNull(workCitation);
assertEquals("Bobby Ewing, ", workCitation.getCitation());
assertEquals(CitationType.FORMATTED_IEEE, workCitation.getWorkCitationType());
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(2, contributors.getContributor().size());
assertEquals("Jaylen Kessler", contributors.getContributor().get(0).getCreditName().getContent());
assertEquals(Visibility.PUBLIC, contributors.getContributor().get(0).getCreditName().getVisibility());
assertEquals(Visibility.PUBLIC, orcidWork.getVisibility());
assertNull(orcidWork.getJournalTitle());
} else if (orcidWork.getPutCode().equals("3")) {
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(1, contributors.getContributor().size());
assertEquals("0000-0003-0172-7925", contributors.getContributor().get(0).getContributorOrcid().getPath());
} else if (orcidWork.getPutCode().equals("4")) {
putCode4Found = true;
assertNotNull(orcidWork.getWorkTitle());
assertNotNull(orcidWork.getWorkTitle().getTitle());
assertEquals("A book with a Journal Title", orcidWork.getWorkTitle().getTitle().getContent());
assertNotNull(orcidWork.getJournalTitle());
assertEquals("My Journal Title", orcidWork.getJournalTitle().getContent());
assertNotNull(orcidWork.getPublicationDate());
assertNotNull(orcidWork.getPublicationDate().getDay());
assertNotNull(orcidWork.getPublicationDate().getMonth());
assertNotNull(orcidWork.getPublicationDate().getYear());
assertEquals("01", orcidWork.getPublicationDate().getDay().getValue());
assertEquals("02", orcidWork.getPublicationDate().getMonth().getValue());
assertEquals("2011", orcidWork.getPublicationDate().getYear().getValue());
assertNotNull(orcidWork.getWorkCitation());
assertEquals("Sue Ellen ewing", orcidWork.getWorkCitation().getCitation());
assertEquals(CitationType.FORMATTED_IEEE, orcidWork.getWorkCitation().getWorkCitationType());
assertNotNull(orcidWork.getWorkType());
assertEquals(WorkType.BOOK, orcidWork.getWorkType());
}
}
assertTrue(putCode1Found);
assertTrue(putCode4Found);
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method getOrcidProfileAllIndexFieldsPopulated.
private OrcidProfile getOrcidProfileAllIndexFieldsPopulated() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("5678");
OrcidBio orcidBio = new OrcidBio();
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setFamilyName(new FamilyName("Logan"));
personalDetails.setGivenNames(new GivenNames("Donald Edward"));
personalDetails.setCreditName(new CreditName("Stanley Higgins"));
OtherNames otherNames = new OtherNames();
otherNames.getOtherName().add(new OtherName("Edward Bass", null));
otherNames.getOtherName().add(new OtherName("Gareth Dove", null));
personalDetails.setOtherNames(otherNames);
orcidBio.setPersonalDetails(personalDetails);
orcidProfile.setOrcidBio(orcidBio);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
OrcidWorks orcidWorks = new OrcidWorks();
orcidProfile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork1 = new OrcidWork();
OrcidWork orcidWork2 = new OrcidWork();
assignWorkIdentifers(orcidWork1, orcidWork2);
orcidWorks.getOrcidWork().add(orcidWork1);
orcidWorks.getOrcidWork().add(orcidWork2);
orcidProfile.setOrcidWorks(orcidWorks);
FundingList orcidFundings = new FundingList();
orcidProfile.setFundings(orcidFundings);
Funding funding1 = new Funding();
funding1.setVisibility(Visibility.PUBLIC);
FundingTitle title = new FundingTitle();
title.setTitle(new Title("grant1"));
funding1.setTitle(title);
funding1.setDescription("Grant 1 - a short description");
funding1.setPutCode("grant 1 - put-code");
Funding funding2 = new Funding();
funding2.setVisibility(Visibility.PUBLIC);
FundingTitle title2 = new FundingTitle();
title2.setTitle(new Title("grant2"));
funding2.setTitle(title2);
funding2.setDescription("Grant 2 - a short description");
funding2.setPutCode("grant 2 - put-code");
orcidFundings.getFundings().add(funding1);
orcidFundings.getFundings().add(funding2);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorkToUnclaimedProfile.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorkToUnclaimedProfile() {
OrcidProfile profile1 = createBasicProfile();
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);
work2.setVisibility(Visibility.PUBLIC);
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 ("Further Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.LIMITED, work.getVisibility());
else if ("New Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PUBLIC, work.getVisibility());
else
assertEquals(Visibility.PRIVATE, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testPreventDuplicatedWorks.
@Test
@Transactional
@Rollback(true)
public void testPreventDuplicatedWorks() {
OrcidWork work1 = createWork1();
OrcidWork work2 = createWork2();
OrcidWork work3 = createWork3();
OrcidProfile profile = createBasicProfile();
profile = orcidProfileManager.createOrcidProfile(profile, false, false);
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(1, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
assertEquals(work1.getWorkTitle().getTitle().getContent(), profile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work2);
orcidProfileManager.addOrcidWorks(profile);
profile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
boolean found1 = false;
boolean found2 = false;
boolean found3 = false;
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(2, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
for (OrcidWork work : profile.getOrcidActivities().getOrcidWorks().getOrcidWork()) {
String workTitle = work.getWorkTitle().getTitle().getContent();
if (workTitle.equals(work1.getWorkTitle().getTitle().getContent())) {
found1 = true;
} else if (workTitle.equals(work2.getWorkTitle().getTitle().getContent())) {
found2 = true;
} else if (workTitle.equals(work3.getWorkTitle().getTitle().getContent())) {
found3 = true;
}
}
assertTrue(found1);
assertTrue(found2);
assertFalse(found3);
// Add work # 3 and duplicate other works
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work2);
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile);
profile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
// Work 3 was added and work 1 and 2 where not added twice
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(3, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
found1 = false;
found2 = false;
found3 = false;
for (OrcidWork work : profile.getOrcidActivities().getOrcidWorks().getOrcidWork()) {
String workTitle = work.getWorkTitle().getTitle().getContent();
if (workTitle.equals(work1.getWorkTitle().getTitle().getContent())) {
found1 = true;
} else if (workTitle.equals(work2.getWorkTitle().getTitle().getContent())) {
found2 = true;
} else if (workTitle.equals(work3.getWorkTitle().getTitle().getContent())) {
found3 = true;
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Duplicate all works
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work2);
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile);
profile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
// No new works are added and no duplicated was allowed
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(3, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
found1 = false;
found2 = false;
found3 = false;
for (OrcidWork work : profile.getOrcidActivities().getOrcidWorks().getOrcidWork()) {
String workTitle = work.getWorkTitle().getTitle().getContent();
if (workTitle.equals(work1.getWorkTitle().getTitle().getContent())) {
found1 = true;
} else if (workTitle.equals(work2.getWorkTitle().getTitle().getContent())) {
found2 = true;
} else if (workTitle.equals(work3.getWorkTitle().getTitle().getContent())) {
found3 = true;
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
//Test using work source
Source source = new Source();
source.setSourceOrcid(new SourceOrcid(APPLICATION_ORCID));
work1.setSource(source);
// Add work1 again, since it have a different source, it should be added
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
orcidProfileManager.addOrcidWorks(profile);
profile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(4, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
//Add work1 again, and it should not be added, since is duplicated
profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
orcidProfileManager.addOrcidWorks(profile);
profile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertNotNull(profile);
assertNotNull(profile.getOrcidActivities());
assertNotNull(profile.getOrcidActivities().getOrcidWorks());
assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(4, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
}
Aggregations