diff --git a/cds-feature-attachments/src/main/resources/application.yaml b/cds-feature-attachments/src/main/resources/application.yaml new file mode 100644 index 00000000..94c81b5b --- /dev/null +++ b/cds-feature-attachments/src/main/resources/application.yaml @@ -0,0 +1,5 @@ +cds: + data-source: + csv: + paths: + - "./src/main/resources/cds/**" \ No newline at end of file diff --git a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments-annotations.cds b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments-annotations.cds index 5a81448d..2ba8eec3 100644 --- a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments-annotations.cds +++ b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments-annotations.cds @@ -15,20 +15,19 @@ annotate MediaData with @UI.MediaResource: {Stream: content} { Core.IsMediaType ); fileName @(title: '{i18n>attachment_fileName}'); - status @(title: '{i18n>attachment_status}'); + status @(title: '{i18n>attachment_status}', Common.Text : statusNav.name, Common.TextArrangement : #TextOnly); contentId @(UI.Hidden: true); scannedAt @(UI.Hidden: true); } annotate Attachments with @UI: { HeaderInfo: { - $Type : 'UI.HeaderInfoType', TypeName : '{i18n>attachment}', TypeNamePlural: '{i18n>attachments}', }, LineItem : [ {Value: content, @HTML5.CssDefaults: {width: '30%'}}, - {Value: status, @HTML5.CssDefaults: {width: '10%'}}, + {Value: status, Criticality: statusNav.criticality, @HTML5.CssDefaults: {width: '10%'}}, {Value: createdAt, @HTML5.CssDefaults: {width: '20%'}}, {Value: createdBy, @HTML5.CssDefaults: {width: '15%'}}, {Value: note, @HTML5.CssDefaults: {width: '25%'}}, diff --git a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments.cds b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments.cds index 4ca411e3..ecad4f4e 100644 --- a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments.cds +++ b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/attachments.cds @@ -2,10 +2,11 @@ namespace sap.attachments; using { cuid, - managed + managed, + sap.common.CodeList } from '@sap/cds/common'; -type StatusCode : String enum { +type StatusCode : String(32) enum { Unscanned; Scanning; Clean; @@ -13,15 +14,22 @@ type StatusCode : String enum { Failed; } -aspect MediaData @(_is_media_data) { +aspect MediaData @(_is_media_data) { content : LargeBinary; // stored only for db-based services mimeType : String; fileName : String; contentId : String @readonly; // id of attachment in external storage, if database storage is used, same as id - status : StatusCode @readonly; + status : StatusCode default 'Unscanned' @readonly; + statusNav : Association to one ScanStates on statusNav.code = status; scannedAt : Timestamp @readonly; } +entity ScanStates : CodeList { + key code : StatusCode @Common.Text: name @Common.TextArrangement: #TextOnly; + name : localized String(64); + criticality : Integer @UI.Hidden; +} + aspect Attachments : cuid, managed, MediaData { note : String; } diff --git a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates.csv b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates.csv new file mode 100644 index 00000000..0ed93f0f --- /dev/null +++ b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates.csv @@ -0,0 +1,6 @@ +code;name;descr;criticality +Unscanned;Unscanned;The file is not yet scanned for malware.;2 +Scanning;Scanning;The file is currently being scanned for malware.;2 +Infected;Infected;The file contains malware! Do not download!;1 +Clean;Clean;The file does not contain any malware.;3 +Failed;Failed;The file could not be scanned for malware.;1 \ No newline at end of file diff --git a/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates_texts.csv b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates_texts.csv new file mode 100644 index 00000000..cf261a67 --- /dev/null +++ b/cds-feature-attachments/src/main/resources/cds/com.sap.cds/cds-feature-attachments/data/sap.attachments-ScanStates_texts.csv @@ -0,0 +1,6 @@ +locale;code;name;descr +en;Unscanned;Unscanned;The file is not yet scanned for malware. +en;Scanning;Scanning;The file is currently being scanned for malware. +en;Infected;Infected;The file contains malware! Do not download! +en;Clean;Clean;The file does not contain any malware. +en;Failed;Failed;The file could not be scanned for malware. \ No newline at end of file diff --git a/translation_v2.json b/translation_v2.json index f7068f92..734285f4 100644 --- a/translation_v2.json +++ b/translation_v2.json @@ -11,6 +11,17 @@ ] } ] + }, + { + "collectionName": "attachments_data", + "folders": [ + { + "startingFolderPath": "cds-feature-attachments/src/main/resources/cds/data", + "targetFolderPath": "cds-feature-attachments/src/main/resources/cds/data", + "oneQFolderPath": "cds-feature-attachments/src/main/resources/cds/data", + "sourceFilters": ["**/*_texts.csv"] + } + ] } ], "defaultConfiguration": {