diff --git a/odataorganizer/procedures/PrePostEveningEventNumbersRead.hdbview b/odataorganizer/procedures/PrePostEveningEventNumbersRead.hdbview new file mode 100644 index 0000000..9be21b4 --- /dev/null +++ b/odataorganizer/procedures/PrePostEveningEventNumbersRead.hdbview @@ -0,0 +1,45 @@ +// +// 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\", + \"PreEveningEvent\".\"PreEveningEvent\" AS \"PreEveningEvent\", + \"PostEveningEvent\".\"PostEveningEvent\" AS \"PostEveningEvent\" + FROM \"SITREG\".\"com.sap.sapmentors.sitreg.data::SITreg.Event\" AS \"Event\" + LEFT OUTER JOIN ( + SELECT \"EventID\", COUNT(*) AS \"PreEveningEvent\" + FROM \"SITREG\".\"com.sap.sapmentors.sitreg.data::SITreg.Participant\" + WHERE \"PreEveningEvent\" = 'Y' + GROUP BY \"EventID\" ) AS \"PreEveningEvent\" + ON \"Event\".\"ID\" = \"PreEveningEvent\".\"EventID\" + LEFT OUTER JOIN ( + SELECT \"EventID\", COUNT(*) AS \"PostEveningEvent\" + FROM \"SITREG\".\"com.sap.sapmentors.sitreg.data::SITreg.Participant\" + WHERE \"PostEveningEvent\" = 'Y' + GROUP BY \"EventID\" ) AS \"PostEveningEvent\" + ON \"Event\".\"ID\" = \"PostEveningEvent\".\"EventID\" + GROUP BY + \"PreEveningEvent\".\"PreEveningEvent\", + \"PostEveningEvent\".\"PostEveningEvent\", + \"Event\".\"MaxParticipants\", + \"Event\".\"ID\";"; +// Using an hdbtablefunction does not work as it would need SELECT authorization on the Participant table +// query = "select * from \"com.sap.sapmentors.sitreg.odataparticipant.procedures::RegistrationNumbersReadFunc\"()"; +// depends_on_view=["com.sap.sapmentors.sitreg.odataparticipant.procedures::RegistrationNumbersReadFunc"]; diff --git a/odataorganizer/service.xsodata b/odataorganizer/service.xsodata index e5e3243..85d44b2 100644 --- a/odataorganizer/service.xsodata +++ b/odataorganizer/service.xsodata @@ -22,7 +22,8 @@ service { "Events_Participants" as "Participants", "Events_CoOrganizers" as "CoOrganizers", "Event_Changeable" as "EventChangeable", - "Event_RegistrationNumbers" as "RegistrationNumbers" + "Event_RegistrationNumbers" as "RegistrationNumbers", + "Event_PrePostEveningEventNumbers" as "PrePostEveningEventNumbers" ) create using "com.sap.sapmentors.sitreg.odataorganizer.procedures::EventCreate" update using "com.sap.sapmentors.sitreg.odataorganizer.procedures::EventUpdate" @@ -61,4 +62,11 @@ service { association "Event_RegistrationNumbers" principal "Events"("ID") multiplicity "1" dependent "RegistrationNumbers"("EventID") multiplicity "1"; + "com.sap.sapmentors.sitreg.odataorganizer.procedures::PrePostEveningEventNumbersRead" as "PrePostEveningEventNumbers" key ("EventID") + create forbidden + update forbidden + delete forbidden; + + association "Event_PrePostEveningEventNumbers" principal "Events"("ID") multiplicity "1" + dependent "PrePostEveningEventNumbers"("EventID") multiplicity "1"; } \ No newline at end of file