Search in sources :

Example 16 with CreditName

use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.

the class ContributorUtils method filterContributorPrivateData.

public void filterContributorPrivateData(Work work) {
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            contributor.setContributorEmail(null);
            if (!PojoUtil.isEmpty(contributor.getContributorOrcid())) {
                String contributorOrcid = contributor.getContributorOrcid().getPath();
                if (profileEntityManager.orcidExists(contributorOrcid)) {
                    // contributor is an ORCID user - visibility of user's
                    // name in record must be taken into account
                    ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
                    String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
                    CreditName creditName = new CreditName(publicContributorCreditName != null ? publicContributorCreditName : "");
                    contributor.setCreditName(creditName);
                }
            }
        }
    }
}
Also used : CreditName(org.orcid.jaxb.model.common_v2.CreditName) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Contributor(org.orcid.jaxb.model.common_v2.Contributor) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 17 with CreditName

use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.

the class JpaJaxbNameAdapterTest method fromNameToRecordNameEntityTest.

@Test
public void fromNameToRecordNameEntityTest() throws JAXBException {
    Name name = new Name();
    name.setCreditName(new CreditName("Credit Name"));
    name.setFamilyName(new FamilyName("Family Name"));
    name.setGivenNames(new GivenNames("Given Names"));
    name.setPath("0000-0000-0000-0000");
    name.setVisibility(Visibility.PUBLIC);
    name.setSource(new Source("0000-0000-0000-0000"));
    RecordNameEntity entity = adapter.toRecordNameEntity(name);
    assertNotNull(entity);
    assertEquals("Credit Name", entity.getCreditName());
    assertEquals("Family Name", entity.getFamilyName());
    assertEquals("Given Names", entity.getGivenNames());
    assertEquals(Visibility.PUBLIC, entity.getVisibility());
    assertNotNull(entity.getProfile());
    assertEquals("0000-0000-0000-0000", entity.getProfile().getId());
}
Also used : FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) CreditName(org.orcid.jaxb.model.common_v2.CreditName) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) Source(org.orcid.jaxb.model.common_v2.Source) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test)

Example 18 with CreditName

use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.

the class RecordNameManagerTest method testCreateRecordName.

@Test
public void testCreateRecordName() {
    Name name = new Name();
    long time = System.currentTimeMillis();
    name.setCreditName(new CreditName("Credit Name " + time));
    name.setFamilyName(new FamilyName("Family Name " + time));
    name.setGivenNames(new GivenNames("Given Names " + time));
    name.setVisibility(Visibility.PRIVATE);
    String orcid = "0000-0000-0000-0005";
    recordNameManager.createRecordName(orcid, name);
    Name newName = recordNameManager.getRecordName(orcid, 0);
    assertNotNull(newName);
    assertEquals("Credit Name " + time, newName.getCreditName().getContent());
    assertEquals("Family Name " + time, newName.getFamilyName().getContent());
    assertEquals("Given Names " + time, newName.getGivenNames().getContent());
    assertEquals(Visibility.PRIVATE, newName.getVisibility());
}
Also used : FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) CreditName(org.orcid.jaxb.model.common_v2.CreditName) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 19 with CreditName

use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.

the class SetUpClientsAndUsers method createUser.

private void createUser(Map<String, String> params) throws Exception {
    // Create it
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
    orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
    if (params.get(MEMBER_TYPE) != null) {
        orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
    }
    orcidProfile.setPassword(params.get(PASSWORD));
    OrcidInternal internal = new OrcidInternal();
    Preferences preferences = new Preferences();
    ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
    visibilityDefaults.setValue(Visibility.PUBLIC);
    preferences.setActivitiesVisibilityDefault(visibilityDefaults);
    internal.setPreferences(preferences);
    orcidProfile.setOrcidInternal(internal);
    Email email = new Email(params.get(EMAIL));
    email.setCurrent(true);
    email.setPrimary(true);
    email.setVerified(true);
    email.setVisibility(Visibility.PUBLIC);
    List<Email> emails = new ArrayList<Email>();
    emails.add(email);
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.setEmail(emails);
    org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
    org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
    creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    personalDetails.setCreditName(creditName);
    personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
    personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
    OrcidBio bio = new OrcidBio();
    bio.setContactDetails(contactDetails);
    bio.setPersonalDetails(personalDetails);
    bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
    orcidProfile.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    history.setClaimed(new Claimed(true));
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    history.setCreationMethod(CreationMethod.DIRECT);
    orcidProfile.setOrcidHistory(history);
    orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
    if (params.containsKey(LOCKED)) {
        orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
    }
    if (params.containsKey(DEVELOPER_TOOLS)) {
        profileEntityManager.enableDeveloperTools(orcidProfile);
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) ArrayList(java.util.ArrayList) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) Biography(org.orcid.jaxb.model.message.Biography) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory)

