Search in sources :

Example 6 with Contributor

use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.

the class WorksControllerTest method testGetWorkInfoWithContributors.

@Test
public void testGetWorkInfoWithContributors() throws Exception {
    WorkForm work = worksController.getWorkInfo(Long.valueOf("5"));
    assertNotNull(work);
    assertNotNull(work.getContributors());
    assertEquals(4, work.getContributors().size());
    Contributor contributor = work.getContributors().get(0);
    assertNull(contributor.getEmail());
    assertEquals("Jaylen Kessler", contributor.getCreditName().getValue());
    contributor = work.getContributors().get(1);
    assertNull(contributor.getEmail());
    assertEquals("John Smith", contributor.getCreditName().getValue());
    contributor = work.getContributors().get(2);
    assertNull(contributor.getEmail());
    assertEquals("Credit Name", contributor.getCreditName().getValue());
    // contributor is an ORCID user with private name
    contributor = work.getContributors().get(3);
    assertNull(contributor.getEmail());
    assertNull(contributor.getCreditName().getValue());
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Contributor(org.orcid.pojo.ajaxForm.Contributor) WorkFormTest(orcid.pojo.ajaxForm.WorkFormTest) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 7 with Contributor

use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.

the class FundingsController method getFunding.

/**
     * Returns a blank funding form
     * */
@RequestMapping(value = "/funding.json", method = RequestMethod.GET)
@ResponseBody
public FundingForm getFunding() {
    FundingForm result = new FundingForm();
    result.setAmount(new Text());
    result.setCurrencyCode(Text.valueOf(""));
    result.setDescription(new Text());
    result.setFundingName(new Text());
    result.setFundingType(Text.valueOf(""));
    result.setSourceName(new String());
    OrgDefinedFundingSubType subtype = new OrgDefinedFundingSubType();
    subtype.setAlreadyIndexed(false);
    subtype.setSubtype(Text.valueOf(""));
    result.setOrganizationDefinedFundingSubType(subtype);
    FundingTitleForm title = new FundingTitleForm();
    title.setTitle(new Text());
    TranslatedTitleForm tt = new TranslatedTitleForm();
    tt.setContent(new String());
    tt.setLanguageCode(new String());
    tt.setLanguageName(new String());
    title.setTranslatedTitle(tt);
    result.setFundingTitle(title);
    result.setUrl(new Text());
    ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
    Visibility v = Visibility.valueOf(profile.getActivitiesVisibilityDefault() == null ? org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.FUNDING_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault());
    result.setVisibility(v);
    Date startDate = new Date();
    result.setStartDate(startDate);
    startDate.setDay("");
    startDate.setMonth("");
    startDate.setYear("");
    Date endDate = new Date();
    result.setEndDate(endDate);
    endDate.setDay("");
    endDate.setMonth("");
    endDate.setYear("");
    // Set empty contributor
    Contributor contr = new Contributor();
    List<Contributor> contrList = new ArrayList<Contributor>();
    Text rText = new Text();
    rText.setValue("");
    contr.setContributorRole(rText);
    Text sText = new Text();
    sText.setValue("");
    contr.setContributorSequence(sText);
    contrList.add(contr);
    result.setContributors(contrList);
    // Set empty external identifier
    List<FundingExternalIdentifierForm> emptyExternalIdentifiers = new ArrayList<FundingExternalIdentifierForm>();
    FundingExternalIdentifierForm f = new FundingExternalIdentifierForm();
    f.setType(Text.valueOf(DEFAULT_FUNDING_EXTERNAL_IDENTIFIER_TYPE));
    f.setUrl(new Text());
    f.setValue(new Text());
    f.setRelationship(Text.valueOf(Relationship.SELF.value()));
    emptyExternalIdentifiers.add(f);
    result.setExternalIdentifiers(emptyExternalIdentifiers);
    result.setCity(new Text());
    result.setCountry(Text.valueOf(""));
    result.setRegion(new Text());
    return result;
}
Also used : FundingForm(org.orcid.pojo.ajaxForm.FundingForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Text(org.orcid.pojo.ajaxForm.Text) FundingTitleForm(org.orcid.pojo.ajaxForm.FundingTitleForm) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(org.orcid.pojo.ajaxForm.Date) Visibility(org.orcid.pojo.ajaxForm.Visibility) FundingExternalIdentifierForm(org.orcid.pojo.ajaxForm.FundingExternalIdentifierForm) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm) OrgDefinedFundingSubType(org.orcid.pojo.ajaxForm.OrgDefinedFundingSubType) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 8 with Contributor

use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.

the class FundingsController method createFundingIdList.

/**
     * Create a funding id list and sorts a map associated with the list in in
     * the session
     * 
     */
private List<String> createFundingIdList(HttpServletRequest request) {
    Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
    String orcid = getEffectiveUserOrcid();
    List<Funding> fundings = profileFundingManager.getFundingList(orcid, profileEntityManager.getLastModified(orcid));
    HashMap<String, FundingForm> fundingsMap = new HashMap<String, FundingForm>();
    List<String> fundingIds = new ArrayList<String>();
    if (fundings != null) {
        for (Funding funding : fundings) {
            try {
                FundingForm form = FundingForm.valueOf(funding);
                if (funding.getType() != null) {
                    form.setFundingTypeForDisplay(getMessage(buildInternationalizationKey(org.orcid.jaxb.model.message.FundingType.class, funding.getType().value())));
                }
                // Set translated title language name
                if (!(funding.getTitle().getTranslatedTitle() == null) && !StringUtils.isEmpty(funding.getTitle().getTranslatedTitle().getLanguageCode())) {
                    String languageName = languages.get(funding.getTitle().getTranslatedTitle().getLanguageCode());
                    form.getFundingTitle().getTranslatedTitle().setLanguageName(languageName);
                }
                // Set the formatted amount
                if (funding.getAmount() != null && StringUtils.isNotBlank(funding.getAmount().getContent())) {
                    BigDecimal bigDecimal = new BigDecimal(funding.getAmount().getContent());
                    String formattedAmount = formatAmountString(bigDecimal);
                    form.setAmount(Text.valueOf(formattedAmount));
                }
                if (form.getContributors() != null) {
                    for (Contributor contributor : form.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 = cacheManager.getPublicCreditName(profileEntity);
                                contributor.setCreditName(Text.valueOf(publicContributorCreditName));
                            }
                        }
                    }
                }
                form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, funding.getOrganization().getAddress().getCountry().name())));
                String putCode = String.valueOf(funding.getPutCode());
                fundingsMap.put(putCode, form);
                fundingIds.add(putCode);
            } catch (Exception e) {
                LOGGER.error("Failed to parse as Funding. Put code" + funding.getPutCode(), e);
            }
        }
        request.getSession().setAttribute(GRANT_MAP, fundingsMap);
    }
    return fundingIds;
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) HashMap(java.util.HashMap) FundingForm(org.orcid.pojo.ajaxForm.FundingForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) BigDecimal(java.math.BigDecimal) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 9 with Contributor

