Search in sources :

Example 1 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 2 with Contributor

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

the class FundingsControllerTest method testGetFundingsJson.

@Test
public void testGetFundingsJson() {
    when(localeManager.getLocale()).thenReturn(new Locale("us", "EN"));
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpSession session = new MockHttpSession();
    request.setSession(session);
    request.addPreferredLocale(new Locale("us", "EN"));
    List<FundingForm> fundings = fundingController.getFundingsJson(request, "1");
    assertNotNull(fundings);
    assertEquals(1, fundings.size());
    FundingForm funding = fundings.get(0);
    List<Contributor> contributors = funding.getContributors();
    Contributor contributor = contributors.get(0);
    assertNull(contributor.getEmail());
    assertEquals("Jaylen Kessler", contributor.getCreditName().getValue());
    contributor = contributors.get(1);
    assertNull(contributor.getEmail());
    assertEquals("John Smith", contributor.getCreditName().getValue());
    contributor = contributors.get(2);
    assertNull(contributor.getEmail());
    assertEquals("Credit Name", contributor.getCreditName().getValue());
    // contributor is an ORCID user with private name
    contributor = contributors.get(3);
    assertNull(contributor.getEmail());
    assertNull(contributor.getCreditName().getValue());
}
Also used : Locale(java.util.Locale) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) FundingForm(org.orcid.pojo.ajaxForm.FundingForm) MockHttpSession(org.springframework.mock.web.MockHttpSession) Contributor(org.orcid.pojo.ajaxForm.Contributor) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 3 with Contributor

use of org.orcid.pojo.ajaxForm.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 4 with Contributor

use of org.orcid.pojo.ajaxForm.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 5 with Contributor

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

the class WorksController method initializeFields.

private void initializeFields(WorkForm w) {
    if (w.getVisibility() == null) {
        ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
        Visibility v = profile.getActivitiesVisibilityDefault() == null ? Visibility.valueOf(OrcidVisibilityDefaults.WORKS_DEFAULT.getVisibility()) : Visibility.valueOf(profile.getActivitiesVisibilityDefault());
        w.setVisibility(v);
    }
    if (w.getTitle() == null) {
        w.setTitle(new Text());
    }
    if (w.getSubtitle() == null) {
        w.setSubtitle(new Text());
    }
    if (w.getTranslatedTitle() == null) {
        TranslatedTitleForm tt = new TranslatedTitleForm();
        tt.setContent(new String());
        tt.setLanguageCode(new String());
        tt.setLanguageName(new String());
        w.setTranslatedTitle(tt);
    }
    if (PojoUtil.isEmpty(w.getJournalTitle())) {
        Text jt = new Text();
        jt.setRequired(false);
        w.setJournalTitle(jt);
    }
    if (PojoUtil.isEmpty(w.getWorkCategory())) {
        Text wCategoryText = new Text();
        wCategoryText.setValue(new String());
        wCategoryText.setRequired(true);
        w.setWorkCategory(wCategoryText);
    }
    if (PojoUtil.isEmpty(w.getWorkType())) {
        Text wTypeText = new Text();
        wTypeText.setValue(new String());
        wTypeText.setRequired(true);
        w.setWorkType(wTypeText);
    }
    initializePublicationDate(w);
    if (w.getWorkExternalIdentifiers() == null || w.getWorkExternalIdentifiers().isEmpty()) {
        WorkExternalIdentifier wei = new WorkExternalIdentifier();
        Text wdiType = new Text();
        wdiType.setValue(new String());
        wei.setWorkExternalIdentifierId(new Text());
        wei.setWorkExternalIdentifierType(wdiType);
        wei.setRelationship(Text.valueOf(Relationship.SELF.value()));
        List<WorkExternalIdentifier> wdiL = new ArrayList<WorkExternalIdentifier>();
        wdiL.add(wei);
        w.setWorkExternalIdentifiers(wdiL);
    }
    if (PojoUtil.isEmpty(w.getUrl())) {
        w.setUrl(new Text());
    }
    if (w.getContributors() == null || w.getContributors().isEmpty()) {
        List<Contributor> contrList = new ArrayList<Contributor>();
        w.setContributors(contrList);
    }
    if (PojoUtil.isEmpty(w.getShortDescription())) {
        w.setShortDescription(new Text());
    }
    if (PojoUtil.isEmpty(w.getLanguageCode())) {
        Text lc = new Text();
        lc.setRequired(false);
        w.setLanguageCode(lc);
    }
    if (PojoUtil.isEmpty(w.getLanguageName())) {
        Text ln = new Text();
        ln.setRequired(false);
        w.setLanguageName(ln);
    }
    if (PojoUtil.isEmpty(w.getCountryCode())) {
        w.setCountryCode(new Text());
    }
    if (PojoUtil.isEmpty(w.getCountryName())) {
        w.setCountryName(new Text());
    }
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) Visibility(org.orcid.pojo.ajaxForm.Visibility) Text(org.orcid.pojo.ajaxForm.Text) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

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.v3.dev1.record.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.v3.dev1.common.CreatedDate)2 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)2 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)2 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)2 Citation (org.orcid.pojo.ajaxForm.Citation)2 Visibility (org.orcid.pojo.ajaxForm.Visibility)2 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)2