Skip to content

Commit

Permalink
MODINVSTOR-1221 Implement Subject types management (#1050)
Browse files Browse the repository at this point in the history
* MODINVSTOR-1221 Implement Subject types management

* fix checkstyle

* fix checkstyle

* fix checkstyle

* add tests

* add perms into descriptors

* update descriptor

* Update ramls/examples/subjecttypes.json

Co-authored-by: Pavlo Smahin <[email protected]>

* Update ramls/subject-type.raml

Co-authored-by: Pavlo Smahin <[email protected]>

* Update ramls/subject-type.raml

Co-authored-by: Pavlo Smahin <[email protected]>

* small fixes

* add validations

* remove redundant lines

* Update descriptors/ModuleDescriptor-template.json

Co-authored-by: Ruslan Lavrov <[email protected]>

* Update ramls/subject-type.raml

Co-authored-by: Ruslan Lavrov <[email protected]>

---------

Co-authored-by: Pavlo Smahin <[email protected]>
Co-authored-by: Ruslan Lavrov <[email protected]>

(cherry picked from commit 3c619cf)
  • Loading branch information
JavokhirAbdullayev authored and Fazliddin-Ibodullayev-EPAM committed Jan 21, 2025
1 parent 1bb14cc commit 294c477
Show file tree
Hide file tree
Showing 21 changed files with 486 additions and 129 deletions.
5 changes: 0 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Required sourceId field in holdings record ([MODINVSTOR-1161](https://folio-org.atlassian.net/browse/MODINVSTOR-1161))

### New APIs versions
* Provides `subject-source 1.0`
* Provides `subject-types 1.0`
* Provides `instance-date-types 1.0`
* Provides `instance-storage 10.1`
Expand All @@ -18,10 +17,6 @@
* Implement a POST request to get Holdings and Instances ([MODINVSTOR-1223](https://folio-org.atlassian.net/browse/MODINVSTOR-1223))
* Implement instance-date-types endpoint ([MODINVSTOR-1235](https://folio-org.atlassian.net/browse/MODINVSTOR-1235))
* Implement Subject types management ([MODINVSTOR-1221](https://folio-org.atlassian.net/browse/MODINVSTOR-1221))
* Implement endpoint to publish reindex event for the range of instance/item/holding records ([MODINVSTOR-1230](https://folio-org.atlassian.net/browse/MODINVSTOR-1230))
* Info, not warn, about expected 403 from /user-tenants ([MODINVSTOR-1237](https://folio-org.atlassian.net/browse/MODINVSTOR-1237))
* Implement Subject sources management ([MODINVSTOR-1222](https://folio-org.atlassian.net/browse/MODINVSTOR-1222))


### Bug fixes
* Unintended update of instance records \_version (optimistic locking) whenever any of its holdings or items are created, updated or deleted. ([MODINVSTOR-1186](https://folio-org.atlassian.net/browse/MODINVSTOR-1186))
Expand Down
7 changes: 0 additions & 7 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ These properties can be changed by setting env variable.
* `KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS` Default value - `1`
* `KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS` Default value - `1`
* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS` Default value - `1`
* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS` Default value - `16`
* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS` Default value - `1`

# Building

Expand All @@ -129,9 +127,6 @@ These environment variables configure Kafka, for details see [Kafka](#kafka):
* `KAFKA_DOMAIN_TOPIC_NUM_PARTITIONS`
* `KAFKA_CLASSIFICATION_TYPE_TOPIC_NUM_PARTITIONS`
* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS`
* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS`
* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS`


These environment variables configure Kafka topic for specific business-related topics
* `KAFKA_CLASSIFICATION_TYPE_TOPIC_NUM_PARTITIONS`
Expand All @@ -140,8 +135,6 @@ These environment variables configure Kafka topic for specific business-related
* `KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS`
* `KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS`
* `KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS`
* `KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS`
* `KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS`

mod-inventory-storage also supports all Raml Module Builder (RMB) environment variables,
for details see [RMB](https://github.com/folio-org/raml-module-builder#environment-variables):
Expand Down
81 changes: 1 addition & 80 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -557,33 +557,6 @@
}
]
},
{
"id": "subject-sources",
"version": "1.0",
"handlers": [
{
"methods": ["GET"],
"pathPattern": "/subject-sources",
"permissionsRequired": ["inventory-storage.subject-sources.collection.get"]
}, {
"methods": ["GET"],
"pathPattern": "/subject-sources/{id}",
"permissionsRequired": ["inventory-storage.subject-sources.item.get"]
}, {
"methods": ["POST"],
"pathPattern": "/subject-sources",
"permissionsRequired": ["inventory-storage.subject-sources.item.post"]
}, {
"methods": ["PUT"],
"pathPattern": "/subject-sources/{id}",
"permissionsRequired": ["inventory-storage.subject-sources.item.put"]
}, {
"methods": ["DELETE"],
"pathPattern": "/subject-sources/{id}",
"permissionsRequired": ["inventory-storage.subject-sources.item.delete"]
}
]
},
{
"id": "contributor-types",
"version": "2.0",
Expand Down Expand Up @@ -649,20 +622,6 @@
}
]
},
{
"id": "inventory-reindex-records",
"version": "1.0",
"handlers": [
{
"methods": ["POST"],
"pathPattern": "/inventory-reindex-records/publish",
"permissionsRequired": ["inventory-storage.reindex-records.publish.post"],
"modulePermissions": [
"user-tenants.collection.get"
]
}
]
},
{
"id": "instance-formats",
"version": "2.0",
Expand Down Expand Up @@ -1960,11 +1919,6 @@
"displayName": "inventory storage - get bulk ids",
"description": "get a bulk set of record ids from storage"
},
{
"permissionName": "inventory-storage.reindex-records.publish.post",
"displayName": "inventory storage - publish inventory records for reindex",
"description": "publish inventory storage reindex records"
},
{
"permissionName": "inventory-storage.instance-formats.collection.get",
"displayName": "inventory storage - get formats collection",
Expand Down Expand Up @@ -2015,31 +1969,6 @@
"displayName": "inventory storage - delete individual subject type",
"description": "delete subject type in storage"
},
{
"permissionName": "inventory-storage.subject-sources.collection.get",
"displayName": "inventory storage - get subject sources collection",
"description": "get subject-sources collection from storage"
},
{
"permissionName": "inventory-storage.subject-sources.item.get",
"displayName": "inventory storage - get individual subject source",
"description": "get individual subject source from storage"
},
{
"permissionName": "inventory-storage.subject-sources.item.post",
"displayName": "inventory storage - create individual subject source",
"description": "create individual subject source in storage"
},
{
"permissionName": "inventory-storage.subject-sources.item.put",
"displayName": "inventory storage - modify subject source",
"description": "modify subject source in storage"
},
{
"permissionName": "inventory-storage.subject-sources.item.delete",
"displayName": "inventory storage - delete individual subject source",
"description": "delete subject source in storage"
},
{
"permissionName": "inventory-storage.instance-types.collection.get",
"displayName": "inventory storage - get instance types collection",
Expand Down Expand Up @@ -2713,11 +2642,6 @@
"inventory-storage.subject-types.item.post",
"inventory-storage.subject-types.item.put",
"inventory-storage.subject-types.item.delete",
"inventory-storage.subject-sources.collection.get",
"inventory-storage.subject-sources.item.get",
"inventory-storage.subject-sources.item.post",
"inventory-storage.subject-sources.item.put",
"inventory-storage.subject-sources.item.delete",
"inventory-storage.instance-types.collection.get",
"inventory-storage.instance-types.item.get",
"inventory-storage.instance-types.item.post",
Expand Down Expand Up @@ -2845,7 +2769,6 @@
"inventory-storage.migration.job.post",
"inventory-storage.migration.job.item.get",
"inventory-storage.migration.item.get",
"inventory-storage.reindex-records.publish.post",
"inventory-storage.instance-date-types.collection.get",
"inventory-storage.instance-date-types.item.patch"
]
Expand Down Expand Up @@ -2888,9 +2811,7 @@
{ "name": "KAFKA_LIBRARY_TOPIC_NUM_PARTITIONS", "value": "1"},
{ "name": "KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS", "value": "1"},
{ "name": "KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS", "value": "1"},
{ "name": "KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS", "value": "1"},
{ "name": "KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS", "value": "1"},
{ "name": "KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS", "value": "16"}
{ "name": "KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS", "value": "1"}
]
}
}
5 changes: 5 additions & 0 deletions ramls/examples/subject-type.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "535e3160-763a-42f9-b0c0-d8ed7df6e2a2",
"name": "Personal name",
"source": "folio"
}
20 changes: 20 additions & 0 deletions ramls/examples/subject-types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"subjectTypes": [
{
"id": "06b2cbd8-66bf-4956-9d90-97c9776365b8",
"name": "Personal name",
"source": "folio"
},
{
"id": "f9e5b41b-8d5b-47d3-91d0-ca9004796400",
"name": "Occupation",
"source": "folio"
},
{
"id": "6e09d47d-95e2-4d8a-831b-f777b8ef6d99",
"name": "Phone number",
"source": "local"
}
],
"totalRecords": 3
}
4 changes: 2 additions & 2 deletions ramls/subject-type.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"type": "string"
},
"name": {
"description": "label for the subject type",
"description": "label for the identifier type",
"type": "string"
},
"source": {
"type": "string",
"description": "label indicating where the subject type entry originates from, i.e. 'folio' or 'local'",
"description": "label indicating where the identifier type entry originates from, i.e. 'folio' or 'local'",
"enum": [
"folio",
"local"
Expand Down
47 changes: 47 additions & 0 deletions ramls/subject-type.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#%RAML 1.0
title: Subject Types API
version: v1.0
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost

documentation:
- title: Subject Types API
content: This documents the API calls that can be made to query and manage subject types

types:
subjectType: !include subject-type.json
subjectTypes: !include subject-types.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-types:
type:
collection:
exampleCollection: !include examples/subject-types.json
exampleItem: !include examples/subject-type.json
schemaCollection: subjectTypes
schemaItem: subjectType
get:
is: [
searchable: {description: "with valid searchable fields", example: "name=aaa"},
pageable
]
description: Return a list of subject types
post:
description: Create a new subject type
is: [validate]
/{subjectTypeId}:
description: Pass in the subject type id
type:
collection-item:
exampleItem: !include examples/subject-type.json
schema: subjectType
24 changes: 24 additions & 0 deletions ramls/subject-types.json
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 types",
"type": "object",
"properties": {
"subjectTypes": {
"description": "List of subject types",
"id": "subjectType",
"type": "array",
"items": {
"type": "object",
"$ref": "subject-type.json"
}
},
"totalRecords": {
"description": "Estimated or exact total number of records",
"type": "integer"
}
},
"required": [
"subjectTypes",
"totalRecords"
]
}
8 changes: 2 additions & 6 deletions src/main/java/org/folio/InventoryKafkaTopic.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ public enum InventoryKafkaTopic implements KafkaTopic {
LIBRARY("library"),
CAMPUS("campus"),
SUBJECT_TYPE("subject-types"),
INSTITUTION("institution"),
REINDEX_RECORDS("reindex-records"),
SUBJECT_SOURCE("subject-sources");
INSTITUTION("institution");

private static final String DEFAULT_NUM_PARTITIONS_PROPERTY = "KAFKA_DOMAIN_TOPIC_NUM_PARTITIONS";
private static final String DEFAULT_NUM_PARTITIONS_VALUE = "50";
Expand All @@ -37,9 +35,7 @@ public enum InventoryKafkaTopic implements KafkaTopic {
LIBRARY, Pair.of("KAFKA_LIBRARY_TOPIC_NUM_PARTITIONS", "1"),
CAMPUS, Pair.of("KAFKA_CAMPUS_TOPIC_NUM_PARTITIONS", "1"),
INSTITUTION, Pair.of("KAFKA_INSTITUTION_TOPIC_NUM_PARTITIONS", "1"),
SUBJECT_TYPE, Pair.of("KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS", "1"),
REINDEX_RECORDS, Pair.of("KAFKA_REINDEX_RECORDS_TOPIC_NUM_PARTITIONS", "16"),
SUBJECT_SOURCE, Pair.of("KAFKA_SUBJECT_SOURCE_TOPIC_NUM_PARTITIONS", "1")
SUBJECT_TYPE, Pair.of("KAFKA_SUBJECT_TYPE_TOPIC_NUM_PARTITIONS", "1")
);

private final String topic;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/folio/persist/SubjectTypeRepository.java
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.subjecttype.SubjectTypeService.SUBJECT_TYPE;

import io.vertx.core.Context;
import java.util.Map;
import org.folio.rest.jaxrs.model.SubjectType;

public class SubjectTypeRepository extends AbstractRepository<SubjectType> {

public SubjectTypeRepository(Context context, Map<String, String> okapiHeaders) {
super(postgresClient(context, okapiHeaders), SUBJECT_TYPE, SubjectType.class);
}
}
Loading

0 comments on commit 294c477

Please sign in to comment.