use of org.orcid.pojo.ajaxForm.Contributor in project ORCID-Source by ORCID.

the class OrcidInfo method getWorkInfo.

/**
     * Returns the work info for a given work id
     * 
     * @param workId
     *            The id of the work
     * @return the content of that work
     */
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@PathVariable("orcid") String orcid, @RequestParam(value = "workId") Long workId) {
    Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
    if (workId == null)
        return null;
    Work workObj = workManager.getWork(orcid, workId, profileEntManager.getLastModified(orcid));
    if (workObj != null) {
        validateVisibility(workObj.getVisibility());
        sourceUtils.setSourceName(workObj);
        WorkForm work = WorkForm.valueOf(workObj);
        // Set country name
        if (!PojoUtil.isEmpty(work.getCountryCode())) {
            Text countryName = Text.valueOf(retrieveIsoCountries().get(work.getCountryCode().getValue()));
            work.setCountryName(countryName);
        }
        // Set language name
        if (!PojoUtil.isEmpty(work.getLanguageCode())) {
            Text languageName = Text.valueOf(languages.get(work.getLanguageCode().getValue()));
            work.setLanguageName(languageName);
        }
        // Set translated title language name
        if (work.getTranslatedTitle() != null && !StringUtils.isEmpty(work.getTranslatedTitle().getLanguageCode())) {
            String languageName = languages.get(work.getTranslatedTitle().getLanguageCode());
            work.getTranslatedTitle().setLanguageName(languageName);
        }
        if (work.getContributors() != null) {
            for (Contributor contributor : work.getContributors()) {
                if (!PojoUtil.isEmpty(contributor.getOrcid())) {
                    String contributorOrcid = contributor.getOrcid().getValue();
                    if (profileEntManager.orcidExists(contributorOrcid)) {
                        ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
                        String publicContributorCreditName = activityCacheManager.getPublicCreditName(profileEntity);
                        contributor.setCreditName(Text.valueOf(publicContributorCreditName));
                    }
                }
            }
        }
        return work;
    }
    return null;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.record_v2.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

Contributor (org.orcid.pojo.ajaxForm.Contributor)9 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 ArrayList (java.util.ArrayList)4 Text (org.orcid.pojo.ajaxForm.Text)4 WorkForm (org.orcid.pojo.ajaxForm.WorkForm)4 Work (org.orcid.jaxb.model.record_v2.Work)3 Date (org.orcid.pojo.ajaxForm.Date)3 FundingForm (org.orcid.pojo.ajaxForm.FundingForm)3 TranslatedTitleForm (org.orcid.pojo.ajaxForm.TranslatedTitleForm)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 Test (org.junit.Test)2 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)2 CreatedDate (org.orcid.jaxb.model.common_v2.CreatedDate)2 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 PublicationDate (org.orcid.jaxb.model.common_v2.PublicationDate)2 Citation (org.orcid.pojo.ajaxForm.Citation)2 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)2 BigDecimal (java.math.BigDecimal)1