package cinema.services;

import java.util.Collection;
import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import cinema.dao.ProjectionDAO;
import cinema.model.Projection;

@Stateless
@Path("projection")
public class ProjectionManager {

	@Inject
	private ProjectionDAO projectionDAO;

	@GET
	@Produces("application/json")
	public Collection<Projection> getAllProjections() {
		return projectionDAO.getAllProjections();
	}

	@Path("places")
	@GET
	@Produces("application/json")
	public String places(String movieTitle) {
		Collection<Projection> projections = projectionDAO.getAllProjections();
		for (Projection projection : projections) {
			if (projection.getMovieTitle().equals(movieTitle)) {
				return projection.getPlaces().toString();
			}
		}
		return null;
	}
}

@@ -51,31 +51,8 @@
 ion;
-%0Aimport java.util.List;
 %0A%0Aim
@@ -109,37 +109,8 @@
 ct;%0A
-import javax.ws.rs.Consumes;%0A
 impo
@@ -174,23 +174,24 @@
 .ws.rs.P
-roduces
+athParam
 ;%0Aimport
@@ -207,22 +207,16 @@
 .rs.
-core.MediaType
+Produces
 ;%0A%0Ai
@@ -537,28 +537,36 @@
 %0A%0A%09@
-Path(%22places%22)%0A%09@GET
+GET%0A%09@Path(%22%7BprojectionId%7D%22)
 %0A%09@P
@@ -619,25 +619,54 @@
 ces(
-String movieTitle
+@PathParam(%22projectionId%22) String projectionId
 ) %7B%0A
@@ -739,16 +739,52 @@
 ions();%0A
+%09%09System.out.println(projectionId);%0A
 %09%09for (P
@@ -846,38 +846,48 @@
 .get
-MovieTitle().equals(movieTitle
+Id().equals(Long.parseLong(projectionId)
 )) %7B

add rest for freePlaces