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());
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations