Search in sources :

Example 6 with PeerReviewForm

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

the class PeerReviewsControllerTest method testAddPeerReview.

@Test
public void testAddPeerReview() {
    PeerReviewForm form = getForm();
    try {
        PeerReviewForm newForm = peerReviewsController.postPeerReview(form);
        assertNotNull(newForm);
        assertFalse(PojoUtil.isEmpty(newForm.getPutCode()));
        String putCode = newForm.getPutCode().getValue();
        newForm = peerReviewsController.getPeerReviewJson(Long.valueOf(putCode));
        assertEquals(form.getCity(), newForm.getCity());
        assertEquals(form.getRegion(), newForm.getRegion());
        assertEquals(form.getCountry(), newForm.getCountry());
        assertEquals(form.getOrgName(), newForm.getOrgName());
        assertEquals(form.getCompletionDate(), newForm.getCompletionDate());
        assertEquals(form.getExternalIdentifiers(), newForm.getExternalIdentifiers());
        assertEquals(form.getRole(), newForm.getRole());
        assertEquals(form.getType(), newForm.getType());
        assertEquals(form.getUrl(), newForm.getUrl());
        assertEquals(form.getVisibility(), newForm.getVisibility());
        assertEquals(form.getGroupId(), newForm.getGroupId());
        assertEquals(form.getSubjectContainerName(), newForm.getSubjectContainerName());
        assertEquals(form.getSubjectExternalIdentifier(), newForm.getSubjectExternalIdentifier());
        assertEquals(form.getSubjectName(), newForm.getSubjectName());
        assertEquals(form.getSubjectType(), newForm.getSubjectType());
        assertEquals(form.getSubjectUrl(), newForm.getSubjectUrl());
    } catch (NullPointerException npe) {
        fail();
    }
}
Also used : PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Example 7 with PeerReviewForm

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

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

the class OrcidInfo method getPeerReviewsJson.

@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/peer-reviews.json")
@ResponseBody
public List<PeerReviewForm> getPeerReviewsJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "peerReviewIds") String peerReviewIdsStr) {
    Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
    List<PeerReviewForm> peerReviews = new ArrayList<PeerReviewForm>();
    Map<Long, PeerReview> peerReviewMap = peerReviewMap(orcid, getLastModifiedTime(orcid));
    String[] peerReviewIds = peerReviewIdsStr.split(",");
    for (String id : peerReviewIds) {
        PeerReview peerReview = peerReviewMap.get(Long.valueOf(id));
        validateVisibility(peerReview.getVisibility());
        sourceUtils.setSourceName(peerReview);
        PeerReviewForm form = PeerReviewForm.valueOf(peerReview);
        // Set language name
        form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, peerReview.getOrganization().getAddress().getCountry().name())));
        if (!PojoUtil.isEmpty(form.getTranslatedSubjectName())) {
            // Set translated title language name
            if (!StringUtils.isEmpty(form.getTranslatedSubjectName().getLanguageCode())) {
                String languageName = languages.get(form.getTranslatedSubjectName().getLanguageCode());
                form.getTranslatedSubjectName().setLanguageName(languageName);
            }
        }
        // the group id
        if (form.getGroupId() != null && !PojoUtil.isEmpty(form.getGroupId().getValue())) {
            GroupIdRecord groupId = groupIdRecordManager.findByGroupId(form.getGroupId().getValue()).get();
            form.setGroupIdPutCode(Text.valueOf(groupId.getPutCode()));
        }
        peerReviews.add(form);
    }
    return peerReviews;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 9 with PeerReviewForm

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

the class PeerReviewsControllerTest method testValidatePeerReviewFields.

@Test
public void testValidatePeerReviewFields() {
    PeerReviewForm form = peerReviewsController.getEmptyPeerReview();
    form.getGroupId().setValue("bad-group-id");
    form = peerReviewsController.postPeerReview(form);
    assertNotNull(form);
    assertNotNull(form.getErrors());
    assertEquals(6, form.getErrors().size());
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("org.name.not_blank")));
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("org.city.not_blank")));
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("common.country.not_blank")));
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("peer_review.subject.work_type.not_blank")));
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("common.title.not_blank")));
    assertTrue(form.getErrors().contains(peerReviewsController.getMessage("peer_review.group_id.not_valid")));
}
Also used : PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) Test(org.junit.Test) BaseControllerTest(org.orcid.frontend.web.util.BaseControllerTest)

Aggregations

PeerReviewForm (org.orcid.pojo.ajaxForm.PeerReviewForm)9 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)4 WorkExternalIdentifier (org.orcid.pojo.ajaxForm.WorkExternalIdentifier)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 HashMap (java.util.HashMap)2 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)2 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)2 Date (org.orcid.pojo.ajaxForm.Date)2 TranslatedTitleForm (org.orcid.pojo.ajaxForm.TranslatedTitleForm)2 NoResultException (javax.persistence.NoResultException)1 HttpSession (javax.servlet.http.HttpSession)1