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();
}
}
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;
}
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;
}
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")));
}
Aggregations