use of org.orcid.jaxb.model.message.DeactivationDate 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.DeactivationDate in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method deactivateOrcidProfile.
@Override
@Transactional
@Deprecated
public OrcidProfile deactivateOrcidProfile(OrcidProfile existingOrcidProfile) {
OrcidProfile blankedOrcidProfile = new OrcidProfile();
OrcidBio existingBio = existingOrcidProfile.getOrcidBio();
OrcidBio minimalBio = new OrcidBio();
ContactDetails minimalContactDetails = new ContactDetails();
minimalContactDetails.getEmail().addAll(existingBio.getContactDetails().getEmail());
OrcidInternal minimalOrcidInternal = new OrcidInternal();
minimalOrcidInternal.setSecurityDetails(existingOrcidProfile.getOrcidInternal().getSecurityDetails());
OrcidHistory deactivatedOrcidHistory = existingOrcidProfile.getOrcidHistory();
deactivatedOrcidHistory.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
blankedOrcidProfile.setOrcidHistory(deactivatedOrcidHistory);
// only names names from bio with a visibility setting
PersonalDetails minimalPersonalDetails = new PersonalDetails();
minimalPersonalDetails.setOtherNames(null);
CreditName creditName = new CreditName();
creditName.setVisibility(Visibility.PUBLIC);
minimalPersonalDetails.setCreditName(creditName);
minimalPersonalDetails.setGivenNames(new GivenNames("Given Names Deactivated"));
minimalPersonalDetails.setFamilyName(new FamilyName("Family Name Deactivated"));
for (Email email : minimalContactDetails.getEmail()) {
setVisibilityToPrivate(email);
}
setVisibilityToPrivate(minimalPersonalDetails.getOtherNames());
if (minimalPersonalDetails.getOtherNames() != null && minimalPersonalDetails.getOtherNames().getOtherName() != null) {
for (OtherName name : minimalPersonalDetails.getOtherNames().getOtherName()) setVisibilityToPrivate(name);
}
minimalBio.setPersonalDetails(minimalPersonalDetails);
minimalBio.setContactDetails(minimalContactDetails);
minimalBio.setBiography(new Biography());
minimalBio.setExternalIdentifiers(new ExternalIdentifiers());
blankedOrcidProfile.setOrcidBio(minimalBio);
blankedOrcidProfile.setOrcidIdentifier(existingOrcidProfile.getOrcidIdentifier().getPath());
OrcidProfile profileToReturn = updateOrcidProfile(blankedOrcidProfile);
userConnectionDao.deleteByOrcid(existingOrcidProfile.getOrcidIdentifier().getPath());
notificationManager.sendAmendEmail(profileToReturn, AmendedSection.UNKNOWN);
return profileToReturn;
}
use of org.orcid.jaxb.model.message.DeactivationDate in project ORCID-Source by ORCID.
the class PasswordResetControllerTest method testPasswordResetUserDeactivated.
@Test
public void testPasswordResetUserDeactivated() throws DatatypeConfigurationException {
GregorianCalendar c = new GregorianCalendar();
c.setTime(new Date());
XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setDeactivationDate(new DeactivationDate(date));
OrcidProfile deactivatedProfile = new OrcidProfile();
deactivatedProfile.setOrcidHistory(orcidHistory);
when(orcidProfileManager.retrieveOrcidProfileByEmail(Mockito.anyString(), Mockito.any(LoadOptions.class))).thenReturn(deactivatedProfile);
EmailRequest resetRequest = new EmailRequest();
resetRequest = passwordResetController.issuePasswordResetRequest(new MockHttpServletRequest(), resetRequest).getBody();
assertNotNull(resetRequest.getErrors());
assertFalse(resetRequest.getErrors().isEmpty());
}
Aggregations