Search in sources :

Example 11 with IndexKeys

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

the class BibliographicEntityTest method simpleEncode.

@Test
public void simpleEncode() throws Exception {
    IndexKeys indexKeys = new IndexKeys();
    indexKeys.put("title", Arrays.asList("unix bogen", "title2"));
    indexKeys.put("id", Collections.singletonList("argle"));
    BibliographicEntity be = new BibliographicEntity(200, "clazzifier", "1234", "id#1", "work:1", "unit:2", false, indexKeys, "");
    String s = context.marshall(be);
    assertThat(s, is("{\"agencyId\":200,\"classifier\":\"clazzifier\",\"bibliographicRecordId\":\"1234\",\"repositoryId\":\"id#1\",\"work\":\"work:1\",\"unit\":\"unit:2\",\"deleted\":false,\"indexKeys\":{\"id\":[\"argle\"],\"title\":[\"unix bogen\",\"title2\"]},\"trackingId\":\"\"}"));
}
Also used : BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Test(org.junit.Test)

Example 12 with IndexKeys

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

the class BibliographicRecordAPIBeanIT method before.

@Before
public void before() {
    // Setup bean
    em = env().getEntityManager();
    bean = createBiliographicRecordAPIBean(jpaTestEnvironment);
    // Setup records
    env().getPersistenceContext().run(() -> {
        createBibAndHoldings(commonAgency, "ABC", holdingAgencies);
        createBibAndHoldings(commonAgency, "XYZ", holdingAgencies);
        em.persist(new BibliographicEntity(4711, "clazzifier", "XYZ", "id#1", "w", "u", false, new IndexKeys(), "IT"));
    });
    executeScriptResource("/frontendIT.sql");
}
Also used : HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Before(org.junit.Before)

Example 13 with IndexKeys

use of dk.dbc.search.solrdocstore.jpa.IndexKeys 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 14 with IndexKeys

use of dk.dbc.search.solrdocstore.jpa.IndexKeys 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 15 with IndexKeys

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

the class HoldingsItemEntityIT method storeEntity.

@Test
public void storeEntity() {
    EntityManager em = env().getEntityManager();
    env().getPersistenceContext().run(() -> {
        IndexKeys doc1 = new IndexKeys();
        doc1.put("titel", Collections.singletonList("unix bogen"));
        doc1.put("id", Collections.singletonList("argle"));
        IndexKeys doc2 = new IndexKeys();
        doc2.put("titel", Collections.singletonList("unix bogen"));
        doc2.put("id", Collections.singletonList("argle"));
        doc2.put("dyr", Collections.singletonList("hest"));
        em.persist(new HoldingsItemEntity(200, "1234", IndexKeysList.from(doc1, doc2), ""));
    });
    Object key = new AgencyItemKey(200, "1234");
    HoldingsItemEntity be2 = em.find(HoldingsItemEntity.class, key);
    assertThat(be2.getAgencyId(), is(200));
    assertThat(be2.getBibliographicRecordId(), is("1234"));
}
Also used : AgencyItemKey(dk.dbc.search.solrdocstore.jpa.AgencyItemKey) EntityManager(javax.persistence.EntityManager) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) Test(org.junit.Test)

Aggregations

IndexKeys (dk.dbc.search.solrdocstore.jpa.IndexKeys)20 BibliographicEntity (dk.dbc.search.solrdocstore.jpa.BibliographicEntity)15 Test (org.junit.Test)13 HoldingsToBibliographicEntity (dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity)7 HoldingsItemEntity (dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity)5 EntityManager (javax.persistence.EntityManager)5 Response (javax.ws.rs.core.Response)5 SolrIndexKeys (dk.dbc.search.solrdocstore.SolrIndexKeys)3 AgencyItemFieldKey (dk.dbc.search.solrdocstore.jpa.AgencyItemFieldKey)3 BibliographicResourceEntity (dk.dbc.search.solrdocstore.jpa.BibliographicResourceEntity)3 OpenAgencyEntity (dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity)3 AgencyClassifierItemKey (dk.dbc.search.solrdocstore.jpa.AgencyClassifierItemKey)2 AgencyItemKey (dk.dbc.search.solrdocstore.jpa.AgencyItemKey)2 IndexKeysList (dk.dbc.search.solrdocstore.jpa.IndexKeysList)2 BibliographicEntityRequest (dk.dbc.search.solrdocstore.request.BibliographicEntityRequest)2 Before (org.junit.Before)2 BibliographicToBibliographicEntity (dk.dbc.search.solrdocstore.jpa.BibliographicToBibliographicEntity)1 HoldingsToBibliographicKey (dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicKey)1 BibliographicFrontendResponse (dk.dbc.search.solrdocstore.response.BibliographicFrontendResponse)1 DocumentRetrieveResponse (dk.dbc.search.solrdocstore.response.DocumentRetrieveResponse)1