Skip to content

Commit

Permalink
Cleanup after merge, prettyfied it all
Browse files Browse the repository at this point in the history
  • Loading branch information
MormonJesus69420 committed Dec 13, 2024
1 parent 3390153 commit 8d96858
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 114 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
# Defines that test-project job must finish successfully first, before this one can run
needs: test-project
# The if statement limits the job to only run if action was triggered on main branch or one of the tags
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
if: github.ref == "refs/heads/main" || startsWith(github.ref, "refs/tags/v")
runs-on: self-hosted-linux
# Outputs allows a job to output values that can be picked up by _downstream_ jobs that _depend_ on this job
outputs:
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
needs: publish-image
# Runs only on main branch
# Can be changed to also run on tags, to ensure that stage & prod use same image after a new version release
if: github.ref == 'refs/heads/main'
if: github.ref == "refs/heads/main"
runs-on: self-hosted-linux
# Defines what environment this job references, this allows for setting deployment protections in the project
# Allows requiring a number of reviewers or specific reviewers, or allow only specific branches or tags
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
name: Deploy to Kubernetes Prod
needs: publish-image
# Runs only on tags
if: startsWith(github.event.ref, 'refs/tags/v')
if: startsWith(github.event.ref,"refs/tags/v")
runs-on: self-hosted-linux
environment: prod
steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ The images are built based on the `main` branch as well as project `tags`, and c
# Pull the latest image
docker pull harbor.nb.no/mlt/wls:latest

