Search in sources :

Example 21 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.

the class GroupIdRecordManagerReadOnlyImpl method getGroupIdRecords.

@Override
public GroupIdRecords getGroupIdRecords(String pageSize, String pageNum) {
    int pageNumInt = convertToInteger(pageNum);
    int pageSizeInt = convertToInteger(pageSize);
    GroupIdRecords records = new GroupIdRecords();
    records.setPage(pageNumInt);
    records.setPageSize(pageSizeInt);
    List<GroupIdRecordEntity> recordEntities = groupIdRecordDao.getGroupIdRecords(pageSizeInt, pageNumInt);
    List<GroupIdRecord> recordsReturned = jpaJaxbGroupIdRecordAdapter.toGroupIdRecords(recordEntities);
    if (recordsReturned != null) {
        records.setTotal(recordsReturned.size());
        records.getGroupIdRecord().addAll(recordsReturned);
    } else {
        records.setTotal(0);
    }
    return records;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) GroupIdRecords(org.orcid.jaxb.model.groupid_v2.GroupIdRecords) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 22 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc2.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 = peerReviewMap(orcid, getLastModifiedTime(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.groupid_v2.GroupIdRecord) ArrayList(java.util.ArrayList) PeerReviewForm(org.orcid.pojo.ajaxForm.PeerReviewForm) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 23 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getGroupIdRecord.

public GroupIdRecord getGroupIdRecord() {
    GroupIdRecord g = new GroupIdRecord();
    g.setDescription("description");
    g.setGroupId("orcid-generated:0123456789");
    g.setName("group-name");
    g.setType("group-type");
    return g;
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord)

Example 24 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateGroupId_invalidGroupIdTest.

@Test(expected = OrcidValidationException.class)
public void validateGroupId_invalidGroupIdTest() {
    SourceEntity source = mock(SourceEntity.class);
    when(source.getSourceName()).thenReturn("source name");
    GroupIdRecord g = getGroupIdRecord();
    g.setGroupId("invalid");
    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 25 with GroupIdRecord

use of org.orcid.jaxb.model.groupid_rc2.GroupIdRecord in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getGroupIdRecordMapperFacade.

public MapperFacade getGroupIdRecordMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
    addV2CommonFields(classMap);
    registerSourceConverters(mapperFactory, classMap);
    classMap.field("name", "groupName");
    classMap.field("groupId", "groupId");
    classMap.field("description", "groupDescription");
    classMap.field("type", "groupType");
    classMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

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