use of org.orcid.pojo.ajaxForm.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class PeerReviewsController method createPeerReviewIdList.
/**
* Create a funding id list and sorts a map associated with the list in in
* the session
*
*/
private List<String> createPeerReviewIdList(HttpServletRequest request) {
String orcid = getCurrentUserOrcid();
List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid, profileEntityManager.getLastModified(orcid));
Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
HashMap<Long, PeerReviewForm> peerReviewMap = new HashMap<>();
List<String> peerReviewIds = new ArrayList<String>();
if (peerReviews != null) {
for (PeerReview peerReview : peerReviews) {
try {
PeerReviewForm form = PeerReviewForm.valueOf(peerReview);
if (form.getExternalIdentifiers() != null && !form.getExternalIdentifiers().isEmpty()) {
for (WorkExternalIdentifier wExtId : form.getExternalIdentifiers()) {
if (PojoUtil.isEmpty(wExtId.getRelationship())) {
wExtId.setRelationship(Text.valueOf(Relationship.SELF.value()));
}
}
}
if (form.getTranslatedSubjectName() != null) {
// Set translated title language name
if (!(form.getTranslatedSubjectName() == null) && !StringUtils.isEmpty(form.getTranslatedSubjectName().getLanguageCode())) {
String languageName = languages.get(form.getTranslatedSubjectName().getLanguageCode());
form.getTranslatedSubjectName().setLanguageName(languageName);
}
}
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, peerReview.getOrganization().getAddress().getCountry().name())));
//Set the numeric id (the table id in the group_id_record table) of 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()));
}
peerReviewMap.put(peerReview.getPutCode(), form);
peerReviewIds.add(String.valueOf(peerReview.getPutCode()));
} catch (Exception e) {
LOGGER.error("Failed to parse as PeerReview. Put code" + peerReview.getPutCode(), e);
}
}
request.getSession().setAttribute(PEER_REVIEW_MAP, peerReviewMap);
}
return peerReviewIds;
}
use of org.orcid.pojo.ajaxForm.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class PeerReviewsController method postPeerReview.
/**
* Persist a funding object on database
* */
@RequestMapping(value = "/peer-review.json", method = RequestMethod.POST)
@ResponseBody
public PeerReviewForm postPeerReview(@RequestBody PeerReviewForm peerReview) {
// Reset errors
peerReview.setErrors(new ArrayList<String>());
// Remove empty external identifiers
removeEmptyExternalIds(peerReview);
// Remove empty external identifiers on subject
removeEmptyExternalIdsOnSubject(peerReview);
validateOrgName(peerReview);
validateCity(peerReview);
validateRegion(peerReview);
validateCountry(peerReview);
validateUrl(peerReview);
validateExternalIdentifiers(peerReview);
validateGroupId(peerReview);
copyErrors(peerReview.getOrgName(), peerReview);
copyErrors(peerReview.getCity(), peerReview);
copyErrors(peerReview.getRegion(), peerReview);
copyErrors(peerReview.getCountry(), peerReview);
copyErrors(peerReview.getUrl(), peerReview);
copyErrors(peerReview.getGroupId(), peerReview);
if (peerReview.getExternalIdentifiers() != null) {
for (WorkExternalIdentifier extId : peerReview.getExternalIdentifiers()) {
copyErrors(extId.getWorkExternalIdentifierId(), peerReview);
copyErrors(extId.getWorkExternalIdentifierType(), peerReview);
}
}
if (peerReview.getCompletionDate() != null) {
validateCompletionDate(peerReview);
copyErrors(peerReview.getCompletionDate(), peerReview);
}
validateSubjectType(peerReview);
copyErrors(peerReview.getSubjectType(), peerReview);
validateSubjectName(peerReview);
copyErrors(peerReview.getSubjectName(), peerReview);
validateSubjectUrl(peerReview);
copyErrors(peerReview.getSubjectUrl(), peerReview);
validateSubjectExternalIdentifier(peerReview);
copyErrors(peerReview.getSubjectExternalIdentifier(), peerReview);
// If there are no errors, persist to DB
if (peerReview.getErrors().isEmpty()) {
if (PojoUtil.isEmpty(peerReview.getPutCode())) {
peerReview = addPeerReview(peerReview);
} else {
peerReview = editPeerReview(peerReview);
}
}
return peerReview;
}
use of org.orcid.pojo.ajaxForm.WorkExternalIdentifier in project ORCID-Source by ORCID.
the class WorksControllerTest method testAddWork.
@Test
public void testAddWork() throws Exception {
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
HttpSession session = mock(HttpSession.class);
when(servletRequest.getSession()).thenReturn(session);
WorkForm work = worksController.getWork(null);
// Set title
work.setTitle(Text.valueOf("Test add work"));
work.setWorkType(Text.valueOf("artistic-performance"));
WorkExternalIdentifier wei = work.getWorkExternalIdentifiers().get(0);
wei.setWorkExternalIdentifierId(Text.valueOf("1"));
wei.setWorkExternalIdentifierType(Text.valueOf("doi"));
if (!PojoUtil.isEmpty(work.getPutCode())) {
work.setPutCode(Text.valueOf(""));
}
if (work.getCitation() != null && work.getCitation().getCitation() != null && PojoUtil.isEmpty(work.getCitation().getCitation())) {
work.getCitation().getCitation().setValue("test");
}
work = worksController.postWork(null, work);
assertNotNull(work);
assertFalse(PojoUtil.isEmpty(work.getPutCode()));
assertEquals(1, work.getWorkExternalIdentifiers().size());
assertEquals("doi", work.getWorkExternalIdentifiers().get(0).getWorkExternalIdentifierType().getValue());
assertEquals("1", work.getWorkExternalIdentifiers().get(0).getWorkExternalIdentifierId().getValue());
}
use of org.orcid.pojo.ajaxForm.WorkExternalIdentifier 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.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;
}
use of org.orcid.pojo.ajaxForm.WorkExternalIdentifier 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.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;
}
Aggregations