Skip to content

Commit

Permalink
Demonstrate cds-feature-attachments with bookshop (#377)
Browse files Browse the repository at this point in the history
This PR demonstrates the usage of the cds-feature-attachments in the
bookshop.
  • Loading branch information
mofterdinger authored Dec 2, 2024
1 parent 4d570bb commit 0052e95
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Welcome to the bookshop-java project. It demonstrates how to build business appl
- [Demonstrated Features](#demonstrated-features)
- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Clone Build & Run](#clone-build--run)
- [Clone Build & Run](#clone-build-run)
- [Using VS Code](#using-vs-code)
- [Using Eclipse](#using-eclipse)
- [Building and Running](#building-and-running)
Expand Down
9 changes: 9 additions & 0 deletions app/_i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ModifiedBy = Modified By
General = General
Details = Details
Admin = Administrative
Translations = Translations

ID = ID
Currency = Currency
Expand Down Expand Up @@ -68,3 +69,11 @@ AddReview = Add Review
Notes = Notes
Note = Note
ISBN = ISBN
attachment_content = Content
attachment_mimeType = MIME Type
attachment_fileName = File Name
attachment_status = Status
attachment_note = Note
attachment = Cover
attachments = Covers
9 changes: 9 additions & 0 deletions app/_i18n/i18n_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ModifiedBy = Bearbeitet von
General = Generelles
Details = Details
Admin = Administratives
Translations = Übersetzungen

ID = ID
Currency = W\u00E4hrung
Expand Down Expand Up @@ -68,3 +69,11 @@ AddReview = Rezension hinzufügen
Notes = Notizen
Note = Notiz
ISBN = ISBN

attachment_content = Inhalt
attachment_mimeType = MIME-Typ
attachment_fileName = Dateiname
attachment_status = Status
attachment_note = Notiz
attachment = Buchcover
attachments = Buchcovers
10 changes: 9 additions & 1 deletion app/admin/fiori-service.cds
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ annotate AdminService.Books with @(UI : {
Label : '{i18n>Details}',
Target : '@UI.FieldGroup#Details'
},
{
$Type : 'UI.ReferenceFacet',
ID : 'AttachmentsFacet',
Target : 'covers/@UI.LineItem'
},
{
$Type : 'UI.ReferenceFacet',
Label : '{i18n>Admin}',
Target : '@UI.FieldGroup#Admin'
},
}
],
FieldGroup #General : {Data : [
{Value : title},
Expand Down Expand Up @@ -131,3 +136,6 @@ annotate AdminService.Books actions {
quantity @title : '{i18n>Quantity}'
)
}

// Hides technical field up__ID in View Setitings dialog for Books.covers
annotate AdminService.Books.covers:up_ with @UI.Hidden;
4 changes: 2 additions & 2 deletions app/fiori.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
};
</script>

<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/1.129.0/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.129.0/resources/sap-ui-core.js"
<script id="sap-ushell-bootstrap" src="https://sapui5.hana.ondemand.com/1.131.0/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
<script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/1.131.0/resources/sap-ui-core.js"
data-sap-ui-libs="sap.m, sap.ushell, sap.collaboration, sap.ui.layout"
data-sap-ui-compatVersion="edge"
data-sap-ui-theme="sap_horizon"
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<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-feature-attachments.version>1.0.5</cds-feature-attachments.version>
</properties>

<modules>
Expand Down
8 changes: 7 additions & 1 deletion srv/admin-service.cds
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using {sap.common.Languages as CommonLanguages} from '@sap/cds/common';
using {my.bookshop as my} from '../db/index';
using {sap.changelog as changelog} from 'com.sap.cds/change-tracking';
using {sap.attachments.Attachments} from `com.sap.cds/cds-feature-attachments`;

extend my.Orders with changelog.changeTracked;

Expand Down Expand Up @@ -62,4 +63,9 @@ annotate AdminService.Orders with @changelog: [OrderNo];
annotate AdminService.OrderItems with @changelog: [
parent.OrderNo,
book.title,
];
];

// Extends the Books entity with the Attachments composition
extend my.Books with {
covers : Composition of many Attachments;
};
7 changes: 7 additions & 0 deletions srv/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>com.sap.cds</groupId>
<artifactId>cds-feature-attachments</artifactId>
<version>${cds-feature-attachments.version}</version>
<scope>runtime</scope>
</dependency>

<!-- CLOUD SDK dependencies -->
<dependency>
<groupId>com.sap.cloud.sdk.cloudplatform</groupId>
Expand Down

0 comments on commit 0052e95

Please sign in to comment.