Search in sources :

Example 1 with GroupIdRecords

use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_GroupIdTest method testGetGroupIdRecords.

@Test
public void testGetGroupIdRecords() {
    SecurityContextTestUtils.setUpSecurityContextForGroupIdClientOnly();
    /*
         * At this point there should be at least 3 group ids and no more than
         * 5, since we are not sure if testDeleteGroupIdRecord and
         * testCreateGroupIdRecord have ran or not
         */
    // So, get a page with all
    Response response = serviceDelegator.viewGroupIdRecords("5", "1");
    assertNotNull(response);
    GroupIdRecords groupIdRecords1 = (GroupIdRecords) response.getEntity();
    assertNotNull(groupIdRecords1);
    assertNotNull(groupIdRecords1.getGroupIdRecord());
    int total = groupIdRecords1.getTotal();
    if (total < 3 || total > 5) {
        fail("There are more group ids than the expected, we are expecting between 3 and 5, total: " + total);
    }
}
Also used : Response(javax.ws.rs.core.Response) GroupIdRecords(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with GroupIdRecords

use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords 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.v3.dev1.groupid.GroupIdRecord) GroupIdRecords(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords) GroupIdRecordEntity(org.orcid.persistence.jpa.entities.GroupIdRecordEntity)

Example 3 with GroupIdRecords

use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewGroupIdRecords.

@Override
public Response viewGroupIdRecords(String pageSize, String pageNum) {
    GroupIdRecords records = groupIdRecordManagerReadOnly.getGroupIdRecords(pageSize, pageNum);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(records);
    return Response.ok(records).build();
}
Also used : GroupIdRecords(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords)

Example 4 with GroupIdRecords

use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords in project ORCID-Source by ORCID.

the class Api3_0_Dev1LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupIdRecords groupIdRecords) {
    if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
        LastModifiedDate latest = null;
        for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
            if (groupid.getLastModifiedDate() != null && groupid.getLastModifiedDate().after(latest)) {
                latest = groupid.getLastModifiedDate();
            }
        }
        groupIdRecords.setLastModifiedDate(latest);
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)

Example 5 with GroupIdRecords

use of org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegatorImpl method viewGroupIdRecords.

@Override
public Response viewGroupIdRecords(String pageSize, String pageNum) {
    orcidSecurityManager.checkScopes(ScopePathType.GROUP_ID_RECORD_READ);
    GroupIdRecords records = groupIdRecordManagerReadOnly.getGroupIdRecords(pageSize, pageNum);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(records);
    return Response.ok(records).build();
}
Also used : GroupIdRecords(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords)

Aggregations

GroupIdRecords (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecords)4 GroupIdRecord (org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)2 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)1 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)1 DBUnitTest (org.orcid.test.DBUnitTest)1