Search in sources :

Example 1 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc3.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);
    }
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc3.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();
}
Also used : HashMap(java.util.HashMap) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 3 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc3.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;
}
Also used : HashMap(java.util.HashMap) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) WorkExternalIdentifier(org.orcid.pojo.ajaxForm.WorkExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview)

Example 4 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc3.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);
}
Also used : SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Test(org.junit.Test)

Example 5 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc3.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);
}
Also used : Response(javax.ws.rs.core.Response) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)22 Test (org.junit.Test)12 DBUnitTest (org.orcid.test.DBUnitTest)4 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 InvalidPutCodeException (org.orcid.core.exception.InvalidPutCodeException)3 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)3 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)3 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)2 IOException (java.io.IOException)1 URI (java.net.URI)1 AccessControlException (java.security.AccessControlException)1