Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.
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
5 changes: 5 additions & 0 deletions app/_i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ Order = Order
Orders = Orders
Price = Price
Reviews = Reviews
ReviewText = Review Text
Rating = Rating
Pages = Pages
ISBN = ISBN
Publication = Publication
33 changes: 33 additions & 0 deletions app/admin-books/fiori-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ annotate AdminService.Books with @(UI: {
Label : '{i18n>Admin}',
Target: '@UI.FieldGroup#Admin'
},
// hint: add Publication section to Manage Books app's page view
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Publication}',
Target: '@UI.FieldGroup#Publication'
}
],
FieldGroup #General: {Data: [
{Value: title},
Expand All @@ -59,9 +65,28 @@ annotate AdminService.Books with @(UI: {
{Value: createdAt},
{Value: modifiedBy},
{Value: modifiedAt}
]},
// hint: adds Pages and ISBN display to the Publication section
FieldGroup #Publication: {Data: [
{Value: pages, Label:'{i18n>Pages}'},
{Value: isbn, Label:'{i18n>ISBN}'}
]}
});

// hint: define data that is displayed in the list display's extended row mode
annotate AdminService.Books with @(UI: {
SelectionFields: [ title, author_ID, isbn ],
LineItem: [
{ Value:title, Label:'{i18n>Title}' },
{ Value:author.name, Label:'{i18n>Author}' },
{ Value:genre.name, Label:'{i18n>Genre}' },
{ Value:pages, Label:'{i18n>Pages}' }, // hint: display Pages
{ Value:isbn, Label:'{i18n>ISBN}' }, // hint: display ISBN
{ Value:price, Label:'{i18n>Price}' },
{ Value:currency.symbol, Label:'{i18n>Currency}' },
{ Value:stock, Label:'{i18n>Stock}' }
]
});

////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -123,3 +148,11 @@ annotate AdminService.Books with {
annotate AdminService.Books with {
genre @Common.ValueListWithFixedValues;
}

// hint: this was needed to make the path not found at 'reviews/@UI.LineItem' go away
annotate AdminService.Reviews with @(UI: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great thx

LineItem: [
{ Value: text, Label: '{i18n>ReviewText}' },
{ Value: rating, Label: '{i18n>Rating}' }
]
});
63 changes: 50 additions & 13 deletions app/browse/fiori-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,27 @@ annotate CatalogService.Books with @(UI : {
Label : '{i18n>Description}',
Target: '@UI.FieldGroup#Descr'
}, ],
Facets: [{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Details}',
Target: '@UI.FieldGroup#Price'
Facets: [{
$Type: 'UI.ReferenceFacet',
Label: '{i18n>Description}',
Target: '@UI.FieldGroup#Descr'
},
{
$Type: 'UI.ReferenceFacet',
Label: '{i18n>Details}',
Target: '@UI.FieldGroup#Price'
},
{
$Type: 'UI.ReferenceFacet',
Label: '{i18n>Publication}',
Target: '@UI.FieldGroup#Publication'
},

// hint: new facet -> navigates to the reviews entity of this book
{
$Type: 'UI.ReferenceFacet',
Label: '{i18n>Reviews}',
Target: 'reviews/@UI.LineItem'
}, ],
FieldGroup #Descr: {Data : [{Value : descr}, ]},
FieldGroup #Price: {Data : [
Expand All @@ -29,6 +46,12 @@ annotate CatalogService.Books with @(UI : {
Label: '{i18n>Currency}'
},
]},

// hint: shows pages & isbn on the object page
FieldGroup #Publication: { Data: [
{ Value: pages, Label: '{i18n>Pages}' },
{ Value: isbn, Label: '{i18n>ISBN}' }
]}
});

////////////////////////////////////////////////////////////////////////////
Expand All @@ -39,19 +62,33 @@ annotate CatalogService.Books with @(UI : {
SelectionFields: [
ID,
price,
currency_code
currency_code,
// hint: adds isbn search field
isbn
],
LineItem: [
{
Value: ID,
Label: '{i18n>Title}'
{
Value: ID,
Label: '{i18n>Title}'
},
{
{
Value: author,
Label: '{i18n>Author}'
Label: '{i18n>Author}'
},
{Value: genre.name},
{Value: price},
{Value: currency.symbol},
{ Value: genre.name },
{ Value: price },
// hint: adds Pages
{ Value: pages, Label: '{i18n>Pages}' },
// hint: adds ISBN
{ Value: isbn, Label: '{i18n>ISBN}' }
]
});

// hint: adding this removes the `Path does not exist.CDS (annotations)` error
annotate CatalogService.Reviews with @(UI: {
LineItem: [
{ Value: rating, Label: '{i18n>Rating}' },
{ Value: text, Label: '{i18n>Review}' },
{ Value: createdAt, Label: '{i18n>Date}' }
]
});
2 changes: 2 additions & 0 deletions app/common.cds
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ annotate my.Books with {
stock @title: '{i18n>Stock}';
descr @title: '{i18n>Description}' @UI.MultiLineText;
image @title: '{i18n>Image}';
// hint: labels the search field with value from i18n
isbn @title: '{i18n>ISBN}';
}

////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 6 additions & 6 deletions db/data/sap.capire.bookshop-Books.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ID,title,descr,author_ID,stock,price,currency_code,genre_ID
201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11
207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11
251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16
252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,16
271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13
ID,title,descr,author_ID,stock,price,currency_code,genre_ID,pages,isbn
201,Wuthering Heights,"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.",101,12,11.11,GBP,11,416,9780141439556
207,Jane Eyre,"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.",107,11,12.34,GBP,11,532,9780141441146
251,The Raven,"""The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.",150,333,13.13,USD,16,64,9780142437778
252,Eleonora,"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.",150,555,14,USD,16,48,9781503274010
271,Catweazle,"Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.",170,22,150,JPY,13,288,9780330026625
5 changes: 4 additions & 1 deletion db/schema.cds
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ entity Books : managed {
price : Decimal;
currency : Currency;
image : LargeBinary @Core.MediaType: 'image/png';
reviews : Association to many Reviews
reviews : Association to many Reviews
on reviews.book = $self;

pages : Integer @assert.range: [(0),_]; // hint: adds validation, must be > 0
isbn : String(20) @assert.format: '^(?=(?:\D*\d){10}(?:(?:\D*\d){3})?$)[\d-]+$'; // hint: https://stackoverflow.com/questions/41271613/use-regex-to-verify-an-isbn-number
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, does this work when you try to edit an isbn in the books-admin? does it lead to errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you input an invalid ISBN value it prevents you from saving changes to the entity. I have not tested it more extensively as in what happens when wrong data is seeded and such.

}

entity Reviews : managed {
Expand Down
8 changes: 7 additions & 1 deletion srv/cat-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ service CatalogService {

/** For display in details pages */
@readonly entity Books as projection on my.Books { *,
author.name as author
author.name as author,
reviews
} excluding { createdBy, modifiedBy };

entity Reviews as projection on my.Reviews {
*,
book
};

@requires: 'authenticated-user'
action submitOrder (
book : Books:ID @mandatory,
Expand Down