Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MODORDERS-1026] - Implemented API to execute mod-template-engine request #874

Merged
merged 42 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c73fa3e
updated acq-model for routing list
azizbekxm Mar 27, 2024
47ef021
[MODORSERS-1026] - Implement API to execute mod-template-engine request
azizbekxm Mar 28, 2024
9661f92
[MODORSERS-1026] - Update permissions
azizbekxm Mar 28, 2024
17a3b29
Merge branch 'master' into MODORDERS-1026
azizbekxm Mar 28, 2024
63766bc
[MODORSERS-1026] - Fixed context issue
azizbekxm Mar 28, 2024
75c4c08
[MODORSERS-1026] - Added RoutingList service to ApplicationConfig
azizbekxm Mar 28, 2024
5326d4e
[MODORSERS-1026] - Added UserService to ApplicationConfig
azizbekxm Mar 28, 2024
1276445
[MODORSERS-1026] - Implemented api to execute template-request api
azizbekxm Mar 29, 2024
7dc0657
[MODORSERS-1026] - Fixed logs issue
azizbekxm Mar 29, 2024
d83c8ab
[MODORSERS-1026] - added hashcode in TemplateProcessingRequest
azizbekxm Mar 29, 2024
48e3ee4
[MODORSERS-1026] - Added jsonProperty annotation
azizbekxm Mar 29, 2024
e94d73d
[MODORSERS-1026] - Added jsonProperty annotation
azizbekxm Mar 29, 2024
155ea13
[MODORSERS-1026] - tmp log level changed
azizbekxm Mar 29, 2024
e12d91c
[MODORSERS-1026] - Fixed jsonObject converting error
azizbekxm Mar 29, 2024
15d5f35
[MODORSERS-1026] - Fixed endpoint
azizbekxm Mar 29, 2024
274616e
[MODORSERS-1026] - Added tests
azizbekxm Apr 1, 2024
413be73
[MODORSERS-1026] - Fixed tests
azizbekxm Apr 1, 2024
31dc9c0
Merge branch 'master' into MODORDERS-1026
azizbekxm Apr 1, 2024
6724613
[MODORSERS-1026] - Improved template request context
azizbekxm Apr 2, 2024
f7f467f
Merge remote-tracking branch 'origin/MODORDERS-1026' into MODORDERS-1026
azizbekxm Apr 2, 2024
b2a135f
[MODORSERS-1026] - Improved template request context
azizbekxm Apr 2, 2024
980c337
[MODORSERS-1026] - Improved template request context
azizbekxm Apr 2, 2024
4390ef2
Merge branch 'master' into MODORDERS-1026
azizbekxm Apr 2, 2024
7e4980b
[MODORSERS-1026] - Changed api design
azizbekxm Apr 2, 2024
fa557e5
[MODORSERS-1026] - Fixed test
azizbekxm Apr 2, 2024
929aaba
[MODORSERS-1026] - Updated descriptor
azizbekxm Apr 2, 2024
7ff500a
[MODORSERS-1026] - Updated descriptor
azizbekxm Apr 2, 2024
31888b9
[MODORSERS-1026] - Created dto object for userCollection
azizbekxm Apr 3, 2024
6a23713
[MODORSERS-1026] - Improved tests and fixed jsonObject issue
azizbekxm Apr 3, 2024
a301ec0
[MODORSERS-1026] - Prepared to code-review
azizbekxm Apr 3, 2024
7a2f95e
Merge branch 'master' into MODORDERS-1026
azizbekxm Apr 3, 2024
6945eb6
[MODORSERS-1026] - Minor improvement
azizbekxm Apr 3, 2024
2cd840f
Merge remote-tracking branch 'origin/MODORDERS-1026' into MODORDERS-1026
azizbekxm Apr 3, 2024
689877a
[MODORSERS-1026] - Major improvement
azizbekxm Apr 3, 2024
2ce161b
Merge branch 'master' into MODORDERS-1026
azizbekxm Apr 3, 2024
c1c0cdc
[MODORSERS-1026] - Fixed logic to get addressLine
azizbekxm Apr 4, 2024
61f892f
[MODORSERS-1026] - added userService test
azizbekxm Apr 4, 2024
adfc40c
[MODORSERS-1026] - Fixed Setting api
azizbekxm Apr 4, 2024
c3a9f95
[MODORSERS-1026] - Fix the setting api
azizbekxm Apr 4, 2024
1298d3b
[MODORSERS-1026] - Increased unit test
azizbekxm Apr 4, 2024
9837b1b
[MODORSERS-1026] - Increased unit test
azizbekxm Apr 4, 2024
d86faff
[MODORSERS-1026] - Reformat code
azizbekxm Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,22 @@
}
]
},
SerhiiNosko marked this conversation as resolved.
Show resolved Hide resolved
{
"id": "orders.routing-list",
"version": "1.0",
"handlers": [
{
"methods": ["GET"],
"pathPattern": "/orders/routing-lists/{id}/template",
SerhiiNosko marked this conversation as resolved.
Show resolved Hide resolved
"permissionsRequired": ["orders.routing-list-template.item.get"],
"modulePermissions": [
"orders-storage.routing-lists.item.get",
"users.collection.get",
"template-request.post"
]
SerhiiNosko marked this conversation as resolved.
Show resolved Hide resolved
}
]
},
{
"id": "_jsonSchemas",
"version": "1.0",
Expand Down Expand Up @@ -1198,6 +1214,14 @@
{
"id": "user-tenants",
"version": "1.0"
},
{
"id": "users",
"version": "16.0"
},
{
"id": "template-engine",
"version": "2.2"
}
],
"optional": [
Expand Down Expand Up @@ -1705,6 +1729,11 @@
"displayName" : "orders holding-summary get",
"description" : "Holding summary"
},
{
"permissionName": "orders.routing-list-template.item.get",
"displayName" : "orders routing-list-template item get",
"description" : "Orders routing-list-template item get"
},
{
"permissionName": "orders.all",
"displayName": "orders - all permissions",
Expand Down Expand Up @@ -1739,8 +1768,8 @@
"orders.rollover.item.post",
"orders.holding-summary.collection.get",
"orders.acquisition-methods.all",
"orders.export-history.all"

"orders.export-history.all",
"orders.routing-list-template.item.get"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add this permission in routing-lists.all when this PR will be merged #879

]
},
{
Expand Down
47 changes: 47 additions & 0 deletions ramls/routing-lists.raml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#%RAML 1.0
title: "RoutingList"
baseUri: https://github.com/folio-org/mod-orders
version: v1.0

documentation:
- title: Routing lists
content: <b>CRUD API to manage routing lists.</b>

types:
routing_list: !include acq-models/mod-orders-storage/schemas/routing_list.json
routing_list_collection: !include acq-models/mod-orders-storage/schemas/routing_list_collection.json
UUID:
type: string
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$

traits:
pageable: !include raml-util/traits/pageable.raml
searchable: !include raml-util/traits/searchable.raml

resourceTypes:
collection: !include rtypes/collection-with-json-response.raml
collection-item: !include rtypes/item-collection-with-json-response.raml

/orders/routing-lists:
type:
collection:
exampleCollection: !include acq-models/mod-orders-storage/examples/routing_list_collection.sample
exampleItem: !include acq-models/mod-orders-storage/examples/routing_list_get.sample
schemaCollection: routing_list_collection
schemaItem: routing_list
get:
description: Get routing lists
is: [
searchable: {description: "with valid searchable fields: for example routing list", example: "[\"routing_list\", \"ROUTING_LIST\", \"=\"]"},
pageable
]
post:
description: Create routing lists

/{id}/template:
uriParameters:
id:
description: The UUID of a Title
type: UUID
get:
description: Execute mod-template-engine to process templates with replaced token placeholders [update]
12 changes: 12 additions & 0 deletions src/main/java/org/folio/config/ApplicationConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.folio.service.ReasonForClosureService;
import org.folio.service.SuffixService;
import org.folio.service.TagService;
import org.folio.service.UserService;
import org.folio.service.caches.ConfigurationEntriesCache;
import org.folio.service.caches.InventoryCache;
import org.folio.service.configuration.ConfigurationEntriesService;
Expand Down Expand Up @@ -111,6 +112,7 @@
import org.folio.service.pieces.flows.update.PieceUpdateFlowInventoryManager;
import org.folio.service.pieces.flows.update.PieceUpdateFlowManager;
import org.folio.service.pieces.flows.update.PieceUpdateFlowPoLineService;
import org.folio.service.RoutingListService;
import org.folio.service.titles.TitleValidationService;
import org.folio.service.titles.TitlesService;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down Expand Up @@ -434,6 +436,16 @@ CompositeOrderDynamicDataPopulateService combinedPopulateService(CompositeOrderR
return new CombinedOrderDataPopulateService(compositeOrderRetrieveHolderBuilder, populateServices);
}

@Bean
RoutingListService routingListService(RestClient restClient, UserService userService) {
return new RoutingListService(restClient, userService);
}

@Bean
UserService userService(RestClient restClient) {
return new UserService(restClient);
}

@Bean
TitlesService titlesService(RestClient restClient, ProtectionService protectionService, InventoryManager inventoryManager) {
return new TitlesService(restClient, protectionService, inventoryManager);
Expand Down
135 changes: 135 additions & 0 deletions src/main/java/org/folio/models/TemplateProcessingRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package org.folio.models;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.folio.rest.jaxrs.model.RoutingList;

public class TemplateProcessingRequest {
@JsonProperty
private UUID templateId;
@JsonProperty
private String lang;
@JsonProperty
private String outputFormat;
@JsonProperty
private Context context;

public UUID getTemplateId() {
return templateId;
}

public String getLang() {
return lang;
}

public String getOutputFormat() {
return outputFormat;
}

public Context getContext() {
return context;
}

public TemplateProcessingRequest withTemplateId(UUID templateId) {
this.templateId = templateId;
return this;
}

public TemplateProcessingRequest withLang(String lang) {
this.lang = lang;
return this;
}

public TemplateProcessingRequest withOutputFormat(String outputFormat) {
this.outputFormat = outputFormat;
return this;
}

public TemplateProcessingRequest withContext(Context context) {
this.context = context;
return this;
}

public static class Context {
@JsonProperty
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private RoutingList routingList;
@JsonProperty
private List<User> users;

public RoutingList getRoutingList() {
return routingList;
}

public List<User> getUsers() {
return users;
}

public Context withRoutingList(RoutingList routingList) {
this.routingList = routingList;
return this;
}

public Context withUsers(List<User> users) {
this.users = users;
return this;
}
}

public static class User {
@JsonProperty
private String lastName;
@JsonProperty
private String firstName;
@JsonProperty
private String routingAddress;

public String getLastName() {
return lastName;
}

public String getFirstName() {
return firstName;
}

public String getRoutingAddress() {
return routingAddress;
}

public User withLastName(String lastName) {
this.lastName = lastName;
return this;
}

public User withFirstName(String firstName) {
this.firstName = firstName;
return this;
}

public User withRoutingAddress(String routingAddress) {
this.routingAddress = routingAddress;
return this;
}
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TemplateProcessingRequest that)) return false;
return Objects.equals(templateId, that.templateId)
&& Objects.equals(lang, that.lang)
&& Objects.equals(outputFormat, that.outputFormat)
&& Objects.equals(context, that.context);
}

@Override
public int hashCode() {
return Objects.hash(templateId, lang, outputFormat, context);
}
}

76 changes: 76 additions & 0 deletions src/main/java/org/folio/models/UserCollection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.folio.models;

import java.util.List;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public class UserCollection {
@JsonProperty
private List<User> users;
@JsonProperty
private int totalRecords;

public List<User> getUsers() {
return users;
}
public int getTotalRecords() {
return totalRecords;
}

public UserCollection withUsers(List<User> users) {
this.users = users;
return this;
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static class User {
@JsonProperty
private UUID id;
@JsonProperty
private Personal personal;

public UUID getId () {
return id;
}
public Personal getPersonal () {
return personal;
}

@JsonIgnoreProperties(ignoreUnknown = true)
public static class Personal {
@JsonProperty
private String firstName;
@JsonProperty
private String lastName;
@JsonProperty
private List<Address> addresses;

public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public List<Address> getAddresses() {
return addresses;
}
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Address {
@JsonProperty
private String addressLine1;
@JsonProperty
private String addressTypeId;

public String getAddressLine1() {
return addressLine1;
}
public String getAddressTypeId() {
return addressTypeId;
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ private ResourcePathResolver() {
public static final String PAYMENT_STATUS = "paymentStatus";
public static final String ORDER_TEMPLATES = "orderTemplates";
public static final String TITLES = "titles";
public static final String TEMPLATE_REQUEST = "templateRequest";
public static final String FUNDS = "finance.funds";
public static final String BUDGETS = "finance.budgets";
public static final String LEDGERS = "finance.ledgers";
Expand All @@ -47,6 +48,9 @@ private ResourcePathResolver() {
public static final String ORDER_INVOICE_RELATIONSHIP = "order-invoice-relationship";
public static final String EXPORT_HISTORY = "export-history";
public static final String TAGS = "tags";
public static final String ROUTING_LISTS = "routingLists";
public static final String ORDER_SETTINGS = "orderSettings";
public static final String USERS = "users";

private static final Map<String, String> SUB_OBJECT_ITEM_APIS;
private static final Map<String, String> SUB_OBJECT_COLLECTION_APIS;
Expand All @@ -66,6 +70,7 @@ private ResourcePathResolver() {
apis.put(RECEIVING_HISTORY, "/orders-storage/receiving-history");
apis.put(PO_LINE_NUMBER, "/orders-storage/po-line-number");
apis.put(ORDER_TEMPLATES, "/orders-storage/order-templates");
apis.put(TEMPLATE_REQUEST, "/template-request");
apis.put(FUNDS, "/finance/funds");
apis.put(BUDGETS, "/finance/budgets");
apis.put(LEDGERS, "/finance-storage/ledgers");
Expand All @@ -86,6 +91,9 @@ private ResourcePathResolver() {
apis.put(ORDER_INVOICE_RELATIONSHIP, "/orders-storage/order-invoice-relns");
apis.put(EXPORT_HISTORY, "/orders-storage/export-history");
apis.put(TAGS, "/tags");
apis.put(USERS, "/users");
apis.put(ORDER_SETTINGS, "/orders-storage/settings");
apis.put(ROUTING_LISTS, "/orders-storage/routing-lists");

SUB_OBJECT_COLLECTION_APIS = Collections.unmodifiableMap(apis);
SUB_OBJECT_ITEM_APIS = Collections.unmodifiableMap(
Expand Down
Loading
Loading