View Javadoc
1   package org.myorg.jpatickets.bl;
2   
3   import java.util.ArrayList;
4   
5   import java.util.List;
6   
7   import org.myorg.jpatickets.bo.Seat;
8   import org.myorg.jpatickets.bo.Venue;
9   import org.myorg.jpatickets.dao.VenueDAO;
10  
11  public class VenueMgmtImpl implements VenueMgmt {
12      VenueDAO dao;
13      
14      public void setDao(VenueDAO dao) {
15          this.dao = dao;
16      }
17  
18      @Override
19      public Venue createVenue(Venue venue, int sections, int positions, int rows) {
20          List<Seat> seats = new ArrayList<Seat>(sections * positions * rows);
21          for (int s=0; s<sections; s++) {
22              String section = Character.toString((char)('A'+s));
23              for (int row=0; row<rows; row++) {
24                  for (int pos=0; pos<positions; pos++) {
25                      Seat seat = new Seat(venue, section, row, pos);
26                      seats.add(seat);
27                  }
28              }
29          }
30          dao.saveVenue(venue, seats);
31          return venue;
32      }
33  
34      @Override
35      public Venue getVenue(String venueId) {
36          return dao.getVenue(venueId);
37      }
38  }