This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
service-models.cds
344 lines (292 loc) · 13.8 KB
/
service-models.cds
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
using {sap.samples.authorreadings as armodels} from '../db/entity-models';
using sap from '@sap/cds/common';
// ----------------------------------------------------------------------------
// Service for "author reading managers"
service AuthorReadingManager @(
path : 'authorreadingmanager',
impl : './service-implementation.js'
) {
// ----------------------------------------------------------------------------
// Entity inclusions
// Currencies
entity Currencies as projection on sap.common.Currencies;
// Author readings (combined with remote project using mixin)
@odata.draft.enabled
entity AuthorReadings as select from armodels.AuthorReadings
mixin {
// ByD projects: Mix-in of ByD project data
toByDProject: Association to RemoteByDProject.ProjectCollection on toByDProject.ProjectID = $projection.projectID;
// S4HC projects: Mix-in of S4HC project data
toS4HCProject: Association to RemoteS4HCProject.A_EnterpriseProject on toS4HCProject.Project = $projection.projectID;
// C4P projects: Mix-in of C4P project data
toC4PProject: Association to RemoteC4PProject.Projects on toC4PProject.displayId = $projection.projectID;
}
into {
*,
virtual null as statusCriticality : Integer @title : '{i18n>statusCriticality}',
virtual null as projectSystemName : String @title : '{i18n>projectSystemName}' @odata.Type : 'Edm.String',
// ByD projects: visibility of button "Create project in ByD"
virtual null as createByDProjectEnabled : Boolean @title : '{i18n>createByDProjectEnabled}' @odata.Type : 'Edm.Boolean',
toByDProject,
// S4HC projects: visibility of button "Create project in S4HC", code texts
virtual null as createS4HCProjectEnabled : Boolean @title : '{i18n>createS4HCProjectEnabled}' @odata.Type : 'Edm.Boolean',
toS4HCProject,
virtual null as projectProfileCodeText : String @title : '{i18n>projectProfile}' @odata.Type : 'Edm.String',
virtual null as processingStatusText : String @title : '{i18n>processingStatus}' @odata.Type : 'Edm.String',
// C4P projects: visibility of button "Create project in C4P"
virtual null as createC4PProjectEnabled : Boolean @title : '{i18n>createC4PProjectEnabled}' @odata.Type : 'Edm.Boolean',
toC4PProject,
}
actions {
// Action: Block
@(
Common.SideEffects : {TargetEntities : ['_authorreading']},
cds.odata.bindingparameter.name : '_authorreading'
)
action block() returns AuthorReadings;
// Action: Publish
@(
Common.SideEffects : {TargetEntities : ['_authorreading']},
cds.odata.bindingparameter.name : '_authorreading'
)
action publish() returns AuthorReadings;
// ByD projects: action to create a project in ByD
@(
Common.SideEffects : {TargetEntities: ['_authorreading','_authorreading/toByDProject']},
cds.odata.bindingparameter.name : '_authorreading'
)
action createByDProject() returns AuthorReadings;
// S4HC projects: action to create a project in S4HC
@(
Common.SideEffects : {TargetEntities: ['_authorreading','_authorreading/toS4HCProject']},
cds.odata.bindingparameter.name : '_authorreading'
)
action createS4HCProject() returns AuthorReadings;
// C4P projects: action to create a project in C4P
@(
Common.SideEffects : {TargetEntities: ['_authorreading','_authorreading/toC4PProject']},
cds.odata.bindingparameter.name : '_authorreading'
)
action createC4PProject() returns AuthorReadings;
};
// Participants
entity Participants as projection on armodels.Participants {
*,
virtual null as statusCriticality : Integer @title : '{i18n>statusCriticality}',
} actions {
// Action: Cancel Participation
@(
Common.SideEffects : {TargetEntities : [
'_participant',
'_participant/parent'
]},
cds.odata.bindingparameter.name : '_participant'
)
action cancelParticipation() returns Participants;
// Action: Confirm Participation
@(
Common.SideEffects : {TargetEntities : [
'_participant',
'_participant/parent'
]},
cds.odata.bindingparameter.name : '_participant'
)
action confirmParticipation() returns Participants;
};
// ----------------------------------------------------------------------------
// Function to get user information (example for entity-independend function)
type userRoles {
identified : Boolean;
authenticated : Boolean;
};
type user {
user : String;
locale : String;
roles : userRoles
};
function userInfo() returns user;
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by ByD projects (principal propagation)
using { byd_khproject as RemoteByDProject } from './external/byd_khproject';
extend service AuthorReadingManager with {
entity ByDProjects as projection on RemoteByDProject.ProjectCollection {
key ObjectID as ID,
ProjectID as projectID,
ResponsibleCostCentreID as costCenter,
ProjectTypeCode as typeCode,
ProjectTypeCodeText as typeCodeText,
ProjectLifeCycleStatusCode as statusCode,
ProjectLifeCycleStatusCodeText as statusCodeText,
BlockingStatusCode as blockingStatusCode,
PlannedStartDateTime as startDateTime,
PlannedEndDateTime as endDateTime,
ProjectSummaryTask as summaryTask : redirected to ByDProjectSummaryTasks,
Task as task : redirected to ByDProjectTasks
}
entity ByDProjectSummaryTasks as projection on RemoteByDProject.ProjectSummaryTaskCollection {
key ObjectID as ID,
ParentObjectID as parentID,
ID as taskID,
ProjectName as projectName,
ResponsibleEmployeeID as responsibleEmployee,
ResponsibleEmployeeFormattedName as responsibleEmployeeName
}
entity ByDProjectTasks as projection on RemoteByDProject.TaskCollection {
key ObjectID as ID,
ParentObjectID as parentID,
TaskID as taskID,
TaskName as taskName,
PlannedDuration as duration,
ResponsibleEmployeeID as responsibleEmployee,
ResponsibleEmployeeFormattedName as responsibleEmployeeName
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by ByD projects (technical users)
using { byd_khproject_tech_user as RemoteByDProjectTechUser } from './external/byd_khproject_tech_user';
extend service AuthorReadingManager with {
entity ByDProjectsTechUser as projection on RemoteByDProjectTechUser.ProjectCollection {
key ObjectID as ID,
ProjectID as projectID,
ResponsibleCostCentreID as costCenter,
ProjectTypeCode as typeCode,
ProjectTypeCodeText as typeCodeText,
ProjectLifeCycleStatusCode as statusCode,
ProjectLifeCycleStatusCodeText as statusCodeText,
BlockingStatusCode as blockingStatusCode,
PlannedStartDateTime as startDateTime,
PlannedEndDateTime as endDateTime
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by S4HC projects (principal propagation)
using { S4HC_API_ENTERPRISE_PROJECT_SRV_0002 as RemoteS4HCProject } from './external/S4HC_API_ENTERPRISE_PROJECT_SRV_0002';
extend service AuthorReadingManager with {
entity S4HCProjects as projection on RemoteS4HCProject.A_EnterpriseProject {
key ProjectUUID as ProjectUUID,
ProjectInternalID as ProjectInternalID,
Project as Project,
ProjectDescription as ProjectDescription,
EnterpriseProjectType as EnterpriseProjectType,
ProjectStartDate as ProjectStartDate,
ProjectEndDate as ProjectEndDate,
ProcessingStatus as ProcessingStatus,
ResponsibleCostCenter as ResponsibleCostCenter,
ProfitCenter as ProfitCenter,
ProjectProfileCode as ProjectProfileCode,
CompanyCode as CompanyCode,
ProjectCurrency as ProjectCurrency,
EntProjectIsConfidential as EntProjectIsConfidential,
to_EnterpriseProjectElement as to_EnterpriseProjectElement : redirected to S4HCEnterpriseProjectElement ,
to_EntProjTeamMember as to_EntProjTeamMember : redirected to S4HCEntProjTeamMember
}
entity S4HCEnterpriseProjectElement as projection on RemoteS4HCProject.A_EnterpriseProjectElement {
key ProjectElementUUID as ProjectElementUUID,
ProjectUUID as ProjectUUID,
ProjectElement as ProjectElement,
ProjectElementDescription as ProjectElementDescription,
PlannedStartDate as PlannedStartDate,
PlannedEndDate as PlannedEndDate
}
entity S4HCEntProjTeamMember as projection on RemoteS4HCProject.A_EnterpriseProjectTeamMember {
key TeamMemberUUID as TeamMemberUUID,
ProjectUUID as ProjectUUID,
BusinessPartnerUUID as BusinessPartnerUUID,
to_EntProjEntitlement as to_EntProjEntitlement : redirected to S4HCEntProjEntitlement
}
entity S4HCEntProjEntitlement as projection on RemoteS4HCProject.A_EntTeamMemberEntitlement {
key ProjectEntitlementUUID as ProjectEntitlementUUID,
TeamMemberUUID as TeamMemberUUID,
ProjectRoleType as ProjectRoleType
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by S4HC Projects ProjectProfileCode
using { S4HC_ENTPROJECTPROCESSINGSTATUS_0001 as RemoteS4HCProjectProcessingStatus } from './external/S4HC_ENTPROJECTPROCESSINGSTATUS_0001';
extend service AuthorReadingManager with {
entity S4HCProjectsProcessingStatus as projection on RemoteS4HCProjectProcessingStatus.ProcessingStatus {
key ProcessingStatus as ProcessingStatus,
ProcessingStatusText as ProcessingStatusText
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by S4HC Projects ProcessingStatus
using { S4HC_ENTPROJECTPROFILECODE_0001 as RemoteS4HCProjectProjectProfileCode } from './external/S4HC_ENTPROJECTPROFILECODE_0001';
extend service AuthorReadingManager with {
entity S4HCProjectsProjectProfileCode as projection on RemoteS4HCProjectProjectProfileCode.ProjectProfileCode {
key ProjectProfileCode as ProjectProfileCode,
ProjectProfileCodeText as ProjectProfileCodeText
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by C4P Projects
using { c4p_ProjectService as RemoteC4PProject } from './external/c4p_ProjectService';
extend service AuthorReadingManager with {
entity C4PProject as projection on RemoteC4PProject.Projects {
key id as projectId,
displayId as displayId,
name as projectName,
status as status,
startDate as startDate,
endDate as endDate,
location as locationAdress,
description as description
}
};
// -------------------------------------------------------------------------------
// Extend service AuthorReadingManager by C4P Tasks
using { c4p_TaskService as RemoteC4PTask } from './external/c4p_TaskService';
extend service AuthorReadingManager with {
entity C4PTask as projection on RemoteC4PTask.Tasks {
key id as taskId,
projectId as projectId,
displayId as displayId,
taskType as taskType,
subject as subject,
description as description,
category as category,
startDate as startDate,
dueDate as dueDate,
priority as priority,
effortValue as effortValue,
effortUnit as effortUnit
}
};
// -------------------------------------------------------------------------------
// Annotations for data privacy
annotate AuthorReadingManager.AuthorReadings with @PersonalData : {
DataSubjectRole : 'AuthorReadings',
EntitySemantics : 'DataSubject'
}
{
ID @PersonalData.FieldSemantics : 'DataSubjectID';
identifier @PersonalData.FieldSemantics : 'DataSubjectID';
description @PersonalData.FieldSemantics : 'DataSubjectID';
participantsFeeAmount @PersonalData.IsPotentiallySensitive;
}
annotate AuthorReadingManager.Participants with @PersonalData : {
DataSubjectRole : 'AuthorReadings',
EntitySemantics : 'DataSubjectDetails'
}
{
ID @PersonalData.FieldSemantics : 'DataSubjectID';
identifier @PersonalData.FieldSemantics : 'DataSubjectID';
parent @PersonalData.FieldSemantics : 'DataSubjectID';
name @PersonalData.IsPotentiallyPersonal;
email @PersonalData.IsPotentiallySensitive;
mobileNumber @PersonalData.IsPotentiallySensitive;
}
// Annotations for audit logging
annotate AuthorReadingManager.AuthorReadings with @AuditLog.Operation : {
Read : true,
Insert : true,
Update : true,
Delete : true
};
annotate AuthorReadingManager.Participants with @AuditLog.Operation : {
Read : true,
Insert : true,
Update : true,
Delete : true
};