Search in sources :

Example 1 with DeactivationDate

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);
        }
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) CreationMethod(org.orcid.jaxb.model.message.CreationMethod) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Source(org.orcid.jaxb.model.message.Source)

Example 2 with DeactivationDate

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DeactivationDate

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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) LoadOptions(org.orcid.core.manager.LoadOptions) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) EmailRequest(org.orcid.pojo.EmailRequest) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

DeactivationDate (org.orcid.jaxb.model.message.DeactivationDate)3 Date (java.util.Date)2 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 GregorianCalendar (java.util.GregorianCalendar)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 Test (org.junit.Test)1 LoadOptions (org.orcid.core.manager.LoadOptions)1 Biography (org.orcid.jaxb.model.message.Biography)1 CompletionDate (org.orcid.jaxb.model.message.CompletionDate)1 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)1 CreationMethod (org.orcid.jaxb.model.message.CreationMethod)1 CreditName (org.orcid.jaxb.model.message.CreditName)1 Email (org.orcid.jaxb.model.message.Email)1 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)1 FamilyName (org.orcid.jaxb.model.message.FamilyName)1 GivenNames (org.orcid.jaxb.model.message.GivenNames)1 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)1 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)1 OtherName (org.orcid.jaxb.model.message.OtherName)1