Search in sources :

Example 1 with Contributor

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

the class WorkFormTest method getWork.

private Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    work.setJournalTitle(new Title("Journal title"));
    work.setLanguageCode("en");
    work.setPutCode(Long.valueOf("1"));
    work.setShortDescription("Short description");
    work.setSource(new org.orcid.jaxb.model.v3.dev1.common.Source("0000-0000-0000-0000"));
    work.setUrl(new Url("http://myurl.com"));
    work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC);
    org.orcid.jaxb.model.v3.dev1.record.Citation citation = new org.orcid.jaxb.model.v3.dev1.record.Citation();
    citation.setCitation("Citation");
    citation.setWorkCitationType(CitationType.FORMATTED_UNSPECIFIED);
    work.setWorkCitation(citation);
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("Title"));
    title.setTranslatedTitle(new org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle("Translated Title", "es"));
    title.setSubtitle(new Subtitle("Subtitle"));
    work.setWorkTitle(title);
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    Date date = new Date();
    date.setDay("1");
    date.setMonth("1");
    date.setYear("2015");
    GregorianCalendar calendar = date.toCalendar();
    work.setCreatedDate(new CreatedDate(datatypeFactory.newXMLGregorianCalendar(calendar)));
    date = new Date();
    date.setDay("2");
    date.setMonth("2");
    date.setYear("2015");
    calendar = date.toCalendar();
    work.setLastModifiedDate(new LastModifiedDate(datatypeFactory.newXMLGregorianCalendar(calendar)));
    work.setPublicationDate(new PublicationDate(new Year(2015), new Month(3), new Day(3)));
    org.orcid.jaxb.model.v3.dev1.record.WorkContributors contributors = new org.orcid.jaxb.model.v3.dev1.record.WorkContributors();
    org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
    org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes attributes = new org.orcid.jaxb.model.v3.dev1.common.ContributorAttributes();
    attributes.setContributorRole(org.orcid.jaxb.model.v3.dev1.common.ContributorRole.CO_INVENTOR);
    attributes.setContributorSequence(org.orcid.jaxb.model.v3.dev1.record.SequenceType.FIRST);
    contributor.setContributorAttributes(attributes);
    contributor.setContributorEmail(null);
    ContributorOrcid contributorOrcid = new ContributorOrcid("Contributor orcid");
    contributorOrcid.setUri("Contributor uri");
    contributor.setContributorOrcid(contributorOrcid);
    CreditName creditName = new CreditName("Contributor credit name");
    contributor.setCreditName(creditName);
    contributors.getContributor().add(contributor);
    work.setWorkContributors(contributors);
    ExternalIDs externalIdentifiers = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setValue("External Identifier ID");
    extId.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ASIN.value());
    extId.setRelationship(Relationship.SELF);
    externalIdentifiers.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(externalIdentifiers);
    return work;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Contributor(org.orcid.pojo.ajaxForm.Contributor) 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) Citation(org.orcid.pojo.ajaxForm.Citation) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) GregorianCalendar(java.util.GregorianCalendar) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) Date(org.orcid.pojo.ajaxForm.Date) Subtitle(org.orcid.jaxb.model.v3.dev1.common.Subtitle) Year(org.orcid.jaxb.model.v3.dev1.common.Year) 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 2 with Contributor

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

the class WorkFormTest method getWorkForm.

