use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method createGroupIdRecord.
@Override
public Response createGroupIdRecord(GroupIdRecord groupIdRecord) {
orcidSecurityManager.checkScopes(ScopePathType.GROUP_ID_RECORD_UPDATE);
GroupIdRecord newRecord = groupIdRecordManager.createGroupIdRecord(groupIdRecord);
try {
return Response.created(new URI(String.valueOf(newRecord.getPutCode()))).build();
} catch (URISyntaxException ex) {
throw new RuntimeException(localeManager.resolveMessage("apiError.creategroupidrecord_response.exception"), ex);
}
}
use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method updateGroupIdRecord.
@Override
public Response updateGroupIdRecord(GroupIdRecord groupIdRecord, Long putCode) {
orcidSecurityManager.checkScopes(ScopePathType.GROUP_ID_RECORD_UPDATE);
if (!putCode.equals(groupIdRecord.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(groupIdRecord.getPutCode()));
throw new MismatchedPutCodeException(params);
}
GroupIdRecord updatedRecord = groupIdRecordManager.updateGroupIdRecord(putCode, groupIdRecord);
return Response.ok(updatedRecord).build();
}
use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord 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.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateGroupId_validTest.
/**
* VALIDATE GROUP ID RECORD
* */
@Test
public void validateGroupId_validTest() {
SourceEntity source = mock(SourceEntity.class);
when(source.getSourceName()).thenReturn("source name");
GroupIdRecord g = getGroupIdRecord();
activityValidator.validateGroupIdRecord(g, true, source);
}
use of org.orcid.jaxb.model.groupid_v2.GroupIdRecord in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_GroupIdTest method testDeleteGroupIdRecord.
@Test(expected = GroupIdRecordNotFoundException.class)
public void testDeleteGroupIdRecord() {
SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
// Verify if the record exists
Response response = serviceDelegator.viewGroupIdRecord(5L);
assertNotNull(response);
GroupIdRecord groupIdRecord = (GroupIdRecord) response.getEntity();
assertNotNull(groupIdRecord);
// Delete the record
serviceDelegator.deleteGroupIdRecord(5L);
// Throws a record not found exception
serviceDelegator.viewGroupIdRecord(5L);
}
Aggregations