Search in sources :

Example 16 with IndexKeys

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

the class HoldingsItemEntityIT method loadEntity.

@Test
public void loadEntity() throws Exception {
    executeScriptResource("/entityTestData.sql");
    EntityManager em = env().getEntityManager();
    AgencyItemKey key = new AgencyItemKey(300, "4321");
    HoldingsItemEntity be = env().getPersistenceContext().run(() -> em.find(HoldingsItemEntity.class, key));
    assertThat(be.getAgencyId(), is(300));
    assertThat(be.getBibliographicRecordId(), is("4321"));
    IndexKeysList expected = new IndexKeysList();
    IndexKeys doc1 = new IndexKeys();
    doc1.put("title", Collections.singletonList("unix bogen"));
    doc1.put("id", Collections.singletonList("argle"));
    expected.add(doc1);
    IndexKeys doc2 = new IndexKeys();
    doc2.put("title", Collections.singletonList("unix bogen"));
    doc2.put("id", Collections.singletonList("argle"));
    doc2.put("dyr", Collections.singletonList("hest"));
    expected.add(doc2);
    assertThat(be.getIndexKeys(), is(expected));
    assertThat(be.getTrackingId(), is("track"));
}
Also used : AgencyItemKey(dk.dbc.search.solrdocstore.jpa.AgencyItemKey) EntityManager(javax.persistence.EntityManager) IndexKeysList(dk.dbc.search.solrdocstore.jpa.IndexKeysList) HoldingsItemEntity(dk.dbc.search.solrdocstore.jpa.HoldingsItemEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Test(org.junit.Test)

Example 17 with IndexKeys

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

the class BibliographicBean method extractFedoraStreamDate.

private Instant extractFedoraStreamDate(BibliographicEntity entity) {
    if (entity == null)
        return null;
    IndexKeys indexKeys = entity.getIndexKeys();
    if (indexKeys == null)
        return null;
    List<String> dates = indexKeys.get("rec.fedoraStreamDate");
    if (dates == null || dates.size() != 1)
        return null;
    return Instant.parse(dates.get(0));
}
Also used : IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys)

Example 18 with IndexKeys

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

the class QueueBeanIT method setupItems.

@Before
public void setupItems() {
    EntityManager em = env().getEntityManager();
    env().getPersistenceContext().run(() -> {
        em.persist(new BibliographicEntity(777777, "clazzifier", "12345678", "777777-clazzifier:12345678", "work:4", "unit:8", false, new IndexKeys(), "track-me"));
        em.persist(new BibliographicEntity(777777, "clazzifier", "23456789", "777777-clazzifier:23456789", "work:4", "unit:12", false, new IndexKeys(), "track-me"));
        em.persist(new BibliographicEntity(777777, "clazzifier", "87654321", "777777-clazzifier:87654321", null, null, true, new IndexKeys(), "track-me"));
    });
}
Also used : EntityManager(javax.persistence.EntityManager) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Before(org.junit.Before)

Example 19 with IndexKeys

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

the class ResourceBeanIT method testPutResource.

