use of org.orcid.jaxb.model.message.SubmissionDate in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getMinimalOrcidProfile.
private OrcidProfile getMinimalOrcidProfile() {
OrcidProfile profile = new OrcidProfile();
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new org.orcid.jaxb.model.message.Email(System.currentTimeMillis() + "@user.com"));
Preferences preferences = new Preferences();
preferences.setSendChangeNotifications(new SendChangeNotifications(true));
preferences.setSendOrcidNews(new SendOrcidNews(true));
preferences.setSendMemberUpdateRequests(true);
preferences.setSendEmailFrequencyDays("1");
preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.fromValue("public")));
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setFamilyName(new FamilyName("First"));
personalDetails.setGivenNames(new GivenNames("Last"));
bio.setContactDetails(contactDetails);
bio.setPersonalDetails(personalDetails);
OrcidInternal internal = new OrcidInternal();
internal.setPreferences(preferences);
profile.setOrcidBio(bio);
profile.setOrcidInternal(internal);
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setClaimed(new Claimed(true));
orcidHistory.setCreationMethod(CreationMethod.fromValue("integration-test"));
profile.setOrcidHistory(orcidHistory);
orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile.setPassword("password1");
return orcidProfileManager.createOrcidProfile(profile, false, false);
}
use of org.orcid.jaxb.model.message.SubmissionDate 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.SubmissionDate in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method setHistoryDetails.
private void setHistoryDetails(ProfileEntity profileEntity, OrcidHistory orcidHistory) {
if (orcidHistory != null) {
CompletionDate completionDate = orcidHistory.getCompletionDate();
profileEntity.setCompletedDate(completionDate == null ? null : toDate(completionDate.getValue()));
SubmissionDate submissionDate = orcidHistory.getSubmissionDate();
profileEntity.setSubmissionDate(submissionDate == null ? null : toDate(submissionDate.getValue()));
DeactivationDate deactivationDate = orcidHistory.getDeactivationDate();
profileEntity.setDeactivationDate(deactivationDate == null ? null : toDate(deactivationDate.getValue()));
profileEntity.setClaimed(orcidHistory.isClaimed());
CreationMethod creationMethod = orcidHistory.getCreationMethod();
profileEntity.setCreationMethod(creationMethod != null ? creationMethod.value() : null);
Source source = orcidHistory.getSource();
if (source != null) {
SourceEntity sourceEntity = new SourceEntity();
ClientDetailsEntity clientDetailsEntity = new ClientDetailsEntity();
clientDetailsEntity.setId(source.retrieveSourcePath());
sourceEntity.setSourceClient(clientDetailsEntity);
profileEntity.setSource(sourceEntity);
}
}
}
use of org.orcid.jaxb.model.message.SubmissionDate 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.SubmissionDate 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());
}
}
Aggregations