-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODINVSTOR-1222 Implement Subject sources management (#1056)
* MODINVSTOR-1222 Implement Subject sources management * fix checkstyle * small fixes * fix test
- Loading branch information
1 parent
5d3e753
commit f3fe256
Showing
23 changed files
with
664 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"id": "535e3160-763a-42f9-b0c0-d8ed7df6e2a3", | ||
"name": "Library of Congress Subject Headings", | ||
"source": "folio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"subjectSources": [ | ||
{ | ||
"id": "06b2cbd8-66bf-4956-9d90-97c9776365b8", | ||
"name": "Library of Congress Subject Headings", | ||
"source": "folio" | ||
}, | ||
{ | ||
"id": "f9e5b41b-8d5b-47d3-91d0-ca9004796400", | ||
"name": "Library of Congress Children's and Young Adults' Subject Headings", | ||
"source": "folio" | ||
}, | ||
{ | ||
"id": "6e09d47d-95e2-4d8a-831b-f777b8ef6d99", | ||
"name": "Non-medical Subject Headings", | ||
"source": "local" | ||
} | ||
], | ||
"totalRecords": 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"description": "A subject source", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string" | ||
}, | ||
"name": { | ||
"description": "label for the subject source", | ||
"type": "string" | ||
}, | ||
"source": { | ||
"type": "string", | ||
"description": "label indicating where the subject source entry originates from, i.e. 'folio' or 'local'", | ||
"enum": [ | ||
"folio", | ||
"local" | ||
] | ||
}, | ||
"metadata": { | ||
"type": "object", | ||
"$ref": "raml-util/schemas/metadata.schema", | ||
"readonly": true | ||
} | ||
}, | ||
"required": [ | ||
"name" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#%RAML 1.0 | ||
title: Subject Sources API | ||
version: v1.0 | ||
protocols: [ HTTP, HTTPS ] | ||
baseUri: http://localhost | ||
|
||
documentation: | ||
- title: Subject Sources API | ||
content: This documents the API calls that can be made to query and manage subject types | ||
|
||
types: | ||
subjectSource: !include subject-source.json | ||
subjectSources: !include subject-sources.json | ||
errors: !include raml-util/schemas/errors.schema | ||
|
||
traits: | ||
pageable: !include raml-util/traits/pageable.raml | ||
searchable: !include raml-util/traits/searchable.raml | ||
validate: !include raml-util/traits/validation.raml | ||
|
||
resourceTypes: | ||
collection: !include raml-util/rtypes/collection.raml | ||
collection-item: !include raml-util/rtypes/item-collection.raml | ||
get-delete-only: !include raml-util/rtypes/get-delete.raml | ||
|
||
/subject-sources: | ||
type: | ||
collection: | ||
exampleCollection: !include examples/subject-sources.json | ||
exampleItem: !include examples/subject-source.json | ||
schemaCollection: subjectSources | ||
schemaItem: subjectSource | ||
get: | ||
is: [ | ||
searchable: {description: "with valid searchable fields", example: "name=aaa"}, | ||
pageable | ||
] | ||
description: Return a list of subject sources | ||
post: | ||
description: Create a new subject source | ||
is: [validate] | ||
/{subjectSourceId}: | ||
description: Pass in the subject source id | ||
type: | ||
collection-item: | ||
exampleItem: !include examples/subject-source.json | ||
schema: subjectSource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"description": "A collection of subject sources", | ||
"type": "object", | ||
"properties": { | ||
"subjectSources": { | ||
"description": "List of subject sources", | ||
"id": "subjectSource", | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"$ref": "subject-source.json" | ||
} | ||
}, | ||
"totalRecords": { | ||
"description": "Estimated or exact total number of records", | ||
"type": "integer" | ||
} | ||
}, | ||
"required": [ | ||
"subjectSources", | ||
"totalRecords" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/folio/persist/SubjectSourceRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.folio.persist; | ||
|
||
import static org.folio.rest.persist.PgUtil.postgresClient; | ||
import static org.folio.services.subjectsource.SubjectSourceService.SUBJECT_SOURCE; | ||
|
||
import io.vertx.core.Context; | ||
import java.util.Map; | ||
import org.folio.rest.jaxrs.model.SubjectSource; | ||
|
||
public class SubjectSourceRepository extends AbstractRepository<SubjectSource> { | ||
|
||
public SubjectSourceRepository(Context context, Map<String, String> okapiHeaders) { | ||
super(postgresClient(context, okapiHeaders), SUBJECT_SOURCE, SubjectSource.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package org.folio.rest.impl; | ||
|
||
import static io.vertx.core.Future.succeededFuture; | ||
import static org.folio.rest.support.EndpointFailureHandler.handleFailure; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Context; | ||
import io.vertx.core.Handler; | ||
import java.util.Map; | ||
import javax.ws.rs.core.Response; | ||
import org.folio.rest.jaxrs.model.SubjectSource; | ||
import org.folio.rest.jaxrs.resource.SubjectSources; | ||
import org.folio.services.subjectsource.SubjectSourceService; | ||
|
||
public class SubjectSourceApi implements SubjectSources { | ||
|
||
@Override | ||
public void getSubjectSources(String query, String totalRecords, int offset, | ||
int limit, | ||
Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, | ||
Context vertxContext) { | ||
new SubjectSourceService(vertxContext, okapiHeaders) | ||
.getByQuery(query, offset, limit) | ||
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response))) | ||
.onFailure(handleFailure(asyncResultHandler)); | ||
} | ||
|
||
@Override | ||
public void postSubjectSources(SubjectSource entity, | ||
Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, | ||
Context vertxContext) { | ||
new SubjectSourceService(vertxContext, okapiHeaders) | ||
.create(entity) | ||
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response))) | ||
.onFailure(handleFailure(asyncResultHandler)); | ||
} | ||
|
||
@Override | ||
public void getSubjectSourcesBySubjectSourceId(String subjectSourceId, | ||
Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, | ||
Context vertxContext) { | ||
new SubjectSourceService(vertxContext, okapiHeaders) | ||
.getById(subjectSourceId) | ||
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response))) | ||
.onFailure(handleFailure(asyncResultHandler)); | ||
} | ||
|
||
@Override | ||
public void deleteSubjectSourcesBySubjectSourceId(String subjectSourceId, | ||
Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, | ||
Context vertxContext) { | ||
new SubjectSourceService(vertxContext, okapiHeaders) | ||
.delete(subjectSourceId) | ||
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response))) | ||
.onFailure(handleFailure(asyncResultHandler)); | ||
} | ||
|
||
@Override | ||
public void putSubjectSourcesBySubjectSourceId(String subjectSourceId, | ||
SubjectSource entity, | ||
Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, | ||
Context vertxContext) { | ||
new SubjectSourceService(vertxContext, okapiHeaders) | ||
.update(subjectSourceId, entity) | ||
.onSuccess(response -> asyncResultHandler.handle(succeededFuture(response))) | ||
.onFailure(handleFailure(asyncResultHandler)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.