private WorkForm getWorkForm() {
    WorkForm form = new WorkForm();
    form.setCitation(new Citation("Citation", "formatted-unspecified"));
    List<Contributor> çontributors = new ArrayList<Contributor>();
    Contributor contributor = new Contributor();
    contributor.setContributorRole(Text.valueOf("co_inventor"));
    contributor.setContributorSequence(Text.valueOf("first"));
    contributor.setCreditName(Text.valueOf("Contributor credit name"));
    contributor.setEmail(null);
    contributor.setOrcid(Text.valueOf("Contributor orcid"));
    contributor.setUri(Text.valueOf("Contributor uri"));
    çontributors.add(contributor);
    form.setContributors(çontributors);
    form.setCountryCode(Text.valueOf("US"));
    Date createdDate = new Date();
    createdDate.setDay("1");
    createdDate.setMonth("1");
    createdDate.setYear("2015");
    form.setCreatedDate(createdDate);
    form.setJournalTitle(Text.valueOf("Journal title"));
    form.setLanguageCode(Text.valueOf("en"));
    Date lastModifiedDate = new Date();
    lastModifiedDate.setDay("2");
    lastModifiedDate.setMonth("2");
    lastModifiedDate.setYear("2015");
    form.setLastModified(lastModifiedDate);
    Date publicationDate = new Date();
    publicationDate.setDay("03");
    publicationDate.setMonth("03");
    publicationDate.setYear("2015");
    form.setPublicationDate(publicationDate);
    form.setDateSortString(PojoUtil.createDateSortString(null, FuzzyDate.valueOf(2015, 3, 3)));
    form.setPutCode(Text.valueOf("1"));
    form.setShortDescription(Text.valueOf("Short description"));
    form.setSource("0000-0000-0000-0000");
    form.setSubtitle(Text.valueOf("Subtitle"));
    form.setTitle(Text.valueOf("Title"));
    form.setTranslatedTitle(new TranslatedTitleForm("Translated Title", "es"));
    form.setUrl(Text.valueOf("http://myurl.com"));
    form.setVisibility(Visibility.valueOf(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC));
    List<WorkExternalIdentifier> extIds = new ArrayList<WorkExternalIdentifier>();
    WorkExternalIdentifier extId = new WorkExternalIdentifier();
    extId.setWorkExternalIdentifierId(Text.valueOf("External Identifier ID"));
    extId.setWorkExternalIdentifierType(Text.valueOf("asin"));
    extId.setRelationship(Text.valueOf(Relationship.SELF.value()));
    extIds.add(extId);
    form.setWorkExternalIdentifiers(extIds);
    form.setWorkType(Text.valueOf("artistic-performance"));
    WorkCategory category = WorkCategory.fromWorkType(WorkType.fromValue(form.getWorkType().getValue()));
    form.setWorkCategory(Text.valueOf(category.value()));
    return form;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Citation(org.orcid.pojo.ajaxForm.Citation) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) WorkCategory(org.orcid.jaxb.model.v3.dev1.record.WorkCategory) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) Date(org.orcid.pojo.ajaxForm.Date) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

Example 3 with Contributor

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

the class Contributor method valueOf.

public static Contributor valueOf(FundingContributor contributor) {
    Contributor c = new Contributor();
    if (contributor != null) {
        if (contributor.getContributorAttributes() != null) {
            contributor.getContributorAttributes();
            if (contributor.getContributorAttributes().getContributorRole() != null)
                c.setContributorRole(Text.valueOf(contributor.getContributorAttributes().getContributorRole().value()));
        }
        if (contributor.getContributorOrcid() != null) {
            c.setOrcid(Text.valueOf(contributor.getContributorOrcid().getPath()));
            c.setUri(Text.valueOf(contributor.getContributorOrcid().getUri()));
        }
        if (contributor.getCreditName() != null) {
            c.setCreditName(Text.valueOf(contributor.getCreditName().getContent()));
        }
    }
    return c;
}
Also used : FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor)

Example 4 with Contributor

use of org.orcid.jaxb.model.v3.dev1.common.Contributor 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 5 with Contributor

use of org.orcid.jaxb.model.v3.dev1.common.Contributor 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)

Aggregations

FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)24 Work (org.orcid.jaxb.model.v3.dev1.record.Work)14 Contributor (org.orcid.jaxb.model.v3.dev1.common.Contributor)12 CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)11 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)11 Test (org.junit.Test)10 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)10 Title (org.orcid.jaxb.model.v3.dev1.common.Title)9 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)9 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)8 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)7 ContributorEmail (org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)6 WorkContributors (org.orcid.jaxb.model.v3.dev1.record.WorkContributors)6 ArrayList (java.util.ArrayList)5 Contributor (org.orcid.pojo.ajaxForm.Contributor)5 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)4 Url (org.orcid.jaxb.model.v3.dev1.common.Url)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)4 Amount (org.orcid.jaxb.model.v3.dev1.common.Amount)3 Country (org.orcid.jaxb.model.v3.dev1.common.Country)3