Search in sources :

Example 31 with CreditName

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

the class ValidateV2_1SamplesTest method testMarshallCreditName.

@Test
public void testMarshallCreditName() throws JAXBException, SAXException, URISyntaxException {
    CreditName object = (CreditName) unmarshallFromPath("/record_2.1/samples/read_samples/credit-name-2.1.xml", CreditName.class);
    marshall(object, "/record_2.1/personal-details-2.1.xsd");
}
Also used : CreditName(org.orcid.jaxb.model.record_v2.CreditName) Test(org.junit.Test)

Example 32 with CreditName

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

the class ValidateV2SamplesTest method testMarshallCreditName.

@Test
public void testMarshallCreditName() throws JAXBException, SAXException, URISyntaxException {
    CreditName object = (CreditName) unmarshallFromPath("/record_2.0/samples/read_samples/credit-name-2.0.xml", CreditName.class);
    marshall(object, "/record_2.0/personal-details-2.0.xsd");
}
Also used : CreditName(org.orcid.jaxb.model.record_v2.CreditName) Test(org.junit.Test)

Example 33 with CreditName

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

the class ValidateV2SamplesTest method testUnmarshallCreditName.

@Test
public void testUnmarshallCreditName() throws SAXException, URISyntaxException {
    CreditName creditName = (CreditName) unmarshallFromPath("/record_2.0/samples/read_samples/credit-name-2.0.xml", CreditName.class, "/record_2.0/personal-details-2.0.xsd");
    assertNotNull(creditName);
    assertEquals("credit-name", creditName.getContent());
}
Also used : CreditName(org.orcid.jaxb.model.record_v2.CreditName) Test(org.junit.Test)

Example 34 with CreditName

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

the class PublicV2ApiServiceDelegatorImpl method viewWorkCitation.

@Override
public Response viewWorkCitation(String orcid, Long putCode) {
    Work w = (Work) this.viewWork(orcid, putCode).getEntity();
    ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
    String creditName = null;
    RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
    if (recordNameEntity != null) {
        if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(Visibility.PUBLIC)) {
            creditName = recordNameEntity.getCreditName();
            if (StringUtils.isBlank(creditName)) {
                creditName = recordNameEntity.getGivenNames();
                String familyName = recordNameEntity.getFamilyName();
                if (StringUtils.isNotBlank(familyName)) {
                    creditName += " " + familyName;
                }
            }
        }
    }
    WorkToCiteprocTranslator tran = new WorkToCiteprocTranslator();
    CSLItemData item = tran.toCiteproc(w, creditName, true);
    return Response.ok(item).build();
}
Also used : CSLItemData(de.undercouch.citeproc.csl.CSLItemData) Work(org.orcid.jaxb.model.record_v2.Work) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) WorkToCiteprocTranslator(org.orcid.api.common.writer.citeproc.WorkToCiteprocTranslator) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 35 with CreditName

use of org.orcid.jaxb.model.record_v2.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);
        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.getProfileKeywords(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, profileEntityManager.getLastModified(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<WorkLastModifiedEntity> works = workDao.getWorkLastModifiedList(orcid);
        if (works != null && !works.isEmpty()) {
            for (WorkLastModifiedEntity 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, profileEntityManager.getLastModified(orcid));
        if (fundings != null && !fundings.isEmpty()) {
            for (ProfileFundingEntity funding : fundings) {
                profileFundingDao.removeProfileFunding(orcid, funding.getId());
            }
        }
        // Remove peer reviews
        List<PeerReviewEntity> peerReviews = peerReviewDao.getByUser(orcid, profileEntityManager.getLastModified(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) WorkLastModifiedEntity(org.orcid.persistence.jpa.entities.WorkLastModifiedEntity) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) 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

Test (org.junit.Test)17 CreditName (org.orcid.jaxb.model.common_v2.CreditName)16 Name (org.orcid.jaxb.model.record_v2.Name)10 CreditName (org.orcid.jaxb.model.record_v2.CreditName)9 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)9 FamilyName (org.orcid.jaxb.model.record_v2.FamilyName)8 GivenNames (org.orcid.jaxb.model.record_v2.GivenNames)8 IOException (java.io.IOException)5 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 Contributor (org.orcid.jaxb.model.common_v2.Contributor)5 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)5 Biography (org.orcid.jaxb.model.record_v2.Biography)4 Work (org.orcid.jaxb.model.record_v2.Work)4 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)3 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)3 CreditName (org.orcid.jaxb.model.record_rc2.CreditName)3 CreditName (org.orcid.jaxb.model.record_rc4.CreditName)3