Search in sources :

Example 6 with Country

use of org.orcid.jaxb.model.v3.dev1.common.Country in project ORCID-Source by ORCID.

the class FundingForm method toFunding.

public Funding toFunding() {
    Funding result = new Funding();
    Amount orcidAmount = new Amount();
    if (!PojoUtil.isEmpty(amount))
        orcidAmount.setContent(amount.getValue());
    if (!PojoUtil.isEmpty(currencyCode))
        orcidAmount.setCurrencyCode(currencyCode.getValue());
    result.setAmount(orcidAmount);
    if (!PojoUtil.isEmpty(description))
        result.setDescription(description.getValue());
    if (!PojoUtil.isEmpty(startDate))
        result.setStartDate(new FuzzyDate(startDate.toFuzzyDate()));
    if (!PojoUtil.isEmpty(endDate))
        result.setEndDate(new FuzzyDate(endDate.toFuzzyDate()));
    if (!PojoUtil.isEmpty(putCode))
        result.setPutCode(Long.valueOf(putCode.getValue()));
    if (fundingTitle != null) {
        result.setTitle(fundingTitle.toFundingTitle());
    }
    if (!PojoUtil.isEmpty(fundingType))
        result.setType(FundingType.fromValue(fundingType.getValue()));
    if (organizationDefinedFundingSubType != null && !PojoUtil.isEmpty(organizationDefinedFundingSubType.getSubtype()))
        result.setOrganizationDefinedType(new OrganizationDefinedFundingSubType(organizationDefinedFundingSubType.getSubtype().getValue()));
    if (!PojoUtil.isEmpty(url))
        result.setUrl(new Url(url.getValue()));
    else
        result.setUrl(new Url());
    if (visibility != null)
        result.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
    // Set Organization
    Organization organization = new Organization();
    if (!PojoUtil.isEmpty(fundingName))
        organization.setName(fundingName.getValue());
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    if (!PojoUtil.isEmpty(city))
        organizationAddress.setCity(city.getValue());
    if (!PojoUtil.isEmpty(region)) {
        organizationAddress.setRegion(region.getValue());
    }
    if (!PojoUtil.isEmpty(country)) {
        organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
    }
    if (!PojoUtil.isEmpty(disambiguatedFundingSourceId)) {
        organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
        organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedFundingSourceId.getValue());
        organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
    }
    result.setOrganization(organization);
    // Set contributors
    if (contributors != null && !contributors.isEmpty()) {
        FundingContributors fContributors = new FundingContributors();
        for (Contributor contributor : contributors) {
            if (!PojoUtil.isEmtpy(contributor))
                fContributors.getContributor().add(contributor.toFundingContributor());
        }
        result.setContributors(fContributors);
    }
    // Set external identifiers
    if (externalIdentifiers != null && !externalIdentifiers.isEmpty()) {
        ExternalIDs fExternalIdentifiers = new ExternalIDs();
        for (FundingExternalIdentifierForm fExternalIdentifier : externalIdentifiers) {
            if (!PojoUtil.isEmtpy(fExternalIdentifier))
                fExternalIdentifiers.getExternalIdentifier().add(fExternalIdentifier.toFundingExternalIdentifier());
        }
        result.setExternalIdentifiers(fExternalIdentifiers);
    }
    return result;
}
Also used : Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Amount(org.orcid.jaxb.model.v3.dev1.common.Amount) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) FundingContributors(org.orcid.jaxb.model.v3.dev1.record.FundingContributors) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Url(org.orcid.jaxb.model.v3.dev1.common.Url) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.v3.dev1.common.OrganizationDefinedFundingSubType)

Example 7 with Country

use of org.orcid.jaxb.model.v3.dev1.common.Country in project ORCID-Source by ORCID.

the class WorksController method getWorkInfo.

/**
 * Returns a blank work
 */
