Skip to content
Closed
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
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<version>3.3.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -23,11 +23,11 @@

<!-- DEPENDENCIES VERSION -->
<jdk.version>21</jdk.version>
<cds.services.version>3.4.1</cds.services.version>
<cds.services.version>3.5.0</cds.services.version>
<cloud.sdk.version>5.13.0</cloud.sdk.version>
<xsuaa.version>3.5.3</xsuaa.version>
<cf-java-logging-support.version>3.8.4</cf-java-logging-support.version>
<cds.cdsdk-version>8.4.2</cds.cdsdk-version>
<cds.cdsdk-version>8.5.0</cds.cdsdk-version>
</properties>

<modules>
Expand Down
6 changes: 6 additions & 0 deletions srv/admin-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ annotate AdminService.Books with @cds.search : {
title
};

annotate AdminService.OrderItems with {
@mandatory
@assert.range: [(0), _]
quantity
};

// Enable Fiori Draft for Orders
annotate AdminService.Orders with @odata.draft.enabled;
annotate AdminService.Books with @odata.draft.enabled;
Expand Down
1 change: 0 additions & 1 deletion srv/src/main/java/my/bookshop/MessageKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

public class MessageKeys {

public static final String QUANTITY_REQUIRE_MINIMUM = "quantity.require.minimum";
public static final String BOOK_REQUIRE_STOCK = "book.require.stock";
public static final String BOOK_ADDED_ORDER = "book.added.order";
public static final String BOOK_MISSING = "book.missing";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ public void beforeCreateOrder(Stream<Orders> orders, EventContext context) {
order.getItems().forEach(orderItem -> {
// validation of the Order creation request
Integer quantity = orderItem.getQuantity();
if (quantity == null || quantity <= 0) {
// errors with localized messages from property files
// exceptions abort the request and set an error http status code
// messages in contrast allow to collect multiple errors
messages.error(MessageKeys.QUANTITY_REQUIRE_MINIMUM)
.target("in", ORDERS, o -> o.Items(i -> i.ID().eq(orderItem.getId()).and(i.IsActiveEntity().eq(orderItem.getIsActiveEntity()))).quantity());
}

String bookId = orderItem.getBookId();

if(quantity == null || quantity <= 0 || bookId == null) {
Expand Down
1 change: 0 additions & 1 deletion srv/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quantity.require.minimum = The specified quantity is smaller than 1
book.require.stock = Not enough books on stock (only {0} left)
book.added.order = Book successfully added to order
book.missing = Book does not exist
Expand Down
1 change: 0 additions & 1 deletion srv/src/main/resources/messages_de.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quantity.require.minimum = Die eingetragene Anzahl ist kleiner als 1
book.require.stock = Nicht genügend Bücher auf Vorrat (nur {0} übrig)
book.added.order = Das Buch wurde der Bestellung erfolgreich hinzugefügt
book.missing = Das Buch existiert nicht
Expand Down
Loading