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

MLT-0082 Remove Owner from Order and Item #54

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions docker/mongo/mongo-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ db.items.insertOne({
"itemCategory": "PAPER",
"preferredEnvironment": "NONE",
"packaging": "NONE",
"owner": "NB",
"callbackUrl": "https://callback-wls.no/item",
"location": "SYNQ_WAREHOUSE",
"quantity": 1,
Expand All @@ -35,7 +34,6 @@ db.items.insertOne({
"itemCategory": "PAPER",
"preferredEnvironment": "NONE",
"packaging": "NONE",
"owner": "NB",
"callbackUrl": "https://callback-wls.no/item",
"location": "SYNQ_WAREHOUSE",
"quantity": 1,
Expand All @@ -55,7 +53,6 @@ db.orders.insertOne({
}
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import no.nb.mlt.wls.domain.model.Environment
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Item
import no.nb.mlt.wls.domain.model.ItemCategory
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.model.Packaging
import no.nb.mlt.wls.domain.ports.inbound.ItemMetadata
import no.nb.mlt.wls.domain.ports.inbound.ValidationException
Expand All @@ -22,7 +21,6 @@ import org.apache.commons.validator.routines.UrlValidator
"itemCategory": "PAPER",
"preferredEnvironment": "NONE",
"packaging": "NONE",
"owner": "NB",
"callbackUrl": "https://callback-wls.no/item"
}
"""
Expand Down Expand Up @@ -66,11 +64,6 @@ data class ApiItemPayload(
examples = ["NONE", "BOX", "ABOX", "CRATE"]
)
val packaging: Packaging,
@Schema(
description = """Who owns the item. Usually the National Library of Norway ("NB") or the National Archives of Norway ("ARKIVVERKET").""",
examples = ["NB", "ARKIVVERKET"]
)
val owner: Owner,
@Schema(
description = """Callback URL to use for sending item updates to the host system.
For example when item moves or changes quantity in storage.""",
Expand Down Expand Up @@ -101,7 +94,6 @@ data class ApiItemPayload(
itemCategory = itemCategory,
preferredEnvironment = preferredEnvironment,
packaging = packaging,
owner = owner,
callbackUrl = callbackUrl,
location = location,
quantity = quantity
Expand All @@ -115,7 +107,6 @@ data class ApiItemPayload(
itemCategory = itemCategory,
preferredEnvironment = preferredEnvironment,
packaging = packaging,
owner = owner,
callbackUrl = callbackUrl
)

Expand Down Expand Up @@ -159,7 +150,6 @@ fun Item.toApiPayload() =
itemCategory = itemCategory,
preferredEnvironment = preferredEnvironment,
packaging = packaging,
owner = owner,
callbackUrl = callbackUrl,
location = location,
quantity = quantity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Order
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.ports.inbound.CreateOrderDTO
import no.nb.mlt.wls.domain.ports.inbound.ValidationException
import org.apache.commons.validator.routines.UrlValidator
Expand All @@ -23,7 +22,6 @@ import org.apache.commons.validator.routines.UrlValidator
}
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
Expand Down Expand Up @@ -93,13 +91,12 @@ data class ApiOrderPayload(
)
val callbackUrl: String
) {
fun toCreateOrderDTO(owner: Owner) =
fun toCreateOrderDTO() =
CreateOrderDTO(
hostName = hostName,
hostOrderId = hostOrderId,
orderLine = orderLine.map { it.toCreateOrderItem() },
orderType = orderType,
owner = owner,
address = address,
contactPerson = contactPerson,
note = note,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import io.swagger.v3.oas.annotations.tags.Tag
import no.nb.mlt.wls.application.hostapi.ErrorMessage
import no.nb.mlt.wls.application.hostapi.config.checkIfAuthorized
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.ports.inbound.CreateOrder
import no.nb.mlt.wls.domain.ports.inbound.DeleteOrder
import no.nb.mlt.wls.domain.ports.inbound.GetOrder
Expand Down Expand Up @@ -126,14 +125,6 @@ class OrderController(
): ResponseEntity<ApiOrderPayload> {
jwt.checkIfAuthorized(payload.hostName)

// Special handling for Arkivverket is required for the storage systems
val owner =
if (payload.hostName == HostName.ASTA) {
Owner.ARKIVVERKET
} else {
Owner.NB
}

payload.validate()

// Return 200 OK and existing order if it exists
Expand All @@ -143,7 +134,7 @@ class OrderController(
.body(it.toApiOrderPayload())
}

val createdOrder = createOrder.createOrder(payload.toCreateOrderDTO(owner))
val createdOrder = createOrder.createOrder(payload.toCreateOrderDTO())

return ResponseEntity
.status(HttpStatus.CREATED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.ports.inbound.MoveItem
import no.nb.mlt.wls.domain.ports.inbound.OrderStatusUpdate
import no.nb.mlt.wls.domain.ports.inbound.PickItems
import no.nb.mlt.wls.domain.ports.inbound.PickOrderItems
import no.nb.mlt.wls.infrastructure.synq.SynqOwner
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PutMapping
Expand Down Expand Up @@ -93,7 +93,7 @@ class SynqController(
@PutMapping("/pick-update/{owner}/{orderId}")
suspend fun pickOrder(
@Parameter(description = "Owner of the order items")
@PathVariable owner: Owner,
@PathVariable owner: SynqOwner,
@Parameter(description = "Order ID in the storage system")
@PathVariable orderId: String,
@RequestBody payload: SynqOrderPickingConfirmationPayload
Expand Down Expand Up @@ -152,7 +152,7 @@ class SynqController(
suspend fun updateOrder(
@RequestBody orderUpdatePayload: SynqOrderStatusUpdatePayload,
@Parameter(description = "Owner of the order items")
@PathVariable owner: Owner,
@PathVariable owner: SynqOwner,
@Parameter(description = "Order ID in the storage system")
@PathVariable orderId: String
): ResponseEntity<String> {
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/no/nb/mlt/wls/domain/model/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ data class Item(
val itemCategory: ItemCategory,
val preferredEnvironment: Environment,
val packaging: Packaging,
val owner: Owner,
val callbackUrl: String?,
val location: String?,
val quantity: Int?
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/no/nb/mlt/wls/domain/model/Order.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ data class Order(
val status: Status,
val orderLine: List<OrderItem>,
val orderType: Type,
val owner: Owner,
val address: Address?,
val contactPerson: String,
val note: String?,
Expand Down
6 changes: 0 additions & 6 deletions src/main/kotlin/no/nb/mlt/wls/domain/model/Owner.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import no.nb.mlt.wls.domain.model.Environment
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Item
import no.nb.mlt.wls.domain.model.ItemCategory
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.model.Packaging

fun interface AddNewItem {
Expand All @@ -18,7 +17,6 @@ data class ItemMetadata(
val itemCategory: ItemCategory,
val preferredEnvironment: Environment,
val packaging: Packaging,
val owner: Owner,
val callbackUrl: String?
)

Expand All @@ -37,7 +35,6 @@ fun ItemMetadata.toItem(
this.itemCategory,
this.preferredEnvironment,
this.packaging,
this.owner,
this.callbackUrl,
location,
quantity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package no.nb.mlt.wls.domain.ports.inbound

import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Order
import no.nb.mlt.wls.domain.model.Owner

fun interface CreateOrder {
suspend fun createOrder(orderDTO: CreateOrderDTO): Order
Expand All @@ -13,7 +12,6 @@ data class CreateOrderDTO(
val hostOrderId: String,
val orderLine: List<OrderItem>,
val orderType: Order.Type,
val owner: Owner,
val contactPerson: String,
val address: Order.Address?,
val note: String?,
Expand All @@ -34,7 +32,6 @@ fun CreateOrderDTO.toOrder(): Order {
Order.OrderItem(it.hostId, Order.OrderItem.Status.NOT_STARTED)
},
orderType = orderType,
owner = owner,
contactPerson = contactPerson,
address = address,
note = note,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import no.nb.mlt.wls.domain.model.Environment
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Item
import no.nb.mlt.wls.domain.model.ItemCategory
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.model.Packaging

@Schema(
Expand All @@ -19,7 +18,6 @@ import no.nb.mlt.wls.domain.model.Packaging
"itemCategory": "PAPER",
"preferredEnvironment": "NONE",
"packaging": "NONE",
"owner": "NB",
"callbackUrl": "https://callback-wls.no/item",
"location": "SYNQ_WAREHOUSE",
"quantity": 1
Expand Down Expand Up @@ -65,11 +63,6 @@ data class NotificationItemPayload(
examples = ["NONE", "BOX", "ABOX", "CRATE"]
)
val packaging: Packaging,
@Schema(
description = """Who owns the item. Usually the National Library of Norway ("NB") or the National Archives of Norway ("ARKIVVERKET").""",
examples = ["NB", "ARKIVVERKET"]
)
val owner: Owner,
@Schema(
description = """Callback URL to use for sending item updates to the host system.
For example when item moves or changes quantity in storage.""",
Expand Down Expand Up @@ -101,7 +94,6 @@ fun NotificationItemPayload.toItem(): Item {
itemCategory = itemCategory,
preferredEnvironment = preferredEnvironment,
packaging = packaging,
owner = owner,
callbackUrl = callbackUrl,
location = location,
quantity = quantity
Expand All @@ -116,7 +108,6 @@ fun Item.toNotificationItemPayload(): NotificationItemPayload {
itemCategory = itemCategory,
preferredEnvironment = preferredEnvironment,
packaging = packaging,
owner = owner,
callbackUrl = callbackUrl,
location = location,
quantity = quantity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package no.nb.mlt.wls.infrastructure.callbacks
import io.swagger.v3.oas.annotations.media.Schema
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Order
import no.nb.mlt.wls.domain.model.Owner

@Schema(
description = """Payload for updates about orders sent from Hermes WLS to the appropriate catalogues.""",
Expand All @@ -19,7 +18,6 @@ import no.nb.mlt.wls.domain.model.Owner
}
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
Expand Down Expand Up @@ -66,11 +64,6 @@ data class NotificationOrderPayload(
examples = ["LOAN", "DIGITIZATION"]
)
val orderType: Order.Type,
@Schema(
description = """Who's the owner of the material in the order.""",
examples = ["NB", "ARKIVVERKET"]
)
val owner: Owner?,
@Schema(
description = """Who to contact in relation to the order if case of any problems/issues/questions.""",
example = "Dr. Heinz Doofenshmirtz"
Expand Down Expand Up @@ -101,7 +94,6 @@ fun Order.toNotificationOrderPayload() =
status = status,
orderLine = orderLine,
orderType = orderType,
owner = owner,
contactPerson = contactPerson,
address = address,
note = note,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import no.nb.mlt.wls.domain.model.Environment
import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Item
import no.nb.mlt.wls.domain.model.ItemCategory
import no.nb.mlt.wls.domain.model.Owner
import no.nb.mlt.wls.domain.model.Packaging
import org.springframework.data.mongodb.core.mapping.Document

Expand All @@ -16,7 +15,6 @@ data class MongoItem(
val itemCategory: ItemCategory,
val preferredEnvironment: Environment,
val packaging: Packaging,
val owner: Owner,
val callbackUrl: String?,
val location: String?,
val quantity: Int?
Expand All @@ -30,7 +28,6 @@ fun Item.toMongoItem() =
this.itemCategory,
this.preferredEnvironment,
this.packaging,
this.owner,
this.callbackUrl,
this.location,
this.quantity
Expand All @@ -44,7 +41,6 @@ fun MongoItem.toItem() =
this.itemCategory,
this.preferredEnvironment,
this.packaging,
this.owner,
this.callbackUrl,
this.location,
this.quantity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package no.nb.mlt.wls.infrastructure.repositories.order

import no.nb.mlt.wls.domain.model.HostName
import no.nb.mlt.wls.domain.model.Order
import no.nb.mlt.wls.domain.model.Owner
import org.bson.types.ObjectId
import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.index.CompoundIndex
Expand All @@ -18,7 +17,6 @@ data class MongoOrder(
val status: Order.Status,
val orderLine: List<Order.OrderItem>,
val orderType: Order.Type,
val owner: Owner,
val contactPerson: String,
val address: Order.Address?,
val note: String?,
Expand All @@ -32,7 +30,6 @@ fun Order.toMongoOrder(): MongoOrder {
status = status,
orderLine = orderLine,
orderType = orderType,
owner = owner,
contactPerson = contactPerson,
address = address,
note = note,
Expand All @@ -47,7 +44,6 @@ fun MongoOrder.toOrder(): Order {
status = status,
orderLine = orderLine,
orderType = orderType,
owner = owner,
contactPerson = contactPerson,
address = address,
note = note,
Expand Down
Loading