Search in sources :

Example 6 with TranslatedTitleForm

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

the class PeerReviewsController method getEmptyPeerReview.

/**
     * Returns a blank peer review form
     * */
@RequestMapping(value = "/peer-review.json", method = RequestMethod.GET)
@ResponseBody
public PeerReviewForm getEmptyPeerReview() {
    Date emptyDate = new Date();
    emptyDate.setDay(StringUtils.EMPTY);
    emptyDate.setMonth(StringUtils.EMPTY);
    emptyDate.setYear(StringUtils.EMPTY);
    TranslatedTitleForm emptyTranslatedTitle = new TranslatedTitleForm();
    emptyTranslatedTitle.setErrors(Collections.<String>emptyList());
    emptyTranslatedTitle.setContent(StringUtils.EMPTY);
    emptyTranslatedTitle.setLanguageCode(StringUtils.EMPTY);
    emptyTranslatedTitle.setLanguageName(StringUtils.EMPTY);
    WorkExternalIdentifier emptyExternalId = new WorkExternalIdentifier();
    emptyExternalId.setErrors(new ArrayList<String>());
    emptyExternalId.setWorkExternalIdentifierId(Text.valueOf(StringUtils.EMPTY));
    emptyExternalId.getWorkExternalIdentifierId().setRequired(false);
    emptyExternalId.setWorkExternalIdentifierType(Text.valueOf(StringUtils.EMPTY));
    emptyExternalId.getWorkExternalIdentifierType().setRequired(false);
    emptyExternalId.setRelationship(Text.valueOf(Relationship.SELF.value()));
    emptyExternalId.setUrl(Text.valueOf(StringUtils.EMPTY));
    List<WorkExternalIdentifier> emptyExtIdsList = new ArrayList<WorkExternalIdentifier>();
    emptyExtIdsList.add(emptyExternalId);
    PeerReviewForm form = new PeerReviewForm();
    form.setErrors(Collections.<String>emptyList());
    form.setCompletionDate(emptyDate);
    form.setCreatedDate(emptyDate);
    form.setCity(Text.valueOf(StringUtils.EMPTY));
    form.setRegion(Text.valueOf(StringUtils.EMPTY));
    form.getRegion().setRequired(false);
    form.setCountry(Text.valueOf(StringUtils.EMPTY));
    form.setCountryForDisplay(StringUtils.EMPTY);
    form.setDisambiguationSource(Text.valueOf(StringUtils.EMPTY));
    form.getDisambiguationSource().setRequired(false);
    form.setOrgName(Text.valueOf(StringUtils.EMPTY));
    form.setPutCode(Text.valueOf(StringUtils.EMPTY));
    form.getPutCode().setRequired(false);
    form.setRole(Text.valueOf(Role.REVIEWER.value()));
    form.setType(Text.valueOf(PeerReviewType.REVIEW.value()));
    form.setUrl(Text.valueOf(StringUtils.EMPTY));
    form.getUrl().setRequired(false);
    form.setExternalIdentifiers(emptyExtIdsList);
    form.setGroupId(Text.valueOf(StringUtils.EMPTY));
    form.setSubjectContainerName(Text.valueOf(StringUtils.EMPTY));
    form.setSubjectExternalIdentifier(emptyExternalId);
    form.setSubjectName(Text.valueOf(StringUtils.EMPTY));
    form.setSubjectType(Text.valueOf(StringUtils.EMPTY));
    form.setSubjectUrl(Text.valueOf(StringUtils.EMPTY));
    return form;
}
Also used : ArrayList(java.util.ArrayList) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) Date(org.orcid.pojo.ajaxForm.Date) TranslatedTitleForm(org.orcid.pojo.ajaxForm.TranslatedTitleForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 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)

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 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.common_v2.CreatedDate)1 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)1