Search in sources :

Example 1 with GroupIdRecords

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

the class MemberV2ApiServiceDelegator_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.groupid_v2.GroupIdRecords) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with GroupIdRecords

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

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(GroupIdRecords groupIdRecords) {
    Date latestAct = null;
    if (groupIdRecords != null && groupIdRecords.getGroupIdRecord() != null && !groupIdRecords.getGroupIdRecord().isEmpty()) {
        XMLGregorianCalendar latest = groupIdRecords.getGroupIdRecord().get(0).getLastModifiedDate().getValue();
        for (GroupIdRecord groupid : groupIdRecords.getGroupIdRecord()) {
            if (latest.compare(groupid.getLastModifiedDate().getValue()) == -1) {
                latest = groupid.getLastModifiedDate().getValue();
            }
        }
        latestAct = latest.toGregorianCalendar().getTime();
        groupIdRecords.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_rc2.GroupIdRecord) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 3 with GroupIdRecords

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

the class ConvertVrc4ToV2Test method upgradeGroupIdToVrc3Test.

@Test
public void upgradeGroupIdToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(GroupIdRecords.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.groupid_v2.GroupIdRecords.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0_rc4.xml");
    InputStream rc4Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0.xml");
    GroupIdRecords rc4Group = (GroupIdRecords) jaxbUnmarshaller.unmarshal(rc3Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.groupid_v2.GroupIdRecords rc4GroupId1 = (org.orcid.jaxb.model.groupid_v2.GroupIdRecords) jaxbUnmarshaller.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc4ToV2_0.upgrade(new V2Convertible(rc4Group, "v2_rc4"));
    org.orcid.jaxb.model.groupid_v2.GroupIdRecords rc4GroupId2 = (org.orcid.jaxb.model.groupid_v2.GroupIdRecords) result.getObjectToConvert();
    assertEquals(rc4GroupId1, rc4GroupId2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) GroupIdRecords(org.orcid.jaxb.model.groupid_rc4.GroupIdRecords) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 4 with GroupIdRecords

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

the class MemberV2ApiServiceDelegatorImpl method viewGroupIdRecords.

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

Example 5 with GroupIdRecords

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

Aggregations

Test (org.junit.Test)6 InputStream (java.io.InputStream)5 JAXBContext (javax.xml.bind.JAXBContext)5 Unmarshaller (javax.xml.bind.Unmarshaller)5 BaseTest (org.orcid.core.BaseTest)5 V2Convertible (org.orcid.core.version.V2Convertible)5 GroupIdRecords (org.orcid.jaxb.model.groupid_v2.GroupIdRecords)5 Date (java.util.Date)1 Response (javax.ws.rs.core.Response)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1 LastModifiedDate (org.orcid.jaxb.model.common_rc2.LastModifiedDate)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc1.GroupIdRecords)1 GroupIdRecord (org.orcid.jaxb.model.groupid_rc2.GroupIdRecord)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc2.GroupIdRecords)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc3.GroupIdRecords)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc4.GroupIdRecords)1 GroupIdRecord (org.orcid.jaxb.model.groupid_v2.GroupIdRecord)1 GroupIdRecordEntity (org.orcid.persistence.jpa.entities.GroupIdRecordEntity)1 DBUnitTest (org.orcid.test.DBUnitTest)1