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\":\"\"}"));
}
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");
}
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);
}
}
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));
}
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"));
}
Aggregations