Skip to content

Commit

Permalink
Rename TicketCategoryCount
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogoevici authored and pmuir committed May 28, 2012
1 parent 7fb3bbf commit 9e7c61c
Showing 1 changed file with 6 additions and 10 deletions.
Expand Up @@ -9,8 +9,6 @@

import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
Expand All @@ -26,7 +24,7 @@
import org.jboss.jdf.example.ticketmonster.model.Customer;
import org.jboss.jdf.example.ticketmonster.model.Performance;
import org.jboss.jdf.example.ticketmonster.model.PriceCategory;
import org.jboss.jdf.example.ticketmonster.model.TicketCategoryCount;
import org.jboss.jdf.example.ticketmonster.model.AllocationTicketCategoryCount;
import org.jboss.jdf.example.ticketmonster.model.SectionRow;

/**
Expand All @@ -38,7 +36,6 @@
public class BookingService extends BaseEntityService<Booking> {



public BookingService() {
super(Booking.class); //To change body of overridden methods use File | Settings | File Templates.
}
Expand All @@ -61,8 +58,7 @@ public Response createBooking(@FormParam("email") String email,
@FormParam("performance") Long performanceId,
@FormParam("priceCategories") Long[] priceCategoryIds,
@FormParam("sections") Long[] sectionIds,
@FormParam("tickets") String[] ticketCounts
) {
@FormParam("tickets") String[] ticketCounts) {
Customer customer = new Customer();
customer.setEmail(email);
getEntityManager().persist(customer);
Expand All @@ -77,18 +73,18 @@ public Response createBooking(@FormParam("email") String email,
Response response = Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
}
Map<Long, Integer> ticketCountsPerSection = new LinkedHashMap<Long, Integer>();
Map<Long, List<TicketCategoryCount>> ticketsPerCategory = new LinkedHashMap<Long, List<TicketCategoryCount>>();
Map<Long, List<AllocationTicketCategoryCount>> ticketsPerCategory = new LinkedHashMap<Long, List<AllocationTicketCategoryCount>>();
for (int i = 0; i < ticketCounts.length; i++) {
if (ticketCounts[i] == null || "".equals(ticketCounts[i].trim()))
continue;
Integer ticketCountAsInteger = Integer.valueOf(ticketCounts[i]);
if (!ticketCountsPerSection.containsKey(sectionIds[i])) {
ticketCountsPerSection.put(sectionIds[i], 0);
ticketsPerCategory.put(sectionIds[i], new ArrayList<TicketCategoryCount>());
ticketsPerCategory.put(sectionIds[i], new ArrayList<AllocationTicketCategoryCount>());
}
ticketCountsPerSection.put(sectionIds[i], ticketCountsPerSection.get(sectionIds[i]) + ticketCountAsInteger);
final PriceCategory priceCategory = getEntityManager().find(PriceCategory.class, priceCategoryIds[i]);
ticketsPerCategory.get(sectionIds[i]).add(new TicketCategoryCount(priceCategory.getCategory(), ticketCountAsInteger));
ticketsPerCategory.get(sectionIds[i]).add(new AllocationTicketCategoryCount(priceCategory.getCategory(), ticketCountAsInteger));
}
for (Long sectionId : ticketCountsPerSection.keySet()) {
int ticketCount = ticketCountsPerSection.get(sectionId);
Expand Down Expand Up @@ -137,7 +133,7 @@ public Response createBooking(@FormParam("email") String email,
getEntityManager().persist(createdAllocation);
booking.getAllocations().add(createdAllocation);
}
booking.setCancelationCode("abc");
booking.setCancellationCode("abc");
getEntityManager().persist(booking);
return Response.ok().entity(booking).type(MediaType.APPLICATION_JSON_TYPE).build();
}
Expand Down

0 comments on commit 9e7c61c

Please sign in to comment.