Skip to content

Commit

Permalink
View to read pre- and post evening event participants, extend organiz…
Browse files Browse the repository at this point in the history
…er odata service sapmentors#23
  • Loading branch information
gregorwolf authored and open-ui5 committed Oct 14, 2016
1 parent 01976fe commit 8a7de6d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
45 changes: 45 additions & 0 deletions odataorganizer/procedures/PrePostEveningEventNumbersRead.hdbview
Original file line number Diff line number Diff line change
@@ -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"];
10 changes: 9 additions & 1 deletion odataorganizer/service.xsodata
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
}

0 comments on commit 8a7de6d

Please sign in to comment.