Search in sources :

Example 1 with BibliographicFrontendResponse

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"));
}
Also used : BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Response(javax.ws.rs.core.Response) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Test(org.junit.Test)

Example 2 with BibliographicFrontendResponse

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);
}
Also used : BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Response(javax.ws.rs.core.Response) FrontendReturnListType(dk.dbc.search.solrdocstore.response.FrontendReturnListType) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Test(org.junit.Test)

Example 3 with BibliographicFrontendResponse

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"));
}
Also used : BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Response(javax.ws.rs.core.Response) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) java.util(java.util) BeanFactoryUtil(dk.dbc.search.solrdocstore.BeanFactoryUtil) LibraryType(dk.dbc.search.solrdocstore.jpa.LibraryType) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) EntityManager(javax.persistence.EntityManager) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) JSONBContext(dk.dbc.commons.jsonb.JSONBContext) Response(javax.ws.rs.core.Response) FrontendReturnListType(dk.dbc.search.solrdocstore.response.FrontendReturnListType) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) Assert(org.junit.Assert) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) FrontendReturnListType(dk.dbc.search.solrdocstore.response.FrontendReturnListType) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Test(org.junit.Test)

Example 4 with BibliographicFrontendResponse

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();
    }
}
Also used : LogWith(dk.dbc.log.LogWith) Query(javax.persistence.Query) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(org.eclipse.microprofile.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 5 with BibliographicFrontendResponse

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());
}
Also used : BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Response(javax.ws.rs.core.Response) FrontendReturnListType(dk.dbc.search.solrdocstore.response.FrontendReturnListType) BibliographicFrontendResponse(dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse) Test(org.junit.Test)

Aggregations

BibliographicFrontendResponse (dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse)7 Response (javax.ws.rs.core.Response)6 FrontendReturnListType (dk.dbc.search.solrdocstore.response.FrontendReturnListType)5 BibliographicEntity (dk.dbc.search.solrdocstore.jpa.BibliographicEntity)4 Test (org.junit.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 LogWith (dk.dbc.log.LogWith)3 HoldingsItemEntity (dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity)3 Collectors (java.util.stream.Collectors)3 EntityManager (javax.persistence.EntityManager)3 Query (javax.persistence.Query)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Timed (org.eclipse.microprofile.metrics.annotation.Timed)3 LogWith.track (dk.dbc.log.LogWith.track)2 HoldingsToBibliographicEntity (dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity)2 IndexKeys (dk.dbc.search.solrdocstore.jpa.IndexKeys)2 List (java.util.List)2 Stateless (javax.ejb.Stateless)2