# Or pull a specific tag (either a GitHub tag or 'main' for the latest main branch image)
# Or pull a specific tag (either a GitHub tag or "main" for the latest main branch image)
docker pull harbor.nb.no/mlt/wls:<TAG>
```

With the image either built or pulled, it can be run using the following command:

```shell
docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE='local-dev' harbor.nb.no/mlt/wls:<TAG>
docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE="local-dev" harbor.nb.no/mlt/wls:<TAG>
```

### Using an IDE
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Use temurin as base image, getting it from local harbor registry, since this is a Kotlin application
# To keep the bloat to a minumum, it uses the alpine version of the image
# Should consider removing the french language pack as well: 'sudo rm -fr /*'
# Should consider removing the french language pack as well: "sudo rm -fr /*"
FROM harbor.nb.no/library/eclipse-temurin:21-jdk-alpine

# Set metadata for the image, this is used to more easily identify the image and who created it
LABEL maintainer="'Magasin og Logistikk' team at NLN"
LABEL maintainer="\"Magasin og Logistikk\" team at NLN"
LABEL description="Hermes WLS (Warehouse and Logistics Service) functions as a \
middleware between NLNs (National Library of Norway) catalogues and storage systems"

# Copy the jar file from the target folder to the root of the container
# GitHub workflow generates the wls.jar file
# When building manually generate the jar file with 'mvn clean package'
# and copy it to the docker folder with 'cp target/wls.jar docker/wls.jar'
# When building manually generate the jar file with "mvn clean package"
# and copy it to the docker folder with "cp target/wls.jar docker/wls.jar"
COPY wls.jar app.jar

# Mark the port that the application is listenting on
Expand Down
8 changes: 4 additions & 4 deletions docker/keycloak/import/mlt-local-realm-export.json
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@
}, {
"id" : "e77adead-5964-4400-9368-3b1520d57bdd",
"name" : "wls-item",
"description" : "A client scope used to add a 'item' scope to the JWT scope field",
"description" : "A client scope used to add a \"item\" scope to the JWT scope field",
"protocol" : "openid-connect",
"attributes" : {
"include.in.token.scope" : "true",
Expand Down Expand Up @@ -1288,7 +1288,7 @@
}, {
"id" : "43e7474f-a3fe-4d44-a0e1-48518c8330f1",
"name" : "wls-synq",
"description" : "A client scope used to add a 'synq' scope to the JWT scope field",
"description" : "A client scope used to add a \"synq\" scope to the JWT scope field",
"protocol" : "openid-connect",
"attributes" : {
"include.in.token.scope" : "true",
Expand Down Expand Up @@ -1431,7 +1431,7 @@
}, {
"id" : "2f9f07c6-b866-402b-8f18-3f7baf021f12",
"name" : "wls-order",
"description" : "A client scope used to add an 'order' scope to the JWT scope field",
"description" : "A client scope used to add an \"order\" scope to the JWT scope field",
"protocol" : "openid-connect",
"attributes" : {
"include.in.token.scope" : "true",
Expand Down Expand Up @@ -2189,4 +2189,4 @@
"clientPolicies" : {
"policies" : [ ]
}
}
}
52 changes: 26 additions & 26 deletions docker/mongo/mongo-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
// This file only runs once during container creation.
// If for some reason it fails to load, re-create the container.
// (by running "docker compose down")
print('START ##################################################################');
print("START ##################################################################");

db = db.getSiblingDB('wls');
db.createUser(
{
user: 'bruker',
pwd: 'drossap',
roles: [{ role: 'readWrite', db: 'wls' }],
user: "bruker",
pwd: "drossap",
roles: [{ role: "readWrite", db: "wls" }],
},
);


db.createCollection('items');
db.createCollection("items");
db.items.insertOne({
"hostId": "mlt-12345",
"hostName": "AXIELL",
Expand Down Expand Up @@ -43,31 +43,31 @@ db.items.insertOne({
})


db.createCollection('orders')
db.createCollection("orders")
db.orders.insertOne({
"hostName": "AXIELL",
"hostOrderId": "mlt-order-12345",
"status": "NOT_STARTED",
"orderLine": [
"hostName": "AXIELL",
"hostOrderId": "mlt-12345-order",
"status": "NOT_STARTED",
"orderLine": [
{
"hostId": "item-12345",
"status": "NOT_STARTED"
"hostId": "mlt-12345",
"status": "NOT_STARTED"
}
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "MLT Team",
"address": {
"recipient": "Doug Doug",
"addressLine1": "Somewhere",
"addressLine2": "Behind a cardboard box",
"city": "Las Vegas",
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
"addressLine1": "Dimmsdale Dimmadome",
"addressLine2": "21st Texan Ave.",
"city": "Dimmsdale",
"country": "United States",
"region": "Texas",
"postcode": "TX-55415"
},
"callbackUrl": "https://callback-wls.no/order",
"region": "California",
"postcode": "CA-55415"
},
"callbackUrl": "https://callback-wls.no/order",
"_class": "no.nb.mlt.wls.infrastructure.repositories.order.MongoOrder"
})

print('END ####################################################################');
print("END ####################################################################");
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import org.apache.commons.validator.routines.UrlValidator
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "Hermes the Great",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Nasjonalbibliotekaren",
"addressLine1": "Henrik Ibsens gate 110",
"city": "Oslo",
"country": "Norway",
"postcode": "0255"
"recipient": "Doug Dimmadome",
"addressLine1": "Dimmsdale Dimmadome",
"addressLine2": "21st Texan Ave.",
"city": "Dimmsdale",
"country": "United States",
"region": "California",
"postcode": "CA-55415"
},
"note": "Handle with care",
"callbackUrl": "https://callback-wls.no/order"
Expand Down Expand Up @@ -70,29 +72,20 @@ data class ApiOrderPayload(
)
val orderType: Order.Type,
@Schema(
description = "The name of the person to contact with manners related to this order",
example = "Hermes"
description = """Who to contact in relation to the order if case of any problems/issues/questions.""",
example = "Dr. Heinz Doofenshmirtz"
)
val contactPerson: String,
@Schema(
description = "Any notes about the order",
example = "This is required in four weeks time"
description = """Address for the order, used in cases where storage operator sends out the order directly.""",
example = "{...}"
)
val note: String?,
// TODO - Should this use custom DTO?
val address: Order.Address?,
@Schema(
description = "The delivery address of this order",
example = """
"address": {
"recipient": "Nasjonalbibliotekaren",
"addressLine1": "Henrik Ibsens gate 110",
"city": "Oslo",
"country": "Norway",
"postcode": "0255"
}
"""
description = """Notes regarding the order, such as delivery instructions, special requests, etc.""",
example = "I need this order in four weeks, not right now."
)
val address: Order.Address?,
val note: String?,
@Schema(
description = """Callback URL to use for sending order updates in the host system.
For example when order items get picked or the order is cancelled.""",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import kotlin.jvm.Throws
}
],
"orderType": "LOAN",
"contactPerson": "MLT Team",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
"addressLine1": "Dimmsdale Dimmadome",
Expand All @@ -32,7 +32,7 @@ import kotlin.jvm.Throws
"postcode": "CA-55415"
},
"note": "Handle with care",
"callbackUrl": "https://example.com/send/callback/here"
"callbackUrl": "https://callback-wls.no/order"
}
"""
)
Expand All @@ -58,34 +58,23 @@ data class ApiUpdateOrderPayload(
)
val orderType: Order.Type,
@Schema(
description = """Who's the receiver of the material in the order.""",
example = "{...}"
description = """Who to contact in relation to the order if case of any problems/issues/questions.""",
example = "Dr. Heinz Doofenshmirtz"
)
val contactPerson: String,
@Schema(
description = """
The delivery address of the order.
If delivering to a country with states (I.E. the United States), include the state name in the region.
""",
example = """
"address": {
"recipient": "Nasjonalbibliotekaren",
"addressLine1": "Henrik Ibsens gate 110",
"city": "Oslo",
"country": "Norway",
"postcode": "0255"
}
"""
description = """Address for the order, used in cases where storage operator sends out the order directly.""",
example = "{...}"
)
val address: Order.Address?,
@Schema(
description = "Any notes about the order",
example = "This is required in four weeks time"
description = """Notes regarding the order, such as delivery instructions, special requests, etc.""",
example = "I need this order in four weeks, not right now."
)
val note: String?,
@Schema(
description = """URL to send a callback to when the order is completed.""",
example = "https://example.com/send/callback/here"
example = "https://callback-wls.no/order"
)
val callbackUrl: String
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ data class Product(
@NotBlank
val productOwner: String,
@Schema(
description = """Product version ID in the storage system, seems to always have value 'Default'.""",
description = """Product version ID in the storage system, seems to always have value "Default".""",
example = "Default"
)
val productVersionId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ data class OrderLine(
)
val productId: String,
@Schema(
description = """Product version ID in the storage system, seems to always have value 'Default'.""",
description = """Product version ID in the storage system, seems to always have value "Default".""",
example = "Default"
)
val productVersionId: String,
Expand Down Expand Up @@ -193,7 +193,7 @@ data class OrderLine(
}

if (quantity < 0) {
throw ValidationException("Order Line's quantity for the product $productId must be positive")
throw ValidationException("Order Line's quantity for the product '$productId' must be positive")
}

if (attributeValue.isNotEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/no/nb/mlt/wls/domain/model/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class Item(
if (amountPicked > itemsInStockQuantity) {
logger.error {
"Tried to pick too many items for item with id '$hostId'. " +
"WLS DB has $itemsInStockQuantity stocked, and storage system tried to pick $amountPicked"
"WLS DB has '$itemsInStockQuantity' stocked, and storage system tried to pick '$amountPicked'"
}
}
val quantity = Math.clamp(itemsInStockQuantity.minus(amountPicked).toLong(), 0, Int.MAX_VALUE)
Expand All @@ -37,7 +37,7 @@ data class Item(
} else {
// Rare edge case. Log it until we can determine if this actually happens in production
logger.error {
"Item with ID $hostId for host $hostName without a location was picked. Location was set to \"UNKNOWN\"."
"Item with ID '$hostId' for host '$hostName' without a location was picked. Location was set to 'UNKNOWN'."
}
"UNKNOWN"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import no.nb.mlt.wls.domain.model.Owner
],
"orderType": "LOAN",
"owner": "NB",
"contactPerson": "MLT Team",
"contactPerson": "Dr. Heinz Doofenshmirtz",
"address": {
"recipient": "Doug Dimmadome",
"addressLine1": "Dimmsdale Dimmadome",
Expand Down Expand Up @@ -72,24 +72,24 @@ data class NotificationOrderPayload(
)
val owner: Owner?,
@Schema(
description = "The person to contact regarding matters about the order",
example = "Hermes the Great"
description = """Who to contact in relation to the order if case of any problems/issues/questions.""",
example = "Dr. Heinz Doofenshmirtz"
)
val contactPerson: String,
@Schema(
description = "The address of the receiver of the material in the order.",
description = """Address for the order, used in cases where storage operator sends out the order directly.""",
example = "{...}"
)
val address: Order.Address?,
@Schema(
description = "Any notes about the order",
example = "This is required in four weeks time"
description = """Notes regarding the order, such as delivery instructions, special requests, etc.""",
example = "I need this order in four weeks, not right now."
)
val note: String?,
@Schema(
description = """Callback URL to use for sending order updates in the host system.
For example when order items get picked or the order is cancelled.""",
example = "https://example.com/send/callback/here"
example = "https://callback-wls.no/order"
)
val callbackUrl: String
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ data class ShippingAddress(
val address: Address
) {
data class Address(
// SynQ does not have a field where we can put owner/contact person for the order, as such this field will be used for order's contact person
val contactPerson: String,
// This will contain address.recipient, as contactPerson is used for something else, explained above ^
@JsonInclude(JsonInclude.Include.NON_NULL)
val addressLine1: String? = null,
// This will contain address.addressLine1, as ...
@JsonInclude(JsonInclude.Include.NON_NULL)
val addressLine2: String? = null,
// ...addressLine2...
@JsonInclude(JsonInclude.Include.NON_NULL)
val addressLine3: String? = null,
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand Down
Loading

0 comments on commit 8d96858

Please sign in to comment.