Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/travels/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</style>
<script
id="sap-ui-bootstrap"
src="https://ui5.sap.com/1.136.8/resources/sap-ui-core.js"
src="https://ui5.sap.com/1.136.12/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-resourceroots='{ "sap.capire.travels": "." }'
Expand Down
23 changes: 0 additions & 23 deletions db/constraints.cds

This file was deleted.

2 changes: 1 addition & 1 deletion db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using {


entity Travels : managed {
key ID : Integer default 0 @readonly;
key ID : Integer default 0;
Description : String(1024);
BeginDate : Date default $now;
EndDate : Date default $now;
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<!-- DEPENDENCIES VERSION -->
<jdk.version>21</jdk.version>
<cds.services.version>4.5.1</cds.services.version>
<cds.services.version>4.6.0</cds.services.version>
<spring.boot.version>3.5.8</spring.boot.version>
<sap.cloud.sdk.version>5.24.0</sap.cloud.sdk.version>

Expand Down Expand Up @@ -169,4 +169,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
6 changes: 6 additions & 0 deletions srv/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ASSERT_ENDDATE_AFTER_BEGINDATE=End date must be after begin date
ASSERT_BOOKINGS_IN_TRAVEL_PERIOD=All bookings must be within the travel period
ASSERT_BOOKING_CURRENCY_MATCHES_TRAVEL=All bookings must use the same currency as the travel
ASSERT_FLIGHT_PRICE_POSITIVE=Flight price must be a positive value
ASSERT_NO_BOOKINGS_AFTER_TRAVEL=No bookings are allowed after the travel end date
ASSERT_BOOKING_FEE_NON_NEGATIVE=Booking fee cannot be negative
50 changes: 50 additions & 0 deletions srv/travel-constraints.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using { TravelService } from './travel-service';


annotate TravelService.Travels with {

Description @assert: (case
when length(Description) < 3 then 'Description too short'
end);

Customer @assert: (case
when Customer is null then 'Customer must be specified'
when not exists Customer then 'Customer does not exist'
end);

EndDate @assert: (case
when EndDate < BeginDate then error('ASSERT_ENDDATE_AFTER_BEGINDATE', null, (BeginDate, EndDate))
end);

BookingFee @assert: (case
when BookingFee < 0 then 'Booking fee cannot be negative'
end);

};


annotate TravelService.Bookings with {

FlightPrice @assert: (case
when FlightPrice < 0 then 'ASSERT_FLIGHT_PRICE_POSITIVE'
end);

Currency {
code @assert: (case
when $self.Currency.code != $self.Travel.Currency.code then 'ASSERT_BOOKING_CURRENCY_MATCHES_TRAVEL'
end);
}

Flight {
date @assert: (case
when date not between $self.Travel.BeginDate and $self.Travel.EndDate then 'ASSERT_BOOKINGS_IN_TRAVEL_PERIOD'
end);
}

};


annotate TravelService.Travels with @Capabilities.FilterRestrictions.FilterExpressionRestrictions: [
{ Property: 'BeginDate', AllowedExpressions : 'SingleRange' },
{ Property: 'EndDate', AllowedExpressions : 'SingleRange' }
];