Search in sources :

Example 11 with HoldingsItemEntity

use of dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity in project solr-document-store by DBCDK.

the class BibliographicRecordAPIBeanIT method createBibAndHoldings.

private void createBibAndHoldings(int agencyId, String bibliographicRecordId, int... agencies) {
    em.persist(new BibliographicEntity(agencyId, "clazzifier", bibliographicRecordId, "id#1", "w", "u", false, new IndexKeys(), "IT"));
    for (int i = 0; i < agencies.length; i++) {
        em.persist(new HoldingsItemEntity(agencies[i], bibliographicRecordId, SolrIndexKeys.ON_SHELF, "track"));
        HoldingsToBibliographicEntity h2b = new HoldingsToBibliographicEntity(agencies[i], bibliographicRecordId, agencyId, false);
        em.persist(h2b);
    }
}
Also used : HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity)

Example 12 with HoldingsItemEntity

use of dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity in project solr-document-store by DBCDK.

the class DocumentRetrieveBeanIT method newCommonRecordWithExistingHoldings.

@Test
public void newCommonRecordWithExistingHoldings() throws Exception {
    em.merge(new BibliographicEntity(300000, "clazzifier", "12345678", "id#1", "work:0", "unit:0", false, new IndexKeys(), "T1"));
    em.merge(new HoldingsItemEntity(300101, "12345678", new IndexKeysList(), "T2"));
    em.merge(new HoldingsItemEntity(300102, "12345678", new IndexKeysList(), "T3"));
    em.merge(new HoldingsToBibliographicEntity(300101, "12345678", 300000, false));
    em.merge(new HoldingsToBibliographicEntity(300102, "12345678", 300000, false));
    DocumentRetrieveResponse doc = env().getPersistenceContext().run(() -> bean.getDocumentWithHoldingsitems(300000, "clazzifier", "12345678"));
    assertThat(doc.bibliographicRecord.getAgencyId(), is(300000));
    assertThat(doc.bibliographicRecord.getBibliographicRecordId(), is("12345678"));
    assertThat(doc.holdingsItemRecords.size(), is(2));
}
Also used : DocumentRetrieveResponse(dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse) IndexKeysList(dk.dbc.search.solrdocstore.jpa.IndexKeysList) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) Test(org.junit.Test)

Example 13 with HoldingsItemEntity

use of dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity in project solr-document-store by DBCDK.

the class DocumentRetrieveResponseTest method testCase.

@Test(timeout = 2_000L)
public void testCase() throws Exception {
    System.out.println("testCase");
    List<HoldingsItemEntity> holdingsItemRecords = Arrays.asList(hiEntityWith("[" + "{'holdingsitem.status':['online']}," + "{'holdingsitem.itemId':['a1', 'a2', 'a3'], 'holdingsitem.status':['onshelf']}" + "]"), hiEntityWith("[" + "{'holdingsitem.itemId':['b1', 'b2'], 'holdingsitem.status':['onshelf']}," + "{'holdingsitem.itemId':['c1', 'c2'], 'holdingsitem.status':['onshelf']}," + "{'holdingsitem.itemId':['d1'], 'holdingsitem.status':['onloan']}" + "]"));
    DocumentRetrieveResponse resp = new DocumentRetrieveResponse(null, holdingsItemRecords, null, null);
    System.out.println("resp.totalStatusCount = " + resp.totalStatusCount);
    List<String> summarized = resp.totalStatusCount.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.toList());
    assertThat(summarized, containsInAnyOrder("onshelf=7", "online=1", "onloan=1"));
}
Also used : DocumentRetrieveResponse(dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse) Arrays(java.util.Arrays) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DocumentRetrieveResponse(dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse) Collectors(java.util.stream.Collectors) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) Test(org.junit.Test)

Example 14 with HoldingsItemEntity

use of dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity in project solr-document-store by DBCDK.

the class EnqueueSupplierBeanIT method holdingsUpdate.

@Test(timeout = 2_000L)
public void holdingsUpdate() {
    System.out.println("holdingsUpdate");
    /*
         * Add Bib( 870970 )
         * Add Holding ( FBS )
         * Queue contains 870970
         * Clear queue
         *
         * Fetch Holding back, update some field
         * Queue contains 870970
         */
    HoldingsItemEntity h = env().getPersistenceContext().run(() -> {
        addBibliographic(commonAgency, "test");
        return addHoldings(fbsAgency, "test");
    });
    assertThat(queueContentAndClear(), containsInAnyOrder(queueItem(commonAgency, "clazzifier", "test"), queueItem("unit:0"), queueItem("work:0")));
    env().getPersistenceContext().run(() -> {
        h.setTrackingId("NEW");
        holdingsItemBean.setHoldingsKeys(h);
    });
    assertThat(queueContentAndClear(), containsInAnyOrder(queueItem(commonAgency, "clazzifier", "test"), queueItem("unit:0"), queueItem("work:0")));
}
Also used : HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) Test(org.junit.Test)

Example 15 with HoldingsItemEntity

use of dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity in project solr-document-store by DBCDK.

the class EnqueueSupplierBeanIT method addHoldings.

private HoldingsItemEntity addHoldings(int holdingAgency, String holdingBibliographicId) throws SQLException {
    // Dummy holding - ensure enqueue from non existing to this
    HoldingsItemEntity e = new HoldingsItemEntity(holdingAgency, holdingBibliographicId, SolrIndexKeys.ON_SHELF, "IT");
    holdingsItemBean.setHoldingsKeys(e);
    return e;
}
Also used : HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity)

Aggregations

HoldingsItemEntity (dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity)22 Test (org.junit.Test)14 HoldingsToBibliographicEntity (dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity)8 BibliographicEntity (dk.dbc.search.solrdocstore.jpa.BibliographicEntity)7 EntityManager (javax.persistence.EntityManager)6 AgencyItemKey (dk.dbc.search.solrdocstore.jpa.AgencyItemKey)5 HoldingsToBibliographicKey (dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicKey)5 DocumentRetrieveResponse (dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse)5 Response (javax.ws.rs.core.Response)5 IndexKeys (dk.dbc.search.solrdocstore.jpa.IndexKeys)4 OpenAgencyEntity (dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Timed (org.eclipse.microprofile.metrics.annotation.Timed)4 LogWith (dk.dbc.log.LogWith)3 AgencyClassifierItemKey (dk.dbc.search.solrdocstore.jpa.AgencyClassifierItemKey)3 BibliographicResourceEntity (dk.dbc.search.solrdocstore.jpa.BibliographicResourceEntity)3 LibraryType (dk.dbc.search.solrdocstore.jpa.LibraryType)3 HashMap (java.util.HashMap)3