Search in sources :

Example 6 with CreditName

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

the class Api12Helper method addFunding.

protected static void addFunding(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    FundingList fundings = new FundingList();
    Funding funding = new Funding();
    funding.setVisibility(Visibility.LIMITED);
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title(title));
    funding.setTitle(fundingTitle);
    funding.setType(FundingType.SALARY_AWARD);
    Amount amount = new Amount();
    amount.setCurrencyCode("CRC");
    amount.setContent("1,250,000");
    funding.setAmount(amount);
    funding.setStartDate(new FuzzyDate(2010, 1, 1));
    funding.setEndDate(new FuzzyDate(2013, 1, 1));
    funding.setDescription("My Grant description");
    funding.setUrl(new Url("http://url.com"));
    Organization org = new Organization();
    org.setName("Orcid Integration Test Org");
    OrganizationAddress add = new OrganizationAddress();
    add.setCity("My City");
    add.setCountry(Iso3166Country.CR);
    org.setAddress(add);
    funding.setOrganization(org);
    FundingExternalIdentifier extIdentifier = new FundingExternalIdentifier();
    extIdentifier.setType(FundingExternalIdentifierType.fromValue("grant_number"));
    extIdentifier.setUrl(new Url("http://url.com"));
    extIdentifier.setValue("My value");
    FundingExternalIdentifiers extIdentifiers = new FundingExternalIdentifiers();
    extIdentifiers.getFundingExternalIdentifier().add(extIdentifier);
    funding.setFundingExternalIdentifiers(extIdentifiers);
    FundingContributors contributors = new FundingContributors();
    FundingContributor contributor = new FundingContributor();
    contributor.setCreditName(new CreditName("My Credit Name"));
    contributor.setContributorEmail(new ContributorEmail("my.email@orcid-integration-test.com"));
    FundingContributorAttributes attributes = new FundingContributorAttributes();
    attributes.setContributorRole(FundingContributorRole.LEAD);
    contributor.setContributorAttributes(attributes);
    contributors.getContributor().add(contributor);
    funding.setFundingContributors(contributors);
    fundings.getFundings().add(funding);
    orcidMessage.getOrcidProfile().getOrcidActivities().setFundings(fundings);
    ClientResponse clientResponse = oauthT2Client.addFundingXml(userOrcid, orcidMessage, token);
    assertEquals(201, clientResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Organization(org.orcid.jaxb.model.message.Organization) Funding(org.orcid.jaxb.model.message.Funding) Amount(org.orcid.jaxb.model.message.Amount) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FundingContributor(org.orcid.jaxb.model.message.FundingContributor) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) CreditName(org.orcid.jaxb.model.message.CreditName) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) ContributorEmail(org.orcid.jaxb.model.message.ContributorEmail) Url(org.orcid.jaxb.model.message.Url) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) FundingContributors(org.orcid.jaxb.model.message.FundingContributors) FundingContributorAttributes(org.orcid.jaxb.model.message.FundingContributorAttributes) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers)

Example 7 with CreditName

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

the class ManageDelegatorsController method getDelegatorsPlusMeJson.

