You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Disable Association to Changes Generation](#disable-association-to-changes-generation)
30
30
-[Modelling Samples](#modelling-samples)
31
31
-[Specify Object ID](#specify-object-id)
32
32
-[Tracing Changes](#tracing-changes)
@@ -35,8 +35,6 @@ The `@cap-js/change-tracking` package is a [CDS plugin](https://cap.cloud.sap/do
35
35
-[Code of Conduct](#code-of-conduct)
36
36
-[Licensing](#licensing)
37
37
38
-
39
-
40
38
## Preliminaries
41
39
42
40
In this guide, we use the [Incidents Management reference sample app](https://github.com/cap-js/incidents-app) as the base to add change tracking to. Clone the repository and apply the step-by-step instructions:
@@ -59,8 +57,6 @@ npm i
59
57
cds w samples/change-tracking
60
58
```
61
59
62
-
63
-
64
60
## Setup
65
61
66
62
To enable change tracking, simply add this self-configuring plugin package to your project:
@@ -69,8 +65,6 @@ To enable change tracking, simply add this self-configuring plugin package to yo
69
65
npm add @cap-js/change-tracking
70
66
```
71
67
72
-
73
-
74
68
## Annotations
75
69
76
70
> [!WARNING]
@@ -96,7 +90,6 @@ The minimal annotation we require for change tracking is `@changelog` on element
96
90
97
91
Additional identifiers or labels can be added to obtain more *human-readable* change records as described below.
98
92
99
-
100
93
### Human-readable Types and Fields
101
94
102
95
By default the implementation looks up *Object Type* names or *Field* namesfrom respective `@title` or `@Common.Label` annotations, and applies i18n lookups. If no such annotations are given, the technical names of the respective CDS definitions are displayed.
@@ -115,7 +108,6 @@ We get a human-readable display for *Object Type*:
Expanding the changelog annotation by additional identifiers `[author, timestamp]`, we can now better identify the `message` change events by their respective author and timestamp.
140
134
141
-
142
135
### Human-readable Values
143
136
144
137
The changelog annotations for *New Value* and *Old Value* are defined at element level.
@@ -148,28 +141,29 @@ They are already human-readable by default, unless the `@changelog` definition c
148
141
For example, having a `@changelog` annotation without any additional identifiers, changes to incident customer would show up as UUIDs:
With the steps above, we have successfully set up change tracking for our reference application. Let's see that in action.
168
160
169
161
1.**Start the server**:
170
-
```sh
171
-
cds watch
172
-
```
162
+
163
+
```sh
164
+
cds watch
165
+
```
166
+
173
167
2.**Make a change** on your change-tracked elements. This change will automatically be persisted in the database table (`sap.changelog.ChangeLog`) and made available in a pre-defined view, namely the [Change History view](#change-history-view) for your convenience.
The system now uses the SAPUI5 default setting `![@UI.PartOfPreview]: true`, such that the table will always shown when navigating to that respective Object page.
229
222
230
-
### Disable UI Facet completely
223
+
### Disable UI Facet generation
231
224
232
225
If you do not want the UI facet added to a specific UI, you can annotate the service entity with `@changelog.disable_facet`. This will disable the automatic addition of the UI faced to this specific entity, but also all views or further projections up the chain.
233
226
227
+
### Disable Association to Changes Generation
228
+
229
+
For some scenarios, e.g. when doing `UNION` and the `@changelog` annotion is still propageted, the automatic addition of the association to `changes` does not make sense. You can use `@changelog.disable_assoc`for this to be disabled on entity level.
230
+
231
+
> [!IMPORTANT]
232
+
> This will also supress the addition of the UI facet, since the change-view is not available as target entity anymore.
incidents : Association to many Incidents on incidents.customer = $self;
522
504
}
523
-
524
505
```
525
506
526
507
The reason is that: the relationship: `Association to many` is only for modelling purpose and there is no concrete field in database table. In the above sample, there is no column for incidents in the table Customers, but there is a navigation property of incidents in Customers OData entity metadata.
@@ -535,7 +516,6 @@ entity AggregatedBusinessTransactionData @(cds.autoexpose) : cuid {
535
516
and FootprintInventory.FootprintInventoryScope.ID = FootprintInventoryScope.ID;
536
517
...
537
518
}
538
-
539
519
```
540
520
541
521
The reason is that: When deploying to relational databases, Associations are mapped to foreign keys. Yet, when mapped to non-relational databases they're just references. More details could be found in [Prefer Managed Associations](https://cap.cloud.sap/docs/guides/domain-models#managed-associations). In the above sample, there is no column for FootprintInventory in the table AggregatedBusinessTransactionData, but there is a navigation property FootprintInventoryof in OData entity metadata.
The reason is that: Application level services are by design the only place where business logic is enforced. This by extension means, that it also is the only point where e.g. change-tracking would be enabled. The underlying method used to do change tracking is `req.diff` which is responsible to read the necessary before-image from the database, and this method is not available on DB level.
556
535
557
-
558
536
## Contributing
559
537
560
538
This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/change-tracking/issues). Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
561
539
562
-
563
540
## Code of Conduct
564
541
565
542
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
566
543
567
-
568
544
## Licensing
569
545
570
546
Copyright 2023 SAP SE or an SAP affiliate company and contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cap-js/change-tracking).
0 commit comments