Example 20 with CreditName

use of org.orcid.jaxb.model.record_rc3.CreditName in project ORCID-Source by ORCID.

the class SetUpClientsAndUsers method clearRegistry.

private boolean clearRegistry(OrcidProfile existingProfile, Map<String, String> params) {
    if (existingProfile != null) {
        String orcid = params.get(ORCID);
        String email = params.get(EMAIL);
        // exception
        if (existingProfile.getOrcidBio() == null || existingProfile.getOrcidBio().getContactDetails() == null || existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail() == null || !email.equals(existingProfile.getOrcidBio().getContactDetails().retrievePrimaryEmail().getValue())) {
            throw new ApplicationException("User with email " + params.get(EMAIL) + " must have orcid id '" + orcid + "' but it is '" + existingProfile.getOrcidId() + "'");
        }
        // Check if the profile have the same password, if not, update the
        // password
        String encryptedPassword = encryptionManager.hashForInternalUse(params.get(PASSWORD));
        if (!encryptedPassword.equals(existingProfile.getPassword())) {
            existingProfile.setPassword(params.get(PASSWORD));
            orcidProfileManager.updatePasswordInformation(existingProfile);
        }
        // Set default names
        Name name = new Name();
        name.setCreditName(new CreditName(params.get(CREDIT_NAME)));
        name.setGivenNames(new GivenNames(params.get(GIVEN_NAMES)));
        name.setFamilyName(new FamilyName(params.get(FAMILY_NAMES)));
        name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility().value()));
        if (recordNameManager.exists(orcid)) {
            recordNameManager.updateRecordName(orcid, name);
        } else {
            recordNameManager.createRecordName(orcid, name);
        }
        profileDao.updatePreferences(orcid, true, true, true, true, org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, true, 1f);
        // Set default bio
        org.orcid.jaxb.model.record_v2.Biography bio = biographyManager.getBiography(orcid, 0L);
        if (bio == null || bio.getContent() == null) {
            bio = new org.orcid.jaxb.model.record_v2.Biography(params.get(BIO));
            bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
            biographyManager.createBiography(orcid, bio);
        } else {
            bio.setContent(params.get(BIO));
            bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility().value()));
            biographyManager.updateBiography(orcid, bio);
        }
        // Remove other names
        List<OtherNameEntity> otherNames = otherNameDao.getOtherNames(orcid, 0L);
        if (otherNames != null && !otherNames.isEmpty()) {
            for (OtherNameEntity otherName : otherNames) {
                otherNameDao.deleteOtherName(otherName);
            }
        }
        // Remove keywords
        List<ProfileKeywordEntity> keywords = profileKeywordDao.getProfileKeywors(orcid, 0L);
        if (keywords != null && !keywords.isEmpty()) {
            for (ProfileKeywordEntity keyword : keywords) {
                profileKeywordDao.deleteProfileKeyword(keyword);
            }
        }
        //Remove researcher urls
        List<ResearcherUrlEntity> rUrls = researcherUrlDao.getResearcherUrls(orcid, 0L);
        if (rUrls != null && !rUrls.isEmpty()) {
            for (ResearcherUrlEntity rUrl : rUrls) {
                researcherUrlDao.deleteResearcherUrl(orcid, rUrl.getId());
            }
        }
        // Remove external ids
        List<ExternalIdentifierEntity> extIds = externalIdentifierDao.getExternalIdentifiers(orcid, System.currentTimeMillis());
        if (extIds != null && !extIds.isEmpty()) {
            for (ExternalIdentifierEntity extId : extIds) {
                externalIdentifierDao.removeExternalIdentifier(orcid, extId.getId());
            }
        }
        // Remove addresses
        List<AddressEntity> addresses = addressDao.getAddresses(orcid, 0L);
        if (addresses != null && !addresses.isEmpty()) {
            for (AddressEntity address : addresses) {
                addressDao.deleteAddress(orcid, address.getId());
            }
        }
        // Remove emails
        List<EmailEntity> emails = emailDao.findByOrcid(orcid);
        if (emails != null && !emails.isEmpty()) {
            for (EmailEntity rc2Email : emails) {
                if (!params.get(EMAIL).equals(rc2Email.getId())) {
                    emailDao.removeEmail(orcid, rc2Email.getId());
                }
            }
        }
        // Remove notifications
        List<NotificationEntity> notifications = notificationDao.findByOrcid(orcid, true, 0, 10000);
        if (notifications != null && !notifications.isEmpty()) {
            for (NotificationEntity notification : notifications) {
                notificationDao.deleteNotificationItemByNotificationId(notification.getId());
                notificationDao.deleteNotificationWorkByNotificationId(notification.getId());
                notificationDao.deleteNotificationById(notification.getId());
            }
        }
        // Remove works
        List<MinimizedWorkEntity> works = workDao.findWorks(orcid, 0L);
        if (works != null && !works.isEmpty()) {
            for (MinimizedWorkEntity work : works) {
                workDao.removeWork(orcid, work.getId());
            }
        }
        // Remove affiliations
        List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
        if (affiliations != null && !affiliations.isEmpty()) {
            for (OrgAffiliationRelationEntity affiliation : affiliations) {
                orgAffiliationRelationDao.remove(affiliation.getId());
            }
        }
        // Remove fundings
        List<ProfileFundingEntity> fundings = profileFundingDao.getByUser(orcid);
        if (fundings != null && !fundings.isEmpty()) {
            for (ProfileFundingEntity funding : fundings) {
                profileFundingDao.removeProfileFunding(orcid, funding.getId());
            }
        }
        // Remove peer reviews
        List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid);
        if (peerReviews != null && !peerReviews.isEmpty()) {
            for (PeerReviewEntity peerReview : peerReviews) {
                peerReviewDao.removePeerReview(orcid, peerReview.getId());
            }
        }
        // Remove 3d party links
        List<OrcidOauth2TokenDetail> tokenDetails = orcidOauth2TokenDetailDao.findByUserName(orcid);
        if (tokenDetails != null && !tokenDetails.isEmpty()) {
            for (OrcidOauth2TokenDetail token : tokenDetails) {
                orcidOauth2TokenDetailDao.remove(token.getId());
            }
        }
        //Unlock just in case it is locked
        profileDao.unlockProfile(orcid);
        return true;
    }
    return false;
}
Also used : ProfileKeywordEntity(org.orcid.persistence.jpa.entities.ProfileKeywordEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Name(org.orcid.jaxb.model.record_v2.Name) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) MinimizedWorkEntity(org.orcid.persistence.jpa.entities.MinimizedWorkEntity) PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) OrcidOauth2TokenDetail(org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail) ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) CreditName(org.orcid.jaxb.model.common_v2.CreditName) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) ApplicationException(org.orcid.core.exception.ApplicationException) OtherNameEntity(org.orcid.persistence.jpa.entities.OtherNameEntity) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

CreditName (org.orcid.jaxb.model.common_v2.CreditName)17 Test (org.junit.Test)14 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)8 CreditName (org.orcid.jaxb.model.record_v2.CreditName)7 FamilyName (org.orcid.jaxb.model.record_v2.FamilyName)7 GivenNames (org.orcid.jaxb.model.record_v2.GivenNames)7 Name (org.orcid.jaxb.model.record_v2.Name)7 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)6 IOException (java.io.IOException)5 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)5 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)4 Contributor (org.orcid.jaxb.model.common_v2.Contributor)3 Country (org.orcid.jaxb.model.common_v2.Country)3 Iso3166Country (org.orcid.jaxb.model.common_v2.Iso3166Country)3 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)3 Title (org.orcid.jaxb.model.common_v2.Title)3 Url (org.orcid.jaxb.model.common_v2.Url)3 CreditName (org.orcid.jaxb.model.record_rc2.CreditName)3