Search in sources :

Example 1 with TranslatedTitleForm

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

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

the class PeerReviewsControllerTest method getForm.

private PeerReviewForm getForm() {
    PeerReviewForm form = new PeerReviewForm();
    form.setCity(Text.valueOf("The City"));
    form.setCountry(Text.valueOf("CR"));
    form.setOrgName(Text.valueOf("OrgName"));
    form.setRegion(Text.valueOf("The Region"));
    form.setRole(Text.valueOf("reviewer"));
    form.setType(Text.valueOf("evaluation"));
    form.setUrl(Text.valueOf("http://orcid.org"));
    form.setVisibility(Visibility.valueOf(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED));
    Date completionDate = new Date();
    completionDate.setDay("01");
    completionDate.setMonth("01");
    completionDate.setYear("2015");
    form.setCompletionDate(completionDate);
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(Text.valueOf("extId1"));
    wei.setWorkExternalIdentifierType(Text.valueOf("bibcode"));
    wei.setRelationship(Text.valueOf(Relationship.SELF.value()));
    wei.setUrl(Text.valueOf("http://myurl.com"));
    List<WorkExternalIdentifier> extIds = new ArrayList<WorkExternalIdentifier>();
    extIds.add(wei);
    form.setExternalIdentifiers(extIds);
    form.setSubjectContainerName(Text.valueOf("Journal Title"));
    form.setSubjectName(Text.valueOf("Title"));
    TranslatedTitleForm translated = new TranslatedTitleForm();
    translated.setContent("Translated title");
    translated.setLanguageCode("es");
    form.setTranslatedSubjectName(translated);
    form.setSubjectUrl(Text.valueOf("http://subject.com"));
    form.setSubjectExternalIdentifier(wei);
    form.setSubjectType(Text.valueOf("book-review"));
    form.setGroupId(Text.valueOf("issn:0000001"));
    return form;
}
Also used : ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) Date(org.orcid.pojo.ajaxForm.Date) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm)

Example 3 with TranslatedTitleForm

use of org.orcid.pojo.ajaxForm.TranslatedTitleForm 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)

Example 4 with TranslatedTitleForm

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

the class WorksControllerTest method testUpdateWork.