@Test(timeout = 2_000L)
public void testPutResource() throws Exception {
    System.out.println("testPutResource");
    BibliographicResourceEntity entity;
    Response r;
    Set<String> queue;
    queueContentAndClear();
    env().getPersistenceContext().run(() -> {
        em.merge(new BibliographicEntity(870970, "clazzifier", "25912233", "id#1", "work:update", "unit:update", false, new IndexKeys(), "track:update"));
        em.merge(new BibliographicEntity(710100, "clazzifier", "25912233", "id#1", "work:update", "unit:update", false, new IndexKeys(), "track:update"));
        em.merge(new OpenAgencyEntity(870970, LibraryType.FBS, false, false, false));
        em.merge(new OpenAgencyEntity(710100, LibraryType.FBS, true, true, true));
    });
    r = env().getPersistenceContext().run(() -> bean.putResource("{\"has\":true}", "hasCoverUrl", 870970, "25912233", null));
    assertThat(r.getStatus(), is(200));
    queue = queueContentAndClear();
    assertThat(queue, containsInAnyOrder("w,work:update", "u,unit:update", "m,710100-clazzifier:25912233", "m,870970-clazzifier:25912233"));
    entity = env().getPersistenceContext().run(() -> em.find(BibliographicResourceEntity.class, new AgencyItemFieldKey(870970, "25912233", "hasCoverUrl")));
    assertThat(entity, notNullValue());
    r = env().getPersistenceContext().run(() -> bean.putResource("{\"has\":false}", "hasCoverUrl", 870970, "25912233", null));
    assertThat(r.getStatus(), is(200));
    queue = queueContentAndClear();
    assertThat(queue, containsInAnyOrder("w,work:update", "u,unit:update", "m,710100-clazzifier:25912233", "m,870970-clazzifier:25912233"));
    entity = env().getPersistenceContext().run(() -> em.find(BibliographicResourceEntity.class, new AgencyItemFieldKey(870970, "25912233", "hasCoverUrl")));
    assertThat(entity, nullValue());
}
Also used : Response(javax.ws.rs.core.Response) AgencyItemFieldKey(dk.dbc.search.solrdocstore.jpa.AgencyItemFieldKey) BibliographicResourceEntity(dk.dbc.search.solrdocstore.jpa.BibliographicResourceEntity) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) OpenAgencyEntity(dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity) Test(org.junit.Test)

Example 20 with IndexKeys

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

the class BibliographicBeanIT method testHoldingsUponCommonStaysIfDeletedManifestationIsCreated.

@Test(timeout = 2_000L)
public void testHoldingsUponCommonStaysIfDeletedManifestationIsCreated() throws Exception {
    System.out.println("testHoldingsUponCommonStaysIfDeletedManifestationIsCreated");
    Response r;
    HoldingsToBibliographicEntity htob;
    HoldingsItemBean hol = createHoldingsItemBean(env());
    String a870970 = jsonbContext.marshall(new BibliographicEntityRequest(870970, "clazzifier", "25912233", "id#0", "work:0", "unit:0", false, new IndexKeys(), "IT", null));
    String d710100 = jsonbContext.marshall(new BibliographicEntityRequest(710100, "clazzifier", "25912233", "id#0", "work:0", "unit:0", true, new IndexKeys(), "IT", null));
    String h710100 = jsonRequestHold("710100-25912233-a");
    r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(true, a870970));
    assertThat(r.getStatus(), is(200));
    r = env().getPersistenceContext().run(() -> hol.setHoldingsKeys(h710100));
    assertThat(r.getStatus(), is(200));
    htob = env().getPersistenceContext().run(() -> em.find(HoldingsToBibliographicEntity.class, new HoldingsToBibliographicKey(710100, "25912233")));
    System.out.println("htob = " + htob);
    assertThat(htob, notNullValue());
    assertThat(htob.getBibliographicAgencyId(), is(870970));
    r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(true, d710100));
    assertThat(r.getStatus(), is(200));
    htob = env().getPersistenceContext().run(() -> em.find(HoldingsToBibliographicEntity.class, new HoldingsToBibliographicKey(710100, "25912233")));
    System.out.println("htob = " + htob);
    assertThat(htob, notNullValue());
    assertThat(htob.getBibliographicAgencyId(), is(870970));
}
Also used : Response(javax.ws.rs.core.Response) HoldingsToBibliographicEntity(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) SolrIndexKeys(dk.dbc.search.solrdocstore.SolrIndexKeys) BibliographicEntityRequest(dk.dbc.search.solrdocstore.request.BibliographicEntityRequest) HoldingsToBibliographicKey(dk.dbc.search.solrdocstore.jpa.HoldingsToBibliographicKey) 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