Search in sources :

Example 11 with GroupIdRecord

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;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)

Example 12 with GroupIdRecord

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\\^._~:/?#\\[\\]@!$&amp;'()*+,;=-]){2,}");
    Matcher matcher = validGroupIdRegexPattern.matcher(groupIdRecord.getGroupId());
    if (!matcher.matches()) {
        throw new OrcidValidationException("Invalid group-id: '" + groupIdRecord.getGroupId() + "'");
    }
}
Also used : Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) InvalidPutCodeException(org.orcid.core.exception.InvalidPutCodeException) Matcher(java.util.regex.Matcher) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)

Example 13 with GroupIdRecord

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;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)

Example 14 with GroupIdRecord

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;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord) ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 15 with GroupIdRecord

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);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord) Test(org.junit.Test)

Aggregations

GroupIdRecord (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)21 Test (org.junit.Test)10 InvalidPutCodeException (org.orcid.core.exception.InvalidPutCodeException)4 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)4 DBUnitTest (org.orcid.test.DBUnitTest)4 HashMap (java.util.HashMap)3 Response (javax.ws.rs.core.Response)3 BaseTest (org.orcid.core.BaseTest)3 DuplicatedGroupIdRecordException (org.orcid.core.exception.DuplicatedGroupIdRecordException)3 GroupIdRecordNotFoundException (org.orcid.core.exception.GroupIdRecordNotFoundException)3 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)3 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)3 ArrayList (java.util.ArrayList)2 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)2 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)2 PeerReviewForm (org.orcid.pojo.ajaxForm.PeerReviewForm)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 AccessControlException (java.security.AccessControlException)1