/** * Create an instance of {@link OrcidProfile } * */ public OrcidProfile createOrcidProfile() { return new OrcidProfile(); }
public void downgradeToExternalIdentifiersOnly() { downgradeToBioOnly(); if (orcidBio != null) { orcidBio.downGradeToExternalIdentifiersOnly(); } }
@Override public OrcidProfile retrieveClaimedOrcidProfile(String orcid, LoadOptions loadOptions) { OrcidProfile orcidProfile = retrieveOrcidProfile(orcid, loadOptions); if (orcidProfile != null) { if (Boolean.TRUE.equals(orcidProfile.getOrcidHistory().getClaimed().isValue()) || orcidProfile.isDeactivated() || isBeingAccessedByCreator(orcidProfile) || haveSystemRole() || isOldEnough(orcidProfile)) { return orcidProfile; } else { if (orcidProfile.getOrcidDeprecated() != null && orcidProfile.getOrcidDeprecated().getPrimaryRecord() != null) return createReservedForClaimOrcidProfile(orcid, orcidProfile.getOrcidDeprecated(), orcidProfile.getOrcidHistory().getLastModifiedDate()); else return createReservedForClaimOrcidProfile(orcid, orcidProfile.getOrcidHistory().getLastModifiedDate()); } } return null; }
public void downgradeToOrcidIdentifierOnly() { setOrcidBio(null); setOrcidActivities(null); }
@Override public OrcidProfile updateOrcidPreferences(OrcidProfile updatedOrcidProfile) { OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath()); if (existingProfile == null) { return null; } existingProfile.setOrcidPreferences(updatedOrcidProfile.getOrcidPreferences()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.PREFERENCES, null); return profileToReturn; }
public static String createCacheKey(OrcidProfile profile) { OrcidHistory orcidHistory = profile.getOrcidHistory(); OrcidIdentifier orcidIdentifier = profile.getOrcidIdentifier(); String xmlFormatLastModifiedDate = (orcidHistory != null && orcidHistory.getLastModifiedDate() != null) ? orcidHistory.getLastModifiedDate().getValue() .toXMLFormat() : "no-last-modified"; String path = orcidIdentifier != null ? orcidIdentifier.getPath() : "no-orcid-identifier"; return StringUtils.join(new String[] {path, xmlFormatLastModifiedDate, profile.getReleaseName() }, "_"); }
OrcidProfile profile = new OrcidProfile(); OrcidType type = (profileEntity.getOrcidType() == null) ? null : OrcidType.valueOf(profileEntity.getOrcidType()); profile.setOrcidIdentifier(new OrcidIdentifier(getOrcidIdBase(profileEntity.getId()))); profile.setOrcidDeprecated(getOrcidDeprecated(profileEntity)); profile.setOrcidActivities(getOrcidActivities(profileEntity, true)); } else { profile.setOrcidActivities(getOrcidActivities(profileEntity, false)); profile.setOrcidBio(getOrcidBio(profileEntity)); profile.setOrcidHistory(getOrcidHistory(profileEntity)); if (loadOptions.isLoadInternal()) { profile.setOrcidInternal(getOrcidInternal(profileEntity)); profile.setOrcidPreferences(getOrcidPreferences(profileEntity)); profile.setPassword(profileEntity.getEncryptedPassword()); profile.setSecurityQuestionAnswer(profileEntity.getEncryptedSecurityAnswer()); profile.setType(type == null ? OrcidType.USER : type); profile.setGroupType(profileEntity.getGroupType() != null ? MemberType.valueOf(profileEntity.getGroupType()) : null); profile.setVerificationCode(profileEntity.getEncryptedVerificationCode()); profile.setLocked(profileEntity.getRecordLocked()); profile.setReviewed(profileEntity.isReviewed());
/** * See {@link OrcidApiServiceDelegator}{@link #searchByQuery(Map)} */ @Override @VisibilityControl public Response searchByQuery(Map<String, List<String>> queryMap) { validateSearchParams(queryMap); OrcidMessage orcidMessage = orcidSearchManager.findOrcidsByQuery(queryMap); List<OrcidSearchResult> searchResults = orcidMessage.getOrcidSearchResults() != null ? orcidMessage.getOrcidSearchResults().getOrcidSearchResult() : null; List<OrcidSearchResult> filteredResults = new ArrayList<OrcidSearchResult>(); OrcidSearchResults orcidSearchResults = new OrcidSearchResults(); if (searchResults != null) { orcidSearchResults.setNumFound(orcidMessage.getOrcidSearchResults().getNumFound()); if (searchResults.size() > 0) { for (OrcidSearchResult searchResult : searchResults) { OrcidSearchResult filteredSearchResult = new OrcidSearchResult(); OrcidProfile filteredProfile = new OrcidProfile(); filteredSearchResult.setRelevancyScore(searchResult.getRelevancyScore()); filteredProfile.setOrcid(searchResult.getOrcidProfile().getOrcid()); filteredProfile.setOrcidId(searchResult.getOrcidProfile().getOrcidId()); filteredProfile.setOrcidIdentifier(searchResult.getOrcidProfile().getOrcidIdentifier()); filteredProfile.setOrcidBio(searchResult.getOrcidProfile().getOrcidBio()); filteredSearchResult.setOrcidProfile(filteredProfile); filteredResults.add(filteredSearchResult); } } } orcidSearchResults.getOrcidSearchResult().addAll(filteredResults); return getOrcidSearchResultsResponse(orcidSearchResults, queryMap.toString()); }
@Override public ProfileEventResult call() throws Exception { String orcidId = getOrcidProfile().getOrcidIdentifier().getPath(); if (orcidProfile.getOrcidBio() == null || orcidProfile.getOrcidBio().getContactDetails() == null || orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail() == null || orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue() == null) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SKIPPED_2017); } if (orcidProfile.isLocked() || orcidProfile.isDeactivated() || orcidProfile.getOrcidDeprecated() != null || !orcidProfile.getOrcidHistory().getClaimed().isValue()) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SKIPPED_2017); } Email primaryEmail = orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail(); if (primaryEmail.isVerified()) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_HAS_VALIDATED_2017); } else { try { boolean sent = sendVerifiedRequiredAnnouncement2017(orcidProfile); if (sent) { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_SENT_2017); } else { return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_FAIL_2017); } } catch (Exception e) { LOG.error("ProfileEventType exception trying to send email to: " + orcidProfile.retrieveOrcidUriAsString(), e); return new ProfileEventResult(orcidId, ProfileEventType.VERIFIED_REQUIRED_FAIL_2017); } } }
@Override public ProfileEntity toProfileEntity(OrcidProfile profile, ProfileEntity existingProfileEntity, UpdateOptions updateOptions) { Assert.notNull(profile, "Cannot convert a null OrcidProfile"); ProfileEntity profileEntity = existingProfileEntity == null ? new ProfileEntity() : existingProfileEntity; // if orcid-id exist us it String orcidString = profile.getOrcidIdentifier().getPath(); if (profile.retrieveOrcidUriAsString() != null && !profile.retrieveOrcidUriAsString().isEmpty()) { orcidString = OrcidStringUtils.getOrcidNumber(profile.retrieveOrcidUriAsString()); } profileEntity.setId(orcidString); profileEntity.setOrcidType(profile.getType().name()); profileEntity.setGroupType(profile.getGroupType() != null ? profile.getGroupType().name() : null); setBioDetails(profileEntity, profile.getOrcidBio()); setHistoryDetails(profileEntity, profile.getOrcidHistory()); setActivityDetails(profileEntity, profile.getOrcidActivities(), updateOptions); setInternalDetails(profileEntity, profile.getOrcidInternal()); setPreferencesDetails(profileEntity, profile.getOrcidPreferences()); profileEntity.setUserLastIp(profile.getUserLastIp()); profileEntity.setReviewed(profile.isReviewed()); if(profileEntity.getUsedRecaptchaOnRegistration() == null) { profileEntity.setUsedRecaptchaOnRegistration(false); } return profileEntity; }
if (orcidProfile.isLocked()) { orcidProfile.downgradeToOrcidIdentifierOnly(); profileIndexDocument.setOrcid(filteredProfile.getOrcidIdentifier().getPath()); OrcidDeprecated orcidDeprecated = filteredProfile.getOrcidDeprecated(); if (orcidDeprecated != null) { profileIndexDocument.setPrimaryRecord(orcidDeprecated.getPrimaryRecord() != null ? orcidDeprecated.getPrimaryRecord().getOrcidIdentifier().getPath() : null); OrcidBio orcidBio = filteredProfile.getOrcidBio(); if (orcidBio != null) { PersonalDetails personalDetails = orcidBio.getPersonalDetails(); OrcidActivities orcidActivities = filteredProfile.getOrcidActivities(); if (orcidActivities != null) { List<OrcidWork> orcidWorks = filteredProfile.retrieveOrcidWorks() != null ? filteredProfile.retrieveOrcidWorks().getOrcidWork() : null; if (orcidWorks != null) { List<String> workTitles = new ArrayList<String>(); List<Funding> orcidFundings = filteredProfile.retrieveFundings() != null ? filteredProfile.retrieveFundings().getFundings() : null; if (orcidFundings != null) { List<String> fundingTitle = new ArrayList<String>(); orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION); orcidMessage.setOrcidProfile(filteredProfile); OrcidHistory orcidHistory = filteredProfile.getOrcidHistory(); if (orcidHistory != null) { LastModifiedDate lastModifiedDate = orcidHistory.getLastModifiedDate();
relevancyScore.setValue(solrResult.getRelevancyScore()); orcidSearchResult.setRelevancyScore(relevancyScore); OrcidProfile orcidProfile = new OrcidProfile(); orcidProfile.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid))); OrcidHistory history = new OrcidHistory(); Date recordLastModified = profileDaoReadOnly.retrieveLastModifiedDate(orcid); history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(recordLastModified))); orcidProfile.setOrcidHistory(history); orcidSearchResult.setOrcidProfile(orcidProfile); orcidSearchResults.add(orcidSearchResult); OrcidWorks fullOrcidWorks = orcidProfile.retrieveOrcidWorks(); if (fullOrcidWorks != null && !fullOrcidWorks.getOrcidWork().isEmpty()) { FundingList fullOrcidFundings = orcidProfile.retrieveFundings(); if (fullOrcidFundings != null && !fullOrcidFundings.getFundings().isEmpty()) { orcidProfile.setOrcidWorks(orcidWorksTitlesOnly); orcidProfile.setFundings(reducedFundings);
protected OrcidProfile createReservedForClaimOrcidProfile(String orcid, OrcidDeprecated deprecatedInfo, LastModifiedDate lastModifiedDate) { OrcidProfile op = new OrcidProfile(); if (jpaJaxbAdapter != null) { op.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid))); } else { op.setOrcidIdentifier(orcid); } if (deprecatedInfo != null) op.setOrcidDeprecated(deprecatedInfo); OrcidHistory oh = new OrcidHistory(); oh.setClaimed(new Claimed(false)); oh.setLastModifiedDate(lastModifiedDate); op.setOrcidHistory(oh); GivenNames gn = new GivenNames(); PersonalDetails pd = new PersonalDetails(); gn.setContent(localeManager.resolveMessage("orcid.reserved_for_claim")); gn.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility()); pd.setGivenNames(gn); OrcidBio ob = new OrcidBio(); ob.setPersonalDetails(pd); op.setOrcidBio(ob); return op; }
/** * Updates the ORCID bio data * * @param updatedOrcidProfile * @return */ @Deprecated @Override public OrcidProfile updateOrcidBio(OrcidProfile updatedOrcidProfile) { addSourceToBioElements(updatedOrcidProfile); OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath(), LoadOptions.ALL_WITH_NEW_AFFILIATION_TYPES); if (existingProfile == null) { return null; } // preserve the visibility settings orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingProfile.getOrcidBio(), updatedOrcidProfile.getOrcidBio()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile, UpdateOptions.NO_ACTIVITIES); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.BIO, null); return profileToReturn; }
OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath(), LoadOptions.ALL_WITH_NEW_AFFILIATION_TYPES); if (existingProfile == null) { return null; OrcidActivities updatedActivities = updatedOrcidProfile.getOrcidActivities(); if (updatedActivities == null) { return null; return null; OrcidActivities existingActivities = existingProfile.getOrcidActivities(); if (existingActivities == null) { existingActivities = new OrcidActivities(); existingProfile.setOrcidActivities(existingActivities); existingActivities.setOrcidWorks(existingOrcidWorks); checkUserCanHoldMoreElement(existingProfile.retrieveOrcidWorks(), updatedOrcidProfile.retrieveOrcidWorks()); orcidJaxbCopyManager.copyUpdatedWorksPreservingVisbility(existingProfile.retrieveOrcidWorks(), updatedOrcidProfile.retrieveOrcidWorks()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.WORK, null); return profileToReturn;
@Override @Deprecated public OrcidProfile updateFundings(OrcidProfile updatedOrcidProfile) { OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath(), LoadOptions.ALL_WITH_NEW_AFFILIATION_TYPES); if (existingProfile == null) { return null; FundingList updatedFundingList = updatedOrcidProfile.retrieveFundings(); if (updatedFundingList == null) { return null; updatedFundingList = updatedOrcidProfile.retrieveFundings(); OrcidActivities existingActivities = existingProfile.getOrcidActivities(); if (existingActivities == null) { existingActivities = new OrcidActivities(); existingProfile.setOrcidActivities(existingActivities); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.FUNDING, null); return profileToReturn;
protected void doInTransactionWithoutResult(TransactionStatus status) { ProfileEntity existingProfileEntity = profileDao.find(orcidProfile.getOrcidIdentifier().getPath()); Visibility defaultVisibility = Visibility.fromValue(existingProfileEntity.getActivitiesVisibilityDefault()); addSourceToNewActivities(orcidProfile.getOrcidActivities()); addSourceToEmails(orcidProfile, existingProfileEntity, amenderOrcid); Boolean claimed = orcidProfile.getOrcidHistory() != null ? orcidProfile.getOrcidHistory().isClaimed() : existingProfileEntity.getClaimed(); if (orcidProfile.getOrcidInternal() != null && orcidProfile.getOrcidInternal().getPreferences() != null && orcidProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault() != null) { defaultVisibility = orcidProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue(); if(orcidProfile.getOrcidActivities() != null && orcidProfile.getOrcidActivities().getOrcidWorks() != null) { adapter.setWorks(profileEntity, orcidProfile.getOrcidActivities().getOrcidWorks()); } else { adapter.setWorks(profileEntity, null);
@Override @Transactional public OrcidProfile createOrcidProfile(OrcidProfile orcidProfile, boolean createdByMember, boolean usedCaptcha) { if (orcidProfile.getOrcidIdentifier() == null) { orcidProfile.setOrcidIdentifier(orcidGenerationManager.createNewOrcid()); if(orcidProfile.getOrcidActivities() != null) { addSourceToNewActivities(orcidProfile.getOrcidActivities()); if (orcidProfile.getOrcidInternal() != null && orcidProfile.getOrcidInternal().getPreferences() != null && orcidProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault() != null) { defaultVisibility = orcidProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue(); profileEntity.setHashedOrcid(encryptionManager.sha256Hash(orcidProfile.getOrcidIdentifier().getPath())); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); if(orcidProfile.getOrcidActivities() != null && orcidProfile.getOrcidActivities().getOrcidWorks() != null) { adapter.setWorks(profileEntity, orcidProfile.getOrcidActivities().getOrcidWorks());
public boolean sendServiceAnnouncement_1_For_2015(OrcidProfile orcidProfile) { String orcid = orcidProfile.getOrcidIdentifier().getPath(); String email = orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue(); String emailFriendlyName = notificationManager.deriveEmailFriendlyName(profileDaoReadOnly.find(orcid)); Map<String, Object> templateParams = new HashMap<String, Object>(); templateParams.put("emailName", emailFriendlyName); String verificationUrl = notificationManager.createVerificationUrl(email, orcidUrlManager.getBaseUrl()); boolean needsVerification = !orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().isVerified() && orcidProfile.getType().equals(org.orcid.jaxb.model.message.OrcidType.USER) && !orcidProfile.isDeactivated(); if (needsVerification) { templateParams.put("verificationUrl", verificationUrl); String emailFrequencyUrl = notificationManager.createUpdateEmailFrequencyUrl(orcidProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue()); templateParams.put("emailFrequencyUrl", emailFrequencyUrl); templateParams.put("orcid", orcid);
@Transactional public void addFundings(OrcidProfile updatedOrcidProfile) { String orcid = updatedOrcidProfile.getOrcidIdentifier().getPath(); OrcidProfile existingProfile = retrieveOrcidProfile(orcid); if (existingProfile == null) { FundingList existingFundingList = existingProfile.retrieveFundings(); FundingList updatedFundingList = updatedOrcidProfile.retrieveFundings(); Visibility workVisibilityDefault = existingProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue(); Boolean claimed = existingProfile.getOrcidHistory().isClaimed(); setFundingPrivacy(updatedFundingList, workVisibilityDefault, claimed == null ? false : claimed); updatedFundingList = dedupeFundings(updatedFundingList); persistAddedFundings(orcid, updatedList); profileDao.flush(); boolean notificationsEnabled = existingProfile.getOrcidInternal().getPreferences().getNotificationsEnabled(); if (notificationsEnabled) { notificationManager.sendAmendEmail(orcid, AmendedSection.FUNDING, null);