Search in sources :

Example 6 with GroupIdRecords

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

the class ConvertVrc2ToVrc3Test method upgradeGroupIdToVrc3Test.

@Test
public void upgradeGroupIdToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(GroupIdRecords.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.groupid_rc3.GroupIdRecords.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc2Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0_rc2.xml");
    InputStream rc3Stream = ConvertVrc2ToVrc3Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0_rc3.xml");
    GroupIdRecords rc2Group = (GroupIdRecords) jaxbUnmarshaller.unmarshal(rc2Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.groupid_rc3.GroupIdRecords rc3GroupId1 = (org.orcid.jaxb.model.groupid_rc3.GroupIdRecords) jaxbUnmarshaller.unmarshal(rc3Stream);
    V2Convertible result = versionConverterV2_0_rc2ToV2_0_rc3.upgrade(new V2Convertible(rc2Group, "v2_rc2"));
    org.orcid.jaxb.model.groupid_rc3.GroupIdRecords rc3GroupId2 = (org.orcid.jaxb.model.groupid_rc3.GroupIdRecords) result.getObjectToConvert();
    assertEquals(rc3GroupId1, rc3GroupId2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) GroupIdRecords(org.orcid.jaxb.model.groupid_rc2.GroupIdRecords) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 7 with GroupIdRecords

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

the class ConvertVrc3ToVrc4Test method upgradeGroupIdToVrc3Test.

@Test
public void upgradeGroupIdToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(GroupIdRecords.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.groupid_rc4.GroupIdRecords.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0_rc3.xml");
    InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0_rc4.xml");
    GroupIdRecords rc4Group = (GroupIdRecords) jaxbUnmarshaller.unmarshal(rc3Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.groupid_rc4.GroupIdRecords rc4GroupId1 = (org.orcid.jaxb.model.groupid_rc4.GroupIdRecords) jaxbUnmarshaller.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc4Group, "v2_rc3"));
    org.orcid.jaxb.model.groupid_rc4.GroupIdRecords rc4GroupId2 = (org.orcid.jaxb.model.groupid_rc4.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_rc3.GroupIdRecords) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 8 with GroupIdRecords

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

the class ConvertV2ToV2_1Test method upgradeGroupIdToV21Test.

@Test
public void upgradeGroupIdToV21Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(GroupIdRecords.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(GroupIdRecords.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream v20Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-group-id-2.0.xml");
    InputStream v21Stream = ConvertV2ToV2_1Test.class.getClassLoader().getResourceAsStream("test-group-id-2.1.xml");
    GroupIdRecords v20Group = (GroupIdRecords) jaxbUnmarshaller.unmarshal(v20Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    GroupIdRecords v21GroupId1 = (GroupIdRecords) jaxbUnmarshaller.unmarshal(v21Stream);
    V2Convertible result = versionConverterV2_0ToV2_1.upgrade(new V2Convertible(v20Group, "v2.1"));
    GroupIdRecords v21GroupId2 = (GroupIdRecords) result.getObjectToConvert();
    assertEquals(v21GroupId1, v21GroupId2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) GroupIdRecords(org.orcid.jaxb.model.groupid_v2.GroupIdRecords) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 9 with GroupIdRecords

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

the class PublicV2ApiServiceDelegatorImpl method viewGroupIdRecords.

@Override
public Response viewGroupIdRecords(String pageSize, String pageNum) {
    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 10 with GroupIdRecords

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

the class Api2_0_rc4_LastModifiedDatesHelper 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.common_rc4.LastModifiedDate) GroupIdRecord(org.orcid.jaxb.model.groupid_rc4.GroupIdRecord)

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 Response (javax.ws.rs.core.Response)1 LastModifiedDate (org.orcid.jaxb.model.common_rc4.LastModifiedDate)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc1.GroupIdRecords)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc2.GroupIdRecords)1 GroupIdRecords (org.orcid.jaxb.model.groupid_rc3.GroupIdRecords)1 GroupIdRecord (org.orcid.jaxb.model.groupid_rc4.GroupIdRecord)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