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);
}
}
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;
}
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);
}
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();
}
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;
}
Aggregations