From 3ff45b7c470758f8c7c654eca745c493172ee4d3 Mon Sep 17 00:00:00 2001 From: sapmentors Date: Mon, 10 Oct 2016 18:57:45 +0200 Subject: [PATCH] Number of participants that where checked in #23 --- .../procedures/ParticipantNumbersRead.hdbview | 30 +++++++++++++++++++ odataorganizer/service.xsodata | 11 ++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 odataorganizer/procedures/ParticipantNumbersRead.hdbview diff --git a/odataorganizer/procedures/ParticipantNumbersRead.hdbview b/odataorganizer/procedures/ParticipantNumbersRead.hdbview new file mode 100644 index 0000000..8a0827a --- /dev/null +++ b/odataorganizer/procedures/ParticipantNumbersRead.hdbview @@ -0,0 +1,30 @@ +// +// Copyright 2016 SAP Mentors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// +// Thanks to the Blog: OData read exits - a delightful solution +// http://scn.sap.com/community/developer-center/hana/blog/2016/01/14/odata-read-exits--an-ingenious-solution +// +schema = "SITREG"; +query = "SELECT \"Event\".\"ID\" AS \"EventID\", + CAST( IFNULL (\"Ticket\".\"Participated\", 0) AS Integer ) AS \"Participated\" + FROM \"SITREG\".\"com.sap.sapmentors.sitreg.data::SITreg.Event\" AS \"Event\" + LEFT OUTER JOIN ( + SELECT \"EventID\", COUNT(*) AS \"Participated\" + FROM \"SITREG\".\"com.sap.sapmentors.sitreg.data::SITreg.Ticket\" + WHERE \"TicketUsed\" = 'Y' OR \"TicketUsed\" = 'M' + GROUP BY \"EventID\" ) AS \"Ticket\" + ON \"Event\".\"ID\" = \"Ticket\".\"EventID\" + GROUP BY \"Ticket\".\"Participated\", \"Event\".\"ID\";"; diff --git a/odataorganizer/service.xsodata b/odataorganizer/service.xsodata index 05ff13a..6b82446 100644 --- a/odataorganizer/service.xsodata +++ b/odataorganizer/service.xsodata @@ -24,7 +24,8 @@ service { "Events_Devices" as "Devices", "Event_Changeable" as "EventChangeable", "Event_RegistrationNumbers" as "RegistrationNumbers", - "Event_PrePostEveningEventNumbers" as "PrePostEveningEventNumbers" + "Event_PrePostEveningEventNumbers" as "PrePostEveningEventNumbers", + "Event_ParticipantNumbers" as "ParticipantNumbers" ) create using "com.sap.sapmentors.sitreg.odataorganizer.procedures::EventCreate" update using "com.sap.sapmentors.sitreg.odataorganizer.procedures::EventUpdate" @@ -80,6 +81,14 @@ service { association "Event_PrePostEveningEventNumbers" principal "Events"("ID") multiplicity "1" dependent "PrePostEveningEventNumbers"("EventID") multiplicity "1"; + "com.sap.sapmentors.sitreg.odataorganizer.procedures::ParticipantNumbersRead" as "ParticipantNumbers" key ("EventID") + create forbidden + update forbidden + delete forbidden; + + association "Event_ParticipantNumbers" principal "Events"("ID") multiplicity "1" + dependent "ParticipantNumbers"("EventID") multiplicity "1"; + // Read Ticket from View to restrict fields that can be read "com.sap.sapmentors.sitreg.odatareceptionist.procedures::TicketRead" as "Ticket" key ("ParticipantID") create forbidden