use of dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse in project solr-document-store by DBCDK.
the class BibliographicRecordAPIBeanIT method testGetBibliographicRecord.
@Test
public void testGetBibliographicRecord() {
Response result = bean.getBibliographicRecord("page-order", 103862);
BibliographicFrontendResponse res = (BibliographicFrontendResponse) result.getEntity();
IndexKeys map = new IndexKeys();
map.put("rec.repositoryId", Collections.singletonList("p-o"));
BibliographicEntity b = new BibliographicEntity(103862, "clazzifier", "page-order", "p-o", "work:2", "unit:6", false, map, "track:8");
Assert.assertEquals(res, new BibliographicFrontendResponse(b, "0639423"));
}
use of dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse in project solr-document-store by DBCDK.
the class BibliographicRecordAPIBeanIT method testPagingBibliographicRecordId.
@Test
public void testPagingBibliographicRecordId() {
String bibliographicRecordId = "page-order";
// Should have 8 results, which with a pagesize of 5 is 2 pages
Response json = bean.getBibliographicKeysWithSupersedeId(bibliographicRecordId, 1, 2, "agencyId", false);
FrontendReturnListType<BibliographicFrontendResponse> frontendReturnListType = (FrontendReturnListType<BibliographicFrontendResponse>) json.getEntity();
Assert.assertEquals(4, frontendReturnListType.pages);
}
use of dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse in project solr-document-store by DBCDK.
the class BibliographicRecordAPIBeanIT method testSupersedeIdIncluded.
@Test
public void testSupersedeIdIncluded() throws JsonProcessingException {
String bibliographicRecordId = "page-order";
Response json = bean.getBibliographicKeysWithSupersedeId(bibliographicRecordId, 1, 10, "agencyId", false);
FrontendReturnListType<BibliographicFrontendResponse> frontendReturnListType = (FrontendReturnListType<BibliographicFrontendResponse>) json.getEntity();
List<String> supersedeIds = frontendReturnListType.result.stream().map(b -> b.getSupersedeId()).collect(Collectors.toList());
Assert.assertEquals(supersedeIds, Arrays.asList("0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423"));
String repositoryId = "p-o";
Response jsonRepo = bean.getBibliographicKeysByRepositoryIdWithSupersedeId(repositoryId, 1, 10, "agencyId", false);
FrontendReturnListType<BibliographicFrontendResponse> frontendReturnListTypeRepo = (FrontendReturnListType<BibliographicFrontendResponse>) jsonRepo.getEntity();
List<String> supersedeIdsRepo = frontendReturnListTypeRepo.result.stream().map(b -> b.getSupersedeId()).collect(Collectors.toList());
Assert.assertEquals(supersedeIdsRepo, Arrays.asList("0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423", "0639423"));
}
use of dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse in project solr-document-store by DBCDK.
the class BibliographicRecordAPIBean method getBibliographicRecord.
@GET
@Path("bibliographic-record/{bibliographicRecordId}/{bibliographicAgencyId}")
@Produces({ MediaType.APPLICATION_JSON })
@Timed
public Response getBibliographicRecord(@PathParam("bibliographicRecordId") String bibliographicRecordId, @PathParam("bibliographicAgencyId") int bibliographicAgencyId) {
try (LogWith logWith = track(null)) {
Query frontendQuery = entityManager.createNativeQuery("SELECT b.*,b2b.livebibliographicrecordid as supersede_id " + "FROM bibliographicsolrkeys b " + "LEFT OUTER JOIN bibliographictobibliographic b2b ON b.bibliographicrecordid=b2b.deadbibliographicrecordid " + "WHERE (b.bibliographicrecordid=?1 AND b.agencyid=?2)", "BibliographicEntityWithSupersedeId").setParameter(1, bibliographicRecordId).setParameter(2, bibliographicAgencyId);
Object[] record = (Object[]) frontendQuery.getSingleResult();
return Response.ok(new BibliographicFrontendResponse((BibliographicEntity) record[0], (String) record[1])).build();
}
}
use of dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse in project solr-document-store by DBCDK.
the class BibliographicRecordAPIBeanIT method testGetBibliographicKeys.
@Test
public void testGetBibliographicKeys() {
String bibliographicRecordId = "XYZ";
Response json = bean.getBibliographicKeysWithSupersedeId(bibliographicRecordId, 1, 10, "agencyId", true);
FrontendReturnListType<BibliographicFrontendResponse> frontendReturnListType = (FrontendReturnListType<BibliographicFrontendResponse>) json.getEntity();
Assert.assertEquals(2, frontendReturnListType.result.size());
}
Aggregations