Skip to content

Commit

Permalink
Number of participants that where checked in #23
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf committed Oct 10, 2016
1 parent daa90b5 commit 3ff45b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
30 changes: 30 additions & 0 deletions odataorganizer/procedures/ParticipantNumbersRead.hdbview
Original file line number Diff line number Diff line change
@@ -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\";";
11 changes: 10 additions & 1 deletion odataorganizer/service.xsodata
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3ff45b7

Please sign in to comment.