Search in sources :

Example 1 with IndexKeys

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

the class BibliographicEntityIT method LoadEntity.

@Test
public void LoadEntity() {
    executeScriptResource("/entityTestData.sql");
    EntityManager em = env().getEntityManager();
    AgencyClassifierItemKey key = new AgencyClassifierItemKey(300, "clazzifier", "4321");
    BibliographicEntity be = env().getPersistenceContext().run(() -> em.find(BibliographicEntity.class, key));
    assertThat(be.getAgencyId(), is(300));
    assertThat(be.getClassifier(), is("clazzifier"));
    assertThat(be.getBibliographicRecordId(), is("4321"));
    assertThat(be.getWork(), is("work:3"));
    assertThat(be.getUnit(), is("unit:3"));
    assertThat(be.isDeleted(), is(true));
    IndexKeys expected = new IndexKeys();
    expected.put("ti", Arrays.asList("isdnBogen", "title2"));
    expected.put("001", Collections.singletonList("argle"));
    assertThat(be.getIndexKeys(), is(expected));
    assertThat(be.getTrackingId(), is("track"));
}
Also used : EntityManager(javax.persistence.EntityManager) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) AgencyClassifierItemKey(dk.dbc.search.solrdocstore.jpa.AgencyClassifierItemKey) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Test(org.junit.Test)

Example 2 with IndexKeys

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

the class BibliographicEntityIT method StoreEntity.

@Test
public void StoreEntity() {
    EntityManager em = env().getEntityManager();
    env().getPersistenceContext().run(() -> {
        IndexKeys indexKeys = new IndexKeys();
        indexKeys.put("titel", Collections.singletonList("unix bogen"));
        indexKeys.put("id", Collections.singletonList("argle"));
        BibliographicEntity be = new BibliographicEntity(200, "clazzifier", "1234", "id#1", "work:1", "unit:2", false, indexKeys, "");
        em.persist(be);
    });
    AgencyClassifierItemKey key = new AgencyClassifierItemKey(200, "clazzifier", "1234");
    BibliographicEntity be2 = env().getPersistenceContext().run(() -> em.find(BibliographicEntity.class, key));
    assertThat(be2.getAgencyId(), is(200));
    assertThat(be2.getClassifier(), is("clazzifier"));
    assertThat(be2.getBibliographicRecordId(), is("1234"));
}
Also used : EntityManager(javax.persistence.EntityManager) BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) AgencyClassifierItemKey(dk.dbc.search.solrdocstore.jpa.AgencyClassifierItemKey) Test(org.junit.Test)

Example 3 with IndexKeys

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

the class BibliographicEntityTest method simpleDecode.

@Test
public void simpleDecode() throws Exception {
    String jsonContent = "{\"agencyId\":200,\"classifier\":\"clazzifier\",\"bibliographicRecordId\":\"1234\",\"repositoryId\":\"id#1\",\"work\":\"work:1\",\"unit\":\"unit:2\",\"deleted\":false,\"indexKeys\":{\"title\": [\"unix bogen\", \"title2\"], \"id\": [\"argle\"] },\"trackingId\":\"\"}";
    BibliographicEntity be = context.unmarshall(jsonContent, BibliographicEntity.class);
    assertThat(be.getAgencyId(), is(200));
    assertThat(be.getClassifier(), is("clazzifier"));
    assertThat(be.getBibliographicRecordId(), is("1234"));
    assertThat(be.getRepositoryId(), is("id#1"));
    assertThat(be.getWork(), is("work:1"));
    assertThat(be.getUnit(), is("unit:2"));
    assertThat(be.isDeleted(), is(false));
    assertThat(be.getTrackingId(), is(""));
    IndexKeys expected = new IndexKeys();
    expected.put("title", Arrays.asList("unix bogen", "title2"));
    expected.put("id", Collections.singletonList("argle"));
    assertThat(be.getIndexKeys(), is(expected));
}
Also used : BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys) Test(org.junit.Test)

Example 4 with IndexKeys

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

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

the class EnqueueSupplierBeanIT method addBibliographic.

private BibliographicEntity addBibliographic(int agency, String classifier, String bibliographicRecordId, Optional<List<String>> superseed) throws SQLException {
    List<String> superseedList = superseed.orElse(Collections.emptyList());
    BibliographicEntity e = new BibliographicEntity(agency, classifier, bibliographicRecordId, "id#1", "work:0", "unit:0", false, new IndexKeys(), "IT");
    bibliographicBean.addBibliographicKeys(e, superseedList, true);
    return e;
}
Also used : BibliographicEntity(dk.dbc.search.solrdocstore.jpa.BibliographicEntity) IndexKeys(dk.dbc.search.solrdocstore.jpa.IndexKeys)

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