@RequestMapping(value = "/delegators-and-me.json", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getDelegatorsPlusMeJson() throws NoSuchRequestHandlingMethodException {
    Map<String, Object> map = new HashMap<>();
    OrcidProfile realProfile = getRealProfile();
    Delegation delegation = realProfile.getOrcidBio().getDelegation();
    if (delegation != null) {
        GivenPermissionBy givenPermissionBy = delegation.getGivenPermissionBy();
        String currentOrcid = getEffectiveUserOrcid();
        if (givenPermissionBy != null) {
            for (Iterator<DelegationDetails> delegationDetailsIterator = givenPermissionBy.getDelegationDetails().iterator(); delegationDetailsIterator.hasNext(); ) {
                if (currentOrcid.equals(delegationDetailsIterator.next().getDelegateSummary().getOrcidIdentifier().getPath())) {
                    delegationDetailsIterator.remove();
                }
            }
        }
        map.put("delegators", givenPermissionBy);
    }
    if (sourceManager.isInDelegationMode()) {
        // Add me, so I can switch back to me
        DelegationDetails details = new DelegationDetails();
        DelegateSummary summary = new DelegateSummary();
        details.setDelegateSummary(summary);
        String displayName = realProfile.getOrcidBio().getPersonalDetails().retrieveDisplayNameIgnoringVisibility();
        summary.setCreditName(new CreditName(displayName));
        summary.setOrcidIdentifier(realProfile.getOrcidIdentifier());
        map.put("me", details);
    }
    return map;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) GivenPermissionBy(org.orcid.jaxb.model.message.GivenPermissionBy) DelegateSummary(org.orcid.jaxb.model.message.DelegateSummary) HashMap(java.util.HashMap) CreditName(org.orcid.jaxb.model.message.CreditName) DelegationDetails(org.orcid.jaxb.model.message.DelegationDetails) Delegation(org.orcid.jaxb.model.message.Delegation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with CreditName

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

the class OrcidJaxbCopyManagerImpl method copyCreditNamePreservingVisibility.

private void copyCreditNamePreservingVisibility(PersonalDetails existingPersonalDetails, PersonalDetails updatedPersonalDetails) {
    CreditName existingCreditName = existingPersonalDetails.getCreditName();
    CreditName updatedCreditName = updatedPersonalDetails.getCreditName();
    // if no update, nothing to do
    if (updatedCreditName == null) {
        return;
    }
    // otherwise take into account the visibility of updated and existing
    Visibility existingVisibility = (existingCreditName != null && existingCreditName.getVisibility() != null) ? existingCreditName.getVisibility() : OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility();
    // If it is private, ignore the request
    if (!existingVisibility.equals(Visibility.PRIVATE)) {
        Visibility updatedVisibility = (updatedCreditName != null && updatedCreditName.getVisibility() != null) ? updatedCreditName.getVisibility() : existingVisibility;
        updatedCreditName.setVisibility(updatedVisibility);
        // now visibility has been preserved, overwrite the content
        existingPersonalDetails.setCreditName(updatedCreditName);
    }
}
Also used : CreditName(org.orcid.jaxb.model.message.CreditName) Visibility(org.orcid.jaxb.model.message.Visibility)

Example 9 with CreditName

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

the class OrcidIndexManagerImplTest method getStandardOrcid.

private OrcidProfile getStandardOrcid() {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier("1234");
    OrcidBio orcidBio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    Email email = new Email("email");
    email.setVisibility(Visibility.PUBLIC);
    contactDetails.addOrReplacePrimaryEmail(email);
    orcidBio.setContactDetails(contactDetails);
    Keywords bioKeywords = new Keywords();
    bioKeywords.getKeyword().add(new Keyword("Pavement Studies", Visibility.PUBLIC));
    bioKeywords.getKeyword().add(new Keyword("Advanced Tea Making", Visibility.PUBLIC));
    bioKeywords.setVisibility(Visibility.PUBLIC);
    orcidBio.setKeywords(bioKeywords);
    PersonalDetails personalDetails = new PersonalDetails();
    CreditName creditName = new CreditName("credit name");
    creditName.setVisibility(Visibility.PUBLIC);
    personalDetails.setCreditName(creditName);
    FamilyName familyName = new FamilyName("familyName");
    familyName.setVisibility(Visibility.PUBLIC);
    personalDetails.setFamilyName(familyName);
    OtherNames otherNames = new OtherNames();
    otherNames.setVisibility(Visibility.PUBLIC);
    otherNames.getOtherName().add(new OtherName("Other 1", Visibility.PUBLIC));
    otherNames.getOtherName().add(new OtherName("Other 2", Visibility.PUBLIC));
    personalDetails.setOtherNames(otherNames);
    GivenNames givenNames = new GivenNames("givenNames");
    givenNames.setVisibility(Visibility.PUBLIC);
    personalDetails.setGivenNames(givenNames);
    orcidBio.setPersonalDetails(personalDetails);
    ExternalIdentifiers externalIdentifiers = new ExternalIdentifiers();
    externalIdentifiers.setVisibility(Visibility.PUBLIC);
    orcidBio.setExternalIdentifiers(externalIdentifiers);
    ExternalIdentifier externalIdentifier1 = createExternalIdentifier("45678", "defghi");
    externalIdentifiers.getExternalIdentifier().add(externalIdentifier1);
    ExternalIdentifier externalIdentifier2 = createExternalIdentifier("54321", "abc123");
    externalIdentifiers.getExternalIdentifier().add(externalIdentifier2);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    FundingList fundings = new FundingList();
    orcidActivities.setFundings(fundings);
    OrcidWorks orcidWorks = new OrcidWorks();
    OrcidWork orcidWork1 = new OrcidWork();
    orcidWork1.setVisibility(Visibility.PUBLIC);
    OrcidWork orcidWork2 = new OrcidWork();
    orcidWork2.setVisibility(Visibility.PUBLIC);
    OrcidWork orcidWork3 = new OrcidWork();
    orcidWork3.setVisibility(Visibility.LIMITED);
    WorkTitle workTitle1 = new WorkTitle();
    Title title1 = new Title("Work title 1");
    workTitle1.setTitle(title1);
    workTitle1.setSubtitle(null);
    orcidWork1.setWorkTitle(workTitle1);
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    orcidWork1.setWorkExternalIdentifiers(new WorkExternalIdentifiers(Arrays.asList(wei)));
    WorkTitle workTitle2 = new WorkTitle();
    Title title2 = new Title("Work title 2");
    workTitle2.setSubtitle(null);
    workTitle2.setTitle(title2);
    orcidWork2.setWorkTitle(workTitle2);
    WorkTitle workTitle3 = new WorkTitle();
    Title title3 = new Title("Work Title 3");
    workTitle3.setSubtitle(null);
    workTitle3.setTitle(title3);
    orcidWork3.setWorkTitle(workTitle3);
    orcidWorks.setOrcidWork(new ArrayList<OrcidWork>(Arrays.asList(new OrcidWork[] { orcidWork1, orcidWork2, orcidWork3 })));
    orcidProfile.setOrcidWorks(orcidWorks);
    orcidProfile.setOrcidBio(orcidBio);
    return orcidProfile;
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Keyword(org.orcid.jaxb.model.message.Keyword) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) FundingList(org.orcid.jaxb.model.message.FundingList) Affiliations(org.orcid.jaxb.model.message.Affiliations) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Example 10 with CreditName

use of org.orcid.jaxb.model.message.CreditName 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)

Aggregations

CreditName (org.orcid.jaxb.model.message.CreditName)24 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)14 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)14 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)14 GivenNames (org.orcid.jaxb.model.message.GivenNames)11 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)9 FamilyName (org.orcid.jaxb.model.message.FamilyName)9 OtherNames (org.orcid.jaxb.model.message.OtherNames)8 Email (org.orcid.jaxb.model.message.Email)7 Test (org.junit.Test)6 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)6 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)6 Url (org.orcid.jaxb.model.message.Url)6 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)5 Keyword (org.orcid.jaxb.model.message.Keyword)5 Keywords (org.orcid.jaxb.model.message.Keywords)5 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)5 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)5 Biography (org.orcid.jaxb.model.message.Biography)4 Contributor (org.orcid.jaxb.model.message.Contributor)4