use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class Utils method getGroupIdRecord.
public static GroupIdRecord getGroupIdRecord() {
GroupIdRecord newRecord = new GroupIdRecord();
newRecord.setGroupId("issn:0000006");
newRecord.setName("TestGroup5");
newRecord.setDescription("TestDescription5");
newRecord.setType("publisher");
return newRecord;
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class ActivityValidator method validateGroupIdRecord.
public void validateGroupIdRecord(GroupIdRecord groupIdRecord, boolean createFlag, SourceEntity sourceEntity) {
if (createFlag) {
if (groupIdRecord.getPutCode() != null) {
Map<String, String> params = new HashMap<String, String>();
if (sourceEntity != null) {
params.put("clientName", sourceEntity.getSourceName());
}
throw new InvalidPutCodeException(params);
}
}
Pattern validGroupIdRegexPattern = Pattern.compile("(ringgold:|issn:|orcid-generated:|fundref:|publons:)([0-9a-zA-Z\\^._~:/?#\\[\\]@!$&'()*+,;=-]){2,}");
Matcher matcher = validGroupIdRegexPattern.matcher(groupIdRecord.getGroupId());
if (!matcher.matches()) {
throw new OrcidValidationException("Invalid group-id: '" + groupIdRecord.getGroupId() + "'");
}
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class BlackBoxBaseV3 method createGroupIdsV3.
/**
* Create group ids
*/
public List<GroupIdRecord> createGroupIdsV3() throws JSONException {
// Use the existing ones
if (groupRecords != null && !groupRecords.isEmpty())
return groupRecords;
groupRecords = new ArrayList<GroupIdRecord>();
String token = getClientCredentialsAccessToken(ScopePathType.GROUP_ID_RECORD_UPDATE, getClient1ClientId(), getClient1ClientSecret(), APIRequestType.MEMBER);
GroupIdRecord g1 = new GroupIdRecord();
g1.setDescription("Description");
g1.setGroupId("orcid-generated:01" + System.currentTimeMillis());
g1.setName("Group # 1");
g1.setType("publisher");
GroupIdRecord g2 = new GroupIdRecord();
g2.setDescription("Description");
g2.setGroupId("orcid-generated:02" + System.currentTimeMillis());
g2.setName("Group # 2");
g2.setType("publisher");
ClientResponse r1 = memberV3Dev1ApiClient.createGroupIdRecord(g1, token);
String r1LocationPutCode = r1.getLocation().getPath().replace("/orcid-api-web/v3.0_dev1/group-id-record/", "");
g1.setPutCode(Long.valueOf(r1LocationPutCode));
groupRecords.add(g1);
ClientResponse r2 = memberV3Dev1ApiClient.createGroupIdRecord(g2, token);
String r2LocationPutCode = r2.getLocation().getPath().replace("/orcid-api-web/v3.0_dev1/group-id-record/", "");
g2.setPutCode(Long.valueOf(r2LocationPutCode));
groupRecords.add(g2);
return groupRecords;
}
use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord 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 = activityManager.pubPeerReviewsMap(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.jaxb.model.v3.dev1.groupid.GroupIdRecord in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateGroupId_invalidPutCodeTest.
@Test(expected = InvalidPutCodeException.class)
public void validateGroupId_invalidPutCodeTest() {
SourceEntity source = mock(SourceEntity.class);
when(source.getSourceName()).thenReturn("source name");
GroupIdRecord g = getGroupIdRecord();
g.setPutCode(1L);
activityValidator.validateGroupIdRecord(g, true, source);
}
Aggregations