@Test
public void testUpdateWork() throws Exception {
    HttpServletRequest servletRequest = mock(HttpServletRequest.class);
    HttpSession session = mock(HttpSession.class);
    when(servletRequest.getSession()).thenReturn(session);
    WorkForm work = worksController.getWorkInfo(Long.valueOf("6"));
    // Set title
    work.setTitle(Text.valueOf("Test update work"));
    work.setSubtitle(Text.valueOf("Test update subtitle"));
    TranslatedTitleForm tTitle = new TranslatedTitleForm();
    tTitle.setContent("Test translated title");
    tTitle.setLanguageCode("EN");
    work.setTranslatedTitle(tTitle);
    work.setWorkType(Text.valueOf("artistic-performance"));
    work.setWorkExternalIdentifiers(new ArrayList<WorkExternalIdentifier>());
    WorkExternalIdentifier wei1 = new WorkExternalIdentifier();
    wei1.setWorkExternalIdentifierId(Text.valueOf("1"));
    wei1.setWorkExternalIdentifierType(Text.valueOf("doi"));
    work.getWorkExternalIdentifiers().add(wei1);
    WorkExternalIdentifier wei2 = new WorkExternalIdentifier();
    wei2.setWorkExternalIdentifierId(Text.valueOf("2"));
    wei2.setWorkExternalIdentifierType(Text.valueOf("arxiv"));
    work.getWorkExternalIdentifiers().add(wei2);
    work.getPublicationDate().setDay("2");
    work.getPublicationDate().setMonth("3");
    work.getPublicationDate().setYear("2014");
    worksController.validateWork(work);
    if (!work.getErrors().isEmpty()) {
        work.getErrors().forEach(n -> System.out.println(n));
        fail("invalid work update");
    }
    worksController.postWork(null, work);
    WorkForm updatedWork = worksController.getWorkInfo(Long.valueOf("6"));
    assertNotNull(updatedWork);
    assertEquals("6", updatedWork.getPutCode().getValue());
    assertEquals("Test update work", updatedWork.getTitle().getValue());
    assertEquals("Test update subtitle", updatedWork.getSubtitle().getValue());
    assertEquals("Test translated title", updatedWork.getTranslatedTitle().getContent());
    assertEquals("EN", updatedWork.getTranslatedTitle().getLanguageCode());
    assertNotNull(updatedWork.getWorkExternalIdentifiers());
    assertEquals(2, updatedWork.getWorkExternalIdentifiers().size());
    List<WorkExternalIdentifier> extIds = updatedWork.getWorkExternalIdentifiers();
    for (WorkExternalIdentifier extId : extIds) {
        if (extId.getWorkExternalIdentifierType().getValue().equals("doi") || extId.getWorkExternalIdentifierType().getValue().equals("arxiv")) {
            if (extId.getWorkExternalIdentifierType().getValue().equals("doi")) {
                assertEquals("1", extId.getWorkExternalIdentifierId().getValue());
            } else {
                assertEquals("2", extId.getWorkExternalIdentifierId().getValue());
            }
        } else {
            fail("Invalid external identifier found: " + extId.getWorkExternalIdentifierType().getValue() + " : " + extId.getWorkExternalIdentifierId().getValue());
        }
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WorkForm(org.orcid.pojo.ajaxForm.WorkForm) HttpSession(javax.servlet.http.HttpSession) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm) WorkFormTest(orcid.pojo.ajaxForm.WorkFormTest) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 5 with TranslatedTitleForm

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

the class FundingsControllerTest method testEditFunding.

@Test
@Rollback(true)
public void testEditFunding() throws Exception {
    HttpSession session = mock(HttpSession.class);
    when(servletRequest.getSession()).thenReturn(session);
    when(localeManager.getLocale()).thenReturn(new Locale("us", "EN"));
    FundingForm funding = fundingController.getFundingJson(Long.valueOf("1"));
    funding.getFundingTitle().getTitle().setValue("Grant # 1 - updated");
    TranslatedTitleForm translatedTitle = new TranslatedTitleForm();
    translatedTitle.setContent("Grant # 1 - translated title");
    translatedTitle.setLanguageCode("en");
    funding.getFundingTitle().setTranslatedTitle(translatedTitle);
    funding.getAmount().setValue("3500");
    funding.getCurrencyCode().setValue("CRC");
    fundingController.postFunding(funding);
    // Fetch the funding again
    FundingForm updated = fundingController.getFundingJson(Long.valueOf("1"));
    assertNotNull(updated);
    assertNotNull(updated.getFundingTitle());
    assertFalse(PojoUtil.isEmpty(updated.getFundingTitle().getTitle()));
    assertEquals("Grant # 1 - updated", updated.getFundingTitle().getTitle().getValue());
    assertEquals("Grant # 1 - translated title", updated.getFundingTitle().getTranslatedTitle().getContent());
    assertEquals("en", updated.getFundingTitle().getTranslatedTitle().getLanguageCode());
    assertFalse(PojoUtil.isEmpty(updated.getFundingType()));
    assertEquals("salary-award", updated.getFundingType().getValue());
    assertFalse(PojoUtil.isEmpty(updated.getAmount()));
    assertEquals("3,500", updated.getAmount().getValue());
    assertFalse(PojoUtil.isEmpty(updated.getCurrencyCode()));
    assertEquals("CRC", updated.getCurrencyCode().getValue());
}
Also used : Locale(java.util.Locale) HttpSession(javax.servlet.http.HttpSession) MockHttpSession(org.springframework.mock.web.MockHttpSession) FundingForm(org.orcid.pojo.ajaxForm.FundingForm) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

TranslatedTitleForm (org.orcid.pojo.ajaxForm.TranslatedTitleForm)7 ArrayList (java.util.ArrayList)5 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)5 Date (org.orcid.pojo.ajaxForm.Date)4 Contributor (org.orcid.pojo.ajaxForm.Contributor)3 HttpSession (javax.servlet.http.HttpSession)2 Test (org.junit.Test)2 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)2 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 FundingForm (org.orcid.pojo.ajaxForm.FundingForm)2 PeerReviewForm (org.orcid.pojo.ajaxForm.PeerReviewForm)2 Text (org.orcid.pojo.ajaxForm.Text)2 Visibility (org.orcid.pojo.ajaxForm.Visibility)2 WorkForm (org.orcid.pojo.ajaxForm.WorkForm)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Locale (java.util.Locale)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 WorkFormTest (orcid.pojo.ajaxForm.WorkFormTest)1 CreatedDate (org.orcid.jaxb.model.v3.dev1.common.CreatedDate)1