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