use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class ValidationManagerImpl method checkActivities.
private void checkActivities(OrcidActivities orcidActivities) {
if (orcidActivities != null) {
OrcidWorks works = orcidActivities.getOrcidWorks();
if (works != null && works.getOrcidWork() != null && !works.getOrcidWork().isEmpty()) {
checkWorks(works.getOrcidWork());
}
FundingList funding = orcidActivities.getFundings();
if (funding != null && funding.getFundings() != null && !funding.getFundings().isEmpty()) {
checkFunding(funding.getFundings());
}
}
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class MarshallingTest method testMarshallingFullMessage.
@Test
public void testMarshallingFullMessage() throws JAXBException {
OrcidMessage orcidMessage = getOrcidMessage();
assertNotNull(orcidMessage);
OrcidProfile orcidProfile = orcidMessage.getOrcidProfile();
assertNotNull(orcidProfile);
assertEquals("4444-4444-4444-4446", orcidProfile.getOrcidIdentifier().getPath());
OrcidActivities orcidActivities = orcidProfile.getOrcidActivities();
assertNotNull(orcidActivities);
assertEquals(4, orcidActivities.getAffiliations().getAffiliation().size());
OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
assertTrue(orcidWorks != null && orcidWorks.getOrcidWork().size() == 1);
OrcidWork orcidWork = orcidWorks.getOrcidWork().get(0);
assertEquals("journal-article", orcidWork.getWorkType().value());
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class CheckAndFixContributorNameVisibility method processOrcid.
private void processOrcid(final String orcid) {
LOG.info("Checking and fixing profile: {}", orcid);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
if (orcidWorks != null) {
for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
WorkContributors workContributors = orcidWork.getWorkContributors();
if (workContributors != null) {
for (Contributor contributor : workContributors.getContributor()) {
ContributorOrcid contributorOrcid = contributor.getContributorOrcid();
if (contributorOrcid != null) {
String orcid = contributorOrcid.getPath();
ProfileEntity contributorProfile = profileDao.find(orcid);
if (contributorProfile.getRecordNameEntity() != null && contributorProfile.getRecordNameEntity().getVisibility() != null) {
if (!Visibility.PUBLIC.value().equals(contributorProfile.getRecordNameEntity().getVisibility().value())) {
contributor.setCreditName(null);
}
}
}
}
}
}
}
orcidProfileManager.updateOrcidProfile(orcidProfile);
}
});
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPublic.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsPublic() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
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);
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 ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.PUBLIC, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createBasicProfile.
protected OrcidProfile createBasicProfile() {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
profile.setSecurityQuestionAnswer("random answer");
profile.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@semantico.com"));
bio.setContactDetails(contactDetails);
profile.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
bio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("Will"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
bio.setBiography(new Biography("Will is a software developer"));
ResearcherUrls researcherUrls = new ResearcherUrls();
bio.setResearcherUrls(researcherUrls);
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = createWork1();
// TODO JB - needs test
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
orcidWorks.getOrcidWork().add(orcidWork);
OrcidInternal orcidInternal = new OrcidInternal();
profile.setOrcidInternal(orcidInternal);
SecurityDetails securityDetails = new SecurityDetails();
securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
orcidInternal.setSecurityDetails(securityDetails);
Preferences preferences = new Preferences();
orcidInternal.setPreferences(preferences);
return profile;
}
Aggregations