use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorks.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorks() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
String originalPutCode = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode();
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("New Title"));
workTitle3.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work3 = createWork2(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(3, 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) {
assertEquals(Visibility.PRIVATE, work.getVisibility());
}
assertEquals("Put code of original work should not have changed", originalPutCode, works.get(2).getPutCode());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method getFundingInsideOrcidProfile.
private OrcidProfile getFundingInsideOrcidProfile(String defaultTitle, String orcid) {
Funding funding = new Funding();
funding.setType(FundingType.AWARD);
FundingTitle title = new FundingTitle();
if (defaultTitle == null) {
title.setTitle(new Title("New Funding"));
} else {
title.setTitle(new Title(defaultTitle));
}
funding.setTitle(title);
FundingExternalIdentifiers fExtIds = new FundingExternalIdentifiers();
FundingExternalIdentifier fExtId = new FundingExternalIdentifier();
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER);
if (defaultTitle == null) {
fExtId.setValue("123");
} else {
fExtId.setValue("123-" + defaultTitle);
}
fExtIds.getFundingExternalIdentifier().add(fExtId);
funding.setFundingExternalIdentifiers(fExtIds);
Organization org = new Organization();
OrganizationAddress add = new OrganizationAddress();
add.setCity("city");
add.setCountry(Iso3166Country.US);
org.setName("Test org");
org.setAddress(add);
funding.setOrganization(org);
FundingList fList = new FundingList();
fList.getFundings().add(funding);
OrcidProfile profile = new OrcidProfile();
profile.setOrcidIdentifier(orcid);
profile.setFundings(fList);
return profile;
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidProfileManagerContributorVisibilityTest method retrieveAddedWorkFromApi.
private OrcidWork retrieveAddedWorkFromApi() {
OrcidProfile retrieved = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
OrcidWorks orcidWorks = retrieved.retrieveOrcidWorks();
assertNotNull(orcidWorks);
List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
assertEquals(1, orcidWorkList.size());
return orcidWorkList.get(0);
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method solrDocWithFundingTitles.
private OrcidSolrDocument solrDocWithFundingTitles() {
OrcidSolrDocument orcidSolrDocument = fullyPopulatedSolrDocumentForPersistence();
orcidSolrDocument.setFundingTitles(Arrays.asList(new String[] { "grant 1", "grant 2" }));
OrcidProfile orcidProfile = getOrcidWithGrants();
OrcidMessage orcidMessage = createFilteredOrcidMessage(orcidProfile);
orcidSolrDocument.setPublicProfileMessage(orcidMessage.toString());
return orcidSolrDocument;
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method visibilityConstraintsAppliedToSolr.
@Test
@Rollback
@Ignore
public void visibilityConstraintsAppliedToSolr() throws Exception {
OrcidProfile hiddenNamesOrcid = orcidProfileLimitedVisiblityCreditNameAndOtherNames();
orcidIndexManager.persistProfileInformationForIndexing(hiddenNamesOrcid);
// check that limited fields are hidden from solr indexing
OrcidSolrDocument namesHiddenSolrDoc = solrDocFilteredByNameVisibility();
verify(solrDao).persist(eq(namesHiddenSolrDoc));
// reset orcid test data and check affilations
OrcidProfile limitedOrcid = orcidProfileLimitedVisiblityAffiliations();
orcidIndexManager.persistProfileInformationForIndexing(limitedOrcid);
OrcidSolrDocument hiddenPastAffiliations = solrDocFilteredByAffilliationVisibility();
verify(solrDao).persist(eq(hiddenPastAffiliations));
OrcidProfile orcidAllWorksPrivate = orcidProfileAllLimitedVisibilityWorks();
orcidIndexManager.persistProfileInformationForIndexing(orcidAllWorksPrivate);
OrcidSolrDocument hiddenWorks = solrDocFilteredByAffilliationVisibility();
verify(solrDao).persist(eq(hiddenWorks));
}
Aggregations