Search in sources :

Example 1 with DeactivationDate

use of org.orcid.jaxb.model.record_v2.DeactivationDate in project ORCID-Source by ORCID.

the class RecordManagerReadOnlyImpl method getHistory.

private History getHistory(String orcid) {
    History history = new History();
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    history.setClaimed(profile.getClaimed());
    if (profile.getCompletedDate() != null) {
        history.setCompletionDate(new CompletionDate(DateUtils.convertToXMLGregorianCalendar(profile.getCompletedDate())));
    }
    if (!PojoUtil.isEmpty(profile.getCreationMethod())) {
        history.setCreationMethod(CreationMethod.fromValue(profile.getCreationMethod()));
    }
    if (profile.getDeactivationDate() != null) {
        history.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(profile.getDeactivationDate())));
    }
    if (profile.getLastModified() != null) {
        history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(profile.getLastModified())));
    }
    if (profile.getSubmissionDate() != null) {
        history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(profile.getSubmissionDate())));
    }
    if (profile.getSource() != null) {
        history.setSource(new Source(profile.getSource().getSourceId()));
    }
    boolean verfiedEmail = false;
    boolean verfiedPrimaryEmail = false;
    Emails emails = emailManager.getEmails(orcid, profile.getLastModified().getTime());
    if (emails != null) {
        for (Email email : emails.getEmails()) {
            if (email.isVerified()) {
                verfiedEmail = true;
                if (email.isPrimary()) {
                    verfiedPrimaryEmail = true;
                    break;
                }
            }
        }
    }
    history.setVerifiedEmail(verfiedEmail);
    history.setVerifiedPrimaryEmail(verfiedPrimaryEmail);
    return history;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails) History(org.orcid.jaxb.model.record_v2.History) SubmissionDate(org.orcid.jaxb.model.record_v2.SubmissionDate) CompletionDate(org.orcid.jaxb.model.record_v2.CompletionDate) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Source(org.orcid.jaxb.model.common_v2.Source)

Aggregations

LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)1 Source (org.orcid.jaxb.model.common_v2.Source)1 CompletionDate (org.orcid.jaxb.model.record_v2.CompletionDate)1 DeactivationDate (org.orcid.jaxb.model.record_v2.DeactivationDate)1 Email (org.orcid.jaxb.model.record_v2.Email)1 Emails (org.orcid.jaxb.model.record_v2.Emails)1 History (org.orcid.jaxb.model.record_v2.History)1 SubmissionDate (org.orcid.jaxb.model.record_v2.SubmissionDate)1 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)1