use of dk.dbc.search.solrdocstore.request.AddResourceRequest in project solr-document-store by DBCDK.
the class ResourceBean method addResource.
@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("add")
@Operation(operationId = "add-resource", summary = "Adds a resource to an item", description = "This operation sets the resource and connect" + " it to a number of manifestations item, if possible.")
@APIResponses({ @APIResponse(name = "Success", responseCode = "200", description = "Resource has been added", ref = StatusResponse.NAME) })
@RequestBody(ref = BibliographicResourceSchemaAnnotated.NAME)
public Response addResource(String jsonContent) throws JSONBException {
try (LogWith logWith = track(UUID.randomUUID().toString())) {
AddResourceRequest request = jsonbContext.unmarshall(jsonContent, AddResourceRequest.class);
// Add resource
BibliographicResourceEntity resource = request.asBibliographicResource();
log.debug("POST resource: {}", resource);
return storeResource(resource);
}
}
use of dk.dbc.search.solrdocstore.request.AddResourceRequest in project solr-document-store by DBCDK.
the class BibliographicResourceIT method testAddSchoolCommonResourceEnqueue.
@Test
public void testAddSchoolCommonResourceEnqueue() {
System.out.println("testAddSchoolCommonResourceEnqueue");
AddResourceRequest request = new AddResourceRequest(300000, "12121212", "hasCoverUrl", true);
runCommonEnqueueTest(request);
}
use of dk.dbc.search.solrdocstore.request.AddResourceRequest in project solr-document-store by DBCDK.
the class BibliographicResourceIT method testAddResourceOntoDeleted.
@Test(timeout = 2_000L)
public void testAddResourceOntoDeleted() throws Exception {
System.out.println("testAddResourceOntoDeleted");
AddResourceRequest request = new AddResourceRequest(890890, "45454545", "hasCoverUrl", true);
jpa(em -> {
em.merge(new OpenAgencyEntity(890890, LibraryType.NonFBS, false, false, false));
em.merge(new BibliographicEntity(890890, "classifier1", "45454545", "repo", null, null, true, null, "track:1"));
bean.addResource(jsonbContext.marshall(request));
});
assertThat(queueContentAndClear(), empty());
}
use of dk.dbc.search.solrdocstore.request.AddResourceRequest in project solr-document-store by DBCDK.
the class BibliographicResourceIT method testAddFBSSchoolResourceEnqueue.
@Test
public void testAddFBSSchoolResourceEnqueue() {
System.out.println("testAddFBSSchoolResourceEnqueue");
AddResourceRequest request = new AddResourceRequest(312000, "12121212", "hasCoverUrl", true);
runCommonEnqueueTest(request);
}
use of dk.dbc.search.solrdocstore.request.AddResourceRequest in project solr-document-store by DBCDK.
the class BibliographicResourceIT method testAddNonFBSdResourceEnqueue.
@Test
public void testAddNonFBSdResourceEnqueue() {
System.out.println("testAddNonFBSdResourceEnqueue");
AddResourceRequest request = new AddResourceRequest(890890, "45454545", "hasCoverUrl", true);
jpa(em -> {
em.merge(new OpenAgencyEntity(890890, LibraryType.NonFBS, false, false, false));
em.merge(new BibliographicEntity(890890, "classifier1", "45454545", "repo", "work:1", "unit:1", false, null, "track:1"));
em.merge(new BibliographicEntity(890890, "classifier2", "45454545", "repo", "work:1", "unit:1", false, null, "track:1"));
em.merge(new BibliographicEntity(890890, "classifier3", "45454545", "repo", "work:1", "unit:1", false, null, "track:1"));
em.merge(new BibliographicResourceEntity(890890, "45454545", "hasCoverUrl", true));
bean.addResource(jsonbContext.marshall(request));
});
// Only enqueues its own items
assertThat(queueContentAndClear(), containsInAnyOrder(queueItem(890890, "classifier1", "45454545"), queueItem(890890, "classifier2", "45454545"), queueItem(890890, "classifier3", "45454545"), queueItem("work:1")));
}
Aggregations