Skip to content

Commit 6f8baa5

Browse files
committed
Add entity PrintQueue, extend receptionist odata service #25
1 parent 8ce51ed commit 6f8baa5

File tree

3 files changed

+100
-5
lines changed

3 files changed

+100
-5
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
--
2+
-- Copyright 2016 SAP Mentors
3+
--
4+
-- Licensed under the Apache License, Version 2.0 (the "License");
5+
-- you may not use this file except in compliance with the License.
6+
-- You may obtain a copy of the License at
7+
--
8+
-- http://www.apache.org/licenses/LICENSE-2.0
9+
--
10+
-- Unless required by applicable law or agreed to in writing, software
11+
-- distributed under the License is distributed on an "AS IS" BASIS,
12+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
-- See the License for the specific language governing permissions and
14+
-- limitations under the License.
15+
--
16+
PROCEDURE "SITREG"."com.sap.sapmentors.sitreg.odatareceptionist.procedures::PrintQueueUpdate" (
17+
IN inrow "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.PrintQueue",
18+
IN oldrow "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.PrintQueue",
19+
OUT error "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.error"
20+
)
21+
LANGUAGE SQLSCRIPT
22+
SQL SECURITY DEFINER
23+
DEFAULT SCHEMA SITREG
24+
AS
25+
BEGIN
26+
27+
DECLARE lv_Count INT;
28+
29+
DECLARE lv_ParticipantID STRING;
30+
DECLARE lv_EventID STRING;
31+
DECLARE lv_FirstName STRING;
32+
DECLARE lv_LastName STRING;
33+
DECLARE lv_Twitter STRING;
34+
DECLARE lv_PrintStatus STRING; -- Q = queued, S = sent, P = printed
35+
DECLARE lv_CreatedBy STRING;
36+
DECLARE lv_CreatedAt STRING;
37+
DECLARE lv_ChangedBy STRING;
38+
DECLARE lv_ChangedAt STRING;
39+
40+
DECLARE lv_PrintStatus_tmp STRING;
41+
42+
DECLARE lv_msg STRING;
43+
44+
SELECT * INTO lv_ParticipantID
45+
, lv_EventID
46+
, lv_FirstName
47+
, lv_LastName
48+
, lv_Twitter
49+
, lv_PrintStatus
50+
, lv_CreatedBy
51+
, lv_CreatedAt
52+
, lv_ChangedBy
53+
, lv_ChangedAt
54+
FROM :inrow;
55+
56+
SELECT "PrintStatus"
57+
INTO lv_PrintStatus_tmp
58+
FROM "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue"
59+
WHERE "ParticipantID" = lv_ParticipantID;
60+
61+
IF lv_PrintStatus_tmp <> '' THEN
62+
IF lv_PrintStatus_tmp = 'S' THEN
63+
IF lv_PrintStatus = 'P' THEN
64+
UPDATE "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue"
65+
SET "PrintStatus" = lv_PrintStatus
66+
, "History.ChangedBy" = CURRENT_USER
67+
, "History.ChangedAt" = CURRENT_TIMESTAMP
68+
WHERE "ParticipantID" = lv_ParticipantID;
69+
ELSE
70+
error = select 400 as http_status_code,
71+
'Update failed' error_message,
72+
'Status can only be set to printed' detail from dummy;
73+
END IF;
74+
ELSE
75+
error = select 400 as http_status_code,
76+
'Update failed' error_message,
77+
'Entry is not is status sent' detail from dummy;
78+
END IF;
79+
ELSE
80+
error = select 400 as http_status_code,
81+
'Update failed' error_message,
82+
'Entry does not exist' detail from dummy;
83+
END IF;
84+
END

odatareceptionist/service.xsodata

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ service {
2020
"com.sap.sapmentors.sitreg.odataparticipant.procedures::EventsRead" as "Events" key ("ID")
2121
navigates ("Event_Ticket" as "Tickets",
2222
"Event_Participants" as "Participants",
23-
"Event_RegistrationNumbers" as "RegistrationNumbers")
23+
"Event_RegistrationNumbers" as "RegistrationNumbers",
24+
"Event_PrintQueue" as "PrintQueue")
2425
create forbidden
2526
update forbidden
2627
delete forbidden;
@@ -32,12 +33,18 @@ service {
3233
update forbidden
3334
delete forbidden;
3435

36+
association "Event_Participants" principal "Events"("ID") multiplicity "1"
37+
dependent "Participants"("EventID") multiplicity "*";
38+
3539
// Read RegistrationNumbers from View to restrict fields that can be read
3640
"com.sap.sapmentors.sitreg.odataparticipant.procedures::RegistrationNumbersRead" as "RegistrationNumbers" key ("EventID")
3741
create forbidden
3842
update forbidden
3943
delete forbidden;
4044

45+
association "Event_RegistrationNumbers" principal "Events"("ID") multiplicity "1"
46+
dependent "RegistrationNumbers"("EventID") multiplicity "1";
47+
4148
// Read Ticket from View to restrict fields that can be read
4249
"com.sap.sapmentors.sitreg.odatareceptionist.procedures::TicketRead" as "Ticket" key ("ParticipantID")
4350
create forbidden
@@ -46,10 +53,13 @@ service {
4653

4754
association "Event_Ticket" principal "Events"("ID") multiplicity "1"
4855
dependent "Ticket"("EventID") multiplicity "*";
49-
association "Event_Participants" principal "Events"("ID") multiplicity "1"
50-
dependent "Participants"("EventID") multiplicity "*";
51-
association "Event_RegistrationNumbers" principal "Events"("ID") multiplicity "1"
52-
dependent "RegistrationNumbers"("EventID") multiplicity "1";
5356
association "Participant_Ticket" principal "Participants"("ID") multiplicity "1"
5457
dependent "Ticket"("ParticipantID") multiplicity "1";
58+
// Read PrintQueue
59+
"com.sap.sapmentors.sitreg.data::SITreg.PrintQueue" as "PrintQueue"
60+
create forbidden
61+
update using "com.sap.sapmentors.sitreg.odatareceptionist.procedures::PrintQueueUpdate"
62+
delete forbidden;
63+
association "Event_PrintQueue" principal "Events"("ID") multiplicity "1"
64+
dependent "PrintQueue"("EventID") multiplicity "*";
5565
}

roles/receptionist.hdbrole

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ role com.sap.sapmentors.sitreg.roles::receptionist {
66
sql object com.sap.sapmentors.sitreg.odatareceptionist.procedures::TicketRead: SELECT;
77
sql object com.sap.sapmentors.sitreg.odatareceptionist.procedures::TicketCheck: EXECUTE;
88
sql object com.sap.sapmentors.sitreg.odatareceptionist.procedures::TicketUpdate: EXECUTE;
9+
sql object com.sap.sapmentors.sitreg.data::SITreg.PrintQueue: SELECT, UPDATE;
910
}

0 commit comments

Comments
 (0)