Search in sources :

Example 66 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method getEmailsElement.

private Emails getEmailsElement(Visibility... vs) {
    Emails elements = new Emails();
    for (Visibility v : vs) {
        Email element = new Email();
        element.setVisibility(v);
        if (elements.getEmails() == null) {
            elements.setEmails(new ArrayList<Email>());
        }
        elements.getEmails().add(element);
    }
    return elements;
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 67 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class NotificationManagerImpl method sendAcknowledgeMessage.

@Override
public void sendAcknowledgeMessage(String userOrcid, String clientId) throws UnsupportedEncodingException {
    ProfileEntity profileEntity = profileEntityCacheManager.retrieve(userOrcid);
    ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
    Locale userLocale = (profileEntity.getLocale() == null || profileEntity.getLocale().value() == null) ? Locale.ENGLISH : LocaleUtils.toLocale(profileEntity.getLocale().value());
    String subject = getSubject("email.subject.institutional_sign_in", userLocale);
    String authorizationUrl = buildAuthorizationUrlForInstitutionalSignIn(clientDetails);
    // Create map of template params
    Map<String, Object> templateParams = new HashMap<String, Object>();
    templateParams.put("emailName", deriveEmailFriendlyName(profileEntity));
    templateParams.put("orcid", userOrcid);
    templateParams.put("baseUri", orcidUrlManager.getBaseUrl());
    templateParams.put("subject", subject);
    templateParams.put("clientName", clientDetails.getClientName());
    templateParams.put("authorization_url", authorizationUrl);
    addMessageParams(templateParams, userLocale);
    // Generate body from template
    String body = templateManager.processTemplate("authenticate_request_email.ftl", templateParams);
    // Generate html from template
    String html = templateManager.processTemplate("authenticate_request_email_html.ftl", templateParams);
    boolean notificationsEnabled = profileEntity.getEnableNotifications();
    if (notificationsEnabled) {
        NotificationInstitutionalConnection notification = new NotificationInstitutionalConnection();
        notification.setNotificationType(NotificationType.INSTITUTIONAL_CONNECTION);
        notification.setAuthorizationUrl(new AuthorizationUrl(authorizationUrl));
        NotificationInstitutionalConnectionEntity notificationEntity = (NotificationInstitutionalConnectionEntity) notificationAdapter.toNotificationEntity(notification);
        notificationEntity.setProfile(new ProfileEntity(userOrcid));
        notificationEntity.setClientSourceId(clientId);
        notificationEntity.setAuthenticationProviderId(clientDetails.getAuthenticationProviderId());
        notificationDao.persist(notificationEntity);
    } else {
        Emails emails = emailManager.getEmails(userOrcid);
        String primaryEmail = null;
        if (emails == null || emails.getEmails() == null) {
            throw new IllegalArgumentException("Unable to find primary email for: " + userOrcid);
        }
        for (org.orcid.jaxb.model.record_v2.Email email : emails.getEmails()) {
            if (email.isPrimary()) {
                primaryEmail = email.getEmail();
            }
        }
        mailGunManager.sendEmail(UPDATE_NOTIFY_ORCID_ORG, primaryEmail, subject, body, html);
    }
}
Also used : Locale(java.util.Locale) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) NotificationInstitutionalConnection(org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection) HashMap(java.util.HashMap) NotificationInstitutionalConnectionEntity(org.orcid.persistence.jpa.entities.NotificationInstitutionalConnectionEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) AuthorizationUrl(org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 68 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class PersonDetailsManagerReadOnlyImpl method getPublicPersonDetails.

@Override
public Person getPublicPersonDetails(String orcid) {
    Person person = new Person();
    Name name = recordNameManager.getRecordName(orcid);
    if (Visibility.PUBLIC.equals(name.getVisibility())) {
        person.setName(name);
    }
    Biography bio = biographyManager.getPublicBiography(orcid);
    if (bio != null) {
        person.setBiography(bio);
    }
    Addresses addresses = addressManager.getPublicAddresses(orcid);
    if (addresses.getAddress() != null) {
        Addresses filteredAddresses = new Addresses();
        filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
        person.setAddresses(filteredAddresses);
    }
    PersonExternalIdentifiers extIds = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
    if (extIds.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
        filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
        person.setExternalIdentifiers(filteredExtIds);
    }
    Keywords keywords = profileKeywordManager.getPublicKeywords(orcid);
    if (keywords.getKeywords() != null) {
        Keywords filteredKeywords = new Keywords();
        filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
        person.setKeywords(filteredKeywords);
    }
    OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid);
    if (otherNames.getOtherNames() != null) {
        OtherNames filteredOtherNames = new OtherNames();
        filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
        person.setOtherNames(filteredOtherNames);
    }
    ResearcherUrls rUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
    if (rUrls.getResearcherUrls() != null) {
        ResearcherUrls filteredRUrls = new ResearcherUrls();
        filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
        person.setResearcherUrls(filteredRUrls);
    }
    Emails emails = emailManager.getPublicEmails(orcid);
    if (emails.getEmails() != null) {
        Emails filteredEmails = new Emails();
        filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
        person.setEmails(filteredEmails);
    }
    return person;
}
Also used : Keywords(org.orcid.jaxb.model.record_v2.Keywords) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Person(org.orcid.jaxb.model.record_v2.Person)

Example 69 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails 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);
    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)

Example 70 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class EmailManagerReadOnlyImpl method toEmails.

private Emails toEmails(List<EmailEntity> entities) {
    List<org.orcid.jaxb.model.record_v2.Email> emailList = jpaJaxbEmailAdapter.toEmailList(entities);
    Emails emails = new Emails();
    emails.setEmails(emailList);
    return emails;
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails)

Aggregations

Emails (org.orcid.jaxb.model.record_v2.Emails)63 Test (org.junit.Test)59 Email (org.orcid.jaxb.model.record_v2.Email)52 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Address (org.orcid.jaxb.model.record_v2.Address)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)34 Keywords (org.orcid.jaxb.model.record_v2.Keywords)33 OtherName (org.orcid.jaxb.model.record_v2.OtherName)33 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)33 Biography (org.orcid.jaxb.model.record_v2.Biography)32 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)32 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 Person (org.orcid.jaxb.model.record_v2.Person)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 Name (org.orcid.jaxb.model.record_v2.Name)29 Record (org.orcid.jaxb.model.record_v2.Record)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15