@RequestMapping(value = "/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@RequestParam(value = "workId") Long workId) {
    Map<String, String> countries = retrieveIsoCountries();
    Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
    if (workId == null)
        return null;
    Work work = workManager.getWork(this.getEffectiveUserOrcid(), workId);
    if (work != null) {
        WorkForm workForm = WorkForm.valueOf(work);
        if (workForm.getPublicationDate() == null) {
            initializePublicationDate(workForm);
        } else {
            if (workForm.getPublicationDate().getDay() == null) {
                workForm.getPublicationDate().setDay(new String());
            }
            if (workForm.getPublicationDate().getMonth() == null) {
                workForm.getPublicationDate().setMonth(new String());
            }
            if (workForm.getPublicationDate().getYear() == null) {
                workForm.getPublicationDate().setYear(new String());
            }
        }
        // Set country name
        if (!PojoUtil.isEmpty(workForm.getCountryCode())) {
            Text countryName = Text.valueOf(countries.get(workForm.getCountryCode().getValue()));
            workForm.setCountryName(countryName);
        }
        // Set language name
        if (!PojoUtil.isEmpty(workForm.getLanguageCode())) {
            Text languageName = Text.valueOf(languages.get(workForm.getLanguageCode().getValue()));
            workForm.setLanguageName(languageName);
        }
        // Set translated title language name
        if (!(workForm.getTranslatedTitle() == null) && !StringUtils.isEmpty(workForm.getTranslatedTitle().getLanguageCode())) {
            String languageName = languages.get(workForm.getTranslatedTitle().getLanguageCode());
            workForm.getTranslatedTitle().setLanguageName(languageName);
        }
        if (workForm.getContributors() != null) {
            for (Contributor contributor : workForm.getContributors()) {
                if (!PojoUtil.isEmpty(contributor.getOrcid())) {
                    String contributorOrcid = contributor.getOrcid().getValue();
                    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 = activityManager.getPublicCreditName(profileEntity);
                        contributor.setCreditName(Text.valueOf(publicContributorCreditName));
                    }
                }
            }
        }
        return workForm;
    }
    return null;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Contributor(org.orcid.pojo.ajaxForm.Contributor) Text(org.orcid.pojo.ajaxForm.Text) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with Country

use of org.orcid.jaxb.model.v3.dev1.common.Country in project ORCID-Source by ORCID.

the class WorkFormTest method getWork.

public static Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    Date date = new Date();
    work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
    work.setJournalTitle(new Title("Journal Title"));
    work.setLanguageCode("EN");
    work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
    work.setPutCode(Long.valueOf("12345"));
    work.setShortDescription("Short description");
    work.setUrl(new Url("http://test.com"));
    work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED);
    work.setWorkCitation(new org.orcid.jaxb.model.v3.dev1.record.Citation("Citation", CitationType.BIBTEX));
    WorkContributors contributors = new WorkContributors();
    org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
    contributor.setCreditName(new CreditName("Credit name"));
    contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
    ContributorAttributes att = new ContributorAttributes();
    att.setContributorRole(ContributorRole.ASSIGNEE);
    att.setContributorSequence(SequenceType.FIRST);
    contributor.setContributorAttributes(att);
    contributors.getContributor().add(contributor);
    work.setWorkContributors(contributors);
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei = new ExternalID();
    wei.setRelationship(Relationship.SELF);
    wei.setUrl(new Url("http://test.com"));
    wei.setValue("ID");
    wei.setType(WorkExternalIdentifierType.AGR.value());
    weis.getExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Work Title"));
    workTitle.setSubtitle(new Subtitle("Subtitle"));
    TranslatedTitle translated = new TranslatedTitle("Translated", "US");
    workTitle.setTranslatedTitle(translated);
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Month(org.orcid.jaxb.model.v3.dev1.common.Month) Work(org.orcid.jaxb.model.v3.dev1.record.Work) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Date(java.util.Date) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) Year(org.orcid.jaxb.model.v3.dev1.common.Year) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) Iso3166Country(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country) Country(org.orcid.jaxb.model.v3.dev1.common.Country) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) Day(org.orcid.jaxb.model.v3.dev1.common.Day)

Example 9 with Country

use of org.orcid.jaxb.model.v3.dev1.common.Country in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getWork.

public Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    work.setJournalTitle(new Title("journal-title"));
    work.setLanguageCode("en");
    work.setPublicationDate(new PublicationDate(getFuzzyDate()));
    work.setShortDescription("short-description");
    work.setUrl(new Url("http://test.orcid.org"));
    work.setVisibility(Visibility.PUBLIC);
    work.setWorkCitation(new Citation("citation", CitationType.FORMATTED_HARVARD));
    ContributorAttributes attributes = new ContributorAttributes();
    attributes.setContributorRole(ContributorRole.ASSIGNEE);
    attributes.setContributorSequence(SequenceType.FIRST);
    ContributorOrcid contributorOrcid = new ContributorOrcid();
    contributorOrcid.setHost("http://test.orcid.org");
    contributorOrcid.setPath("0000-0000-0000-0000");
    contributorOrcid.setUri("https://test.orcid.org/0000-0000-0000-0000");
    Contributor contributor = new Contributor();
    contributor.setContributorAttributes(attributes);
    contributor.setContributorOrcid(contributorOrcid);
    contributor.setCreditName(new CreditName("credit name"));
    contributor.setContributorEmail(new ContributorEmail("email@test.orcid.org"));
    WorkContributors contributors = new WorkContributors(Stream.of(contributor).collect(Collectors.toList()));
    work.setWorkContributors(contributors);
    work.setWorkExternalIdentifiers(getExternalIDs());
    work.setWorkTitle(getWorkTitle());
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    return work;
}
Also used : PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes) FundingContributorAttributes(org.orcid.jaxb.model.v3.dev1.record.FundingContributorAttributes) WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) Work(org.orcid.jaxb.model.v3.dev1.record.Work) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) Country(org.orcid.jaxb.model.v3.dev1.common.Country) Iso3166Country(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 10 with Country

use of org.orcid.jaxb.model.v3.dev1.common.Country in project ORCID-Source by ORCID.

the class AddressForm method toAddress.

public Address toAddress() {
    Address address = new Address();
    if (this.iso2Country != null && this.iso2Country.getValue() != null) {
        Country country = new Country();
        country.setValue(Iso3166Country.fromValue(this.iso2Country.getValue().value()));
        address.setCountry(country);
    }
    if (this.visibility != null && this.visibility.getVisibility() != null) {
        address.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(this.getVisibility().getVisibility().value()));
    }
    if (!PojoUtil.isEmpty(this.getPutCode())) {
        address.setPutCode(Long.valueOf(this.getPutCode()));
    }
    if (displayIndex != null) {
        address.setDisplayIndex(displayIndex);
    } else {
        address.setDisplayIndex(0L);
    }
    address.setSource(new Source(source));
    return address;
}
Also used : Address(org.orcid.jaxb.model.v3.dev1.record.Address) Iso3166Country(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country) Country(org.orcid.jaxb.model.v3.dev1.common.Country) Source(org.orcid.jaxb.model.v3.dev1.common.Source)

Aggregations

Iso3166Country (org.orcid.jaxb.model.v3.dev1.common.Iso3166Country)8 Country (org.orcid.jaxb.model.v3.dev1.common.Country)7 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 Url (org.orcid.jaxb.model.v3.dev1.common.Url)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)4 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)4 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)4 Title (org.orcid.jaxb.model.v3.dev1.common.Title)4 Address (org.orcid.jaxb.model.v3.dev1.record.Address)4 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)3 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)3 Day (org.orcid.jaxb.model.v3.dev1.common.Day)3 Month (org.orcid.jaxb.model.v3.dev1.common.Month)3 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)3 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)3