use of org.orcid.jaxb.model.message.Claimed in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPrivate.
@Test
@Transactional
public void testAddOrcidWorksWhenDefaultVisibilityIsPrivate() {
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.PRIVATE));
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.PRIVATE, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.Claimed in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsLimited.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsLimited() {
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.LIMITED));
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.LIMITED, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.Claimed in project ORCID-Source by ORCID.
the class SetUpClientsAndUsers method createUser.
private void createUser(Map<String, String> params) throws Exception {
// Create it
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
if (params.get(MEMBER_TYPE) != null) {
orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
}
orcidProfile.setPassword(params.get(PASSWORD));
OrcidInternal internal = new OrcidInternal();
Preferences preferences = new Preferences();
ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
visibilityDefaults.setValue(Visibility.PUBLIC);
preferences.setActivitiesVisibilityDefault(visibilityDefaults);
internal.setPreferences(preferences);
orcidProfile.setOrcidInternal(internal);
Email email = new Email(params.get(EMAIL));
email.setCurrent(true);
email.setPrimary(true);
email.setVerified(true);
email.setVisibility(Visibility.PUBLIC);
List<Email> emails = new ArrayList<Email>();
emails.add(email);
ContactDetails contactDetails = new ContactDetails();
contactDetails.setEmail(emails);
org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
personalDetails.setCreditName(creditName);
personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
OrcidBio bio = new OrcidBio();
bio.setContactDetails(contactDetails);
bio.setPersonalDetails(personalDetails);
bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
orcidProfile.setOrcidBio(bio);
OrcidHistory history = new OrcidHistory();
history.setClaimed(new Claimed(true));
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
history.setCreationMethod(CreationMethod.DIRECT);
orcidProfile.setOrcidHistory(history);
orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
if (params.containsKey(LOCKED)) {
orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
}
if (params.containsKey(DEVELOPER_TOOLS)) {
profileEntityManager.enableDeveloperTools(orcidProfile);
}
}
use of org.orcid.jaxb.model.message.Claimed in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method testCreateProfileWithInvalidHistoryElements.
@Test
public void testCreateProfileWithInvalidHistoryElements() {
OrcidMessage orcidMessage = createStubOrcidMessage();
orcidMessage.setMessageVersion("1.2");
//Claimed should be null
try {
OrcidHistory history = new OrcidHistory();
history.setClaimed(new Claimed(false));
orcidMessage.getOrcidProfile().setOrcidHistory(history);
t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
} catch (OrcidValidationException obe) {
assertTrue(obe.getMessage().contains("Claimed status should not be specified when creating a profile"));
}
//Creation method should be null
try {
OrcidHistory history = new OrcidHistory();
history.setCreationMethod(CreationMethod.API);
orcidMessage.getOrcidProfile().setOrcidHistory(history);
t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
} catch (OrcidValidationException obe) {
assertTrue(obe.getMessage().contains("Creation method should not be specified when creating a profile"));
}
//Completion date should be null
try {
OrcidHistory history = new OrcidHistory();
history.setCompletionDate(new CompletionDate());
orcidMessage.getOrcidProfile().setOrcidHistory(history);
t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
} catch (OrcidValidationException obe) {
assertTrue(obe.getMessage().contains("Completion date should not be specified when creating a profile"));
}
//Submission date should be null
try {
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate());
orcidMessage.getOrcidProfile().setOrcidHistory(history);
t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
} catch (OrcidValidationException obe) {
assertTrue(obe.getMessage().contains("Submission date should not be specified when creating a profile"));
}
//Last modified date should be null
try {
OrcidHistory history = new OrcidHistory();
history.setLastModifiedDate(new LastModifiedDate());
orcidMessage.getOrcidProfile().setOrcidHistory(history);
t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
} catch (OrcidValidationException obe) {
assertTrue(obe.getMessage().contains("Last modified date should not be specified when creating a profile"));
}
}
use of org.orcid.jaxb.model.message.Claimed in project ORCID-Source by ORCID.
the class OrcidProfileManagerReadOnlyImpl method createReservedForClaimOrcidProfile.
protected OrcidProfile createReservedForClaimOrcidProfile(String orcid, OrcidDeprecated deprecatedInfo, LastModifiedDate lastModifiedDate) {
OrcidProfile op = new OrcidProfile();
if (jpaJaxbAdapter != null) {
op.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid)));
} else {
op.setOrcidIdentifier(orcid);
}
if (deprecatedInfo != null)
op.setOrcidDeprecated(deprecatedInfo);
OrcidHistory oh = new OrcidHistory();
oh.setClaimed(new Claimed(false));
oh.setLastModifiedDate(lastModifiedDate);
op.setOrcidHistory(oh);
GivenNames gn = new GivenNames();
PersonalDetails pd = new PersonalDetails();
gn.setContent(localeManager.resolveMessage("orcid.reserved_for_claim"));
gn.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
pd.setGivenNames(gn);
OrcidBio ob = new OrcidBio();
ob.setPersonalDetails(pd);
op.setOrcidBio(ob);
return op;
}
Aggregations