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