Skip to content

Commit

Permalink
Merge branch 'master' into MODORDERS-1079
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-git authored Apr 4, 2024
2 parents bea6cb1 + d74496e commit 7fc31a7
Show file tree
Hide file tree
Showing 20 changed files with 1,004 additions and 21 deletions.
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 @@
}
]
},
{
"id": "orders.routing-list",
"version": "1.0",
"handlers": [
{
"methods": ["GET"],
"pathPattern": "/orders/routing-lists/{id}/template",
"permissionsRequired": ["orders.routing-list-template.item.get"],
"modulePermissions": [
"orders-storage.routing-lists.item.get",
"users.collection.get",
"template-request.post"
]
}
]
},
{
"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"
]
},
{
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

0 comments on commit 7fc31a7

Please sign in to comment.