Search in sources :

Example 1 with ContributorOrcid

use of org.orcid.jaxb.model.message.ContributorOrcid in project ORCID-Source by ORCID.

the class CurrentWorkContributor method getContributor.

public Contributor getContributor() {
    Contributor contributor = new Contributor();
    if (StringUtils.isNotBlank(orcid)) {
        contributor.setContributorOrcid(new ContributorOrcid(orcid));
    }
    if (StringUtils.isNotBlank(creditName)) {
        contributor.setCreditName(new CreditName(creditName));
    }
    if (StringUtils.isNotBlank(email)) {
        contributor.setContributorEmail(new ContributorEmail(email));
    }
    if (StringUtils.isNotBlank(role)) {
        ContributorAttributes attributes = retrieveContributorAttributes(contributor);
        ContributorRole contributorRole = ContributorRole.fromValue(role);
        attributes.setContributorRole(contributorRole);
    }
    if (StringUtils.isNotBlank(sequence)) {
        ContributorAttributes attributes = retrieveContributorAttributes(contributor);
        SequenceType sequenceType = SequenceType.fromValue(sequence);
        attributes.setContributorSequence(sequenceType);
    }
    return contributor;
}
Also used : ContributorRole(org.orcid.jaxb.model.message.ContributorRole) ContributorAttributes(org.orcid.jaxb.model.message.ContributorAttributes) CreditName(org.orcid.jaxb.model.message.CreditName) Contributor(org.orcid.jaxb.model.message.Contributor) ContributorOrcid(org.orcid.jaxb.model.message.ContributorOrcid) SequenceType(org.orcid.jaxb.model.message.SequenceType) ContributorEmail(org.orcid.jaxb.model.message.ContributorEmail)

Example 2 with ContributorOrcid

use of org.orcid.jaxb.model.message.ContributorOrcid in project ORCID-Source by ORCID.

the class CheckAndFixContributorNameVisibility method processOrcid.

private void processOrcid(final String orcid) {
    LOG.info("Checking and fixing profile: {}", orcid);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
            OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
            if (orcidWorks != null) {
                for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
                    WorkContributors workContributors = orcidWork.getWorkContributors();
                    if (workContributors != null) {
                        for (Contributor contributor : workContributors.getContributor()) {
                            ContributorOrcid contributorOrcid = contributor.getContributorOrcid();
                            if (contributorOrcid != null) {
                                String orcid = contributorOrcid.getPath();
                                ProfileEntity contributorProfile = profileDao.find(orcid);
                                if (contributorProfile.getRecordNameEntity() != null && contributorProfile.getRecordNameEntity().getVisibility() != null) {
                                    if (!Visibility.PUBLIC.value().equals(contributorProfile.getRecordNameEntity().getVisibility().value())) {
                                        contributor.setCreditName(null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            orcidProfileManager.updateOrcidProfile(orcidProfile);
        }
    });
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkContributors(org.orcid.jaxb.model.message.WorkContributors) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) TransactionStatus(org.springframework.transaction.TransactionStatus) Contributor(org.orcid.jaxb.model.message.Contributor) ContributorOrcid(org.orcid.jaxb.model.message.ContributorOrcid) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

Contributor (org.orcid.jaxb.model.message.Contributor)2 ContributorOrcid (org.orcid.jaxb.model.message.ContributorOrcid)2 ContributorAttributes (org.orcid.jaxb.model.message.ContributorAttributes)1 ContributorEmail (org.orcid.jaxb.model.message.ContributorEmail)1 ContributorRole (org.orcid.jaxb.model.message.ContributorRole)1 CreditName (org.orcid.jaxb.model.message.CreditName)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)1 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)1 SequenceType (org.orcid.jaxb.model.message.SequenceType)1 WorkContributors (org.orcid.jaxb.model.message.WorkContributors)1 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1