package policycompass.fcmmanager.services;

import java.util.ArrayList;
import java.util.List;

import javax.transaction.Transactional;
import javax.ws.rs.*;
import javax.ws.rs.core.*;

import policycompass.fcmmanager.controllers.*;
import policycompass.fcmmanager.models.*;

@Path("/fcmmanager")
public class FCMModelService {

/*	@GET
	@Path("/models")
	@Produces(MediaType.APPLICATION_JSON)
	public Response retrieveAllModels() throws Exception {
		Response rb = null;
		rb = Response.ok(FCMModels.retrieveFCMModelList()).build();
		return rb;
	}
*/
	
	@GET
	@Path("/models")
	@Produces(MediaType.APPLICATION_JSON)
	public List<FCMModel> retrieveAllModels() throws Exception {
		return FCMModels.retrieveFCMModelList();
	}

	
	@GET
	@Path("/models/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public Response retrieveFCMModel(@PathParam("id") int id) throws Exception {
		Response rb = null;
		rb = Response.ok(FCMModels.retrieveFCMModel(id)).build();
		return rb;
	}

    @POST @Path("/list")
    @Consumes({MediaType.APPLICATION_JSON})
    @Transactional
    public Response createPodcasts(ArrayList<FCMModel> fcmmodels) {
        for(FCMModel fcmmodel : fcmmodels){
        	FCMModels.createFCMModel(fcmmodel);            
        }
 
        return Response.status(204).build();     
    }

	@GET
	@Path("/loaddata")
	@Produces(MediaType.APPLICATION_JSON)
	public Response LoadDataService() throws Exception {
		Response rb = null;
		rb = Response.ok(FCMModels.LoadData()).build();
		return rb;
	}

}

@@ -41,100 +41,8 @@
 s;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport javax.transaction.Transactional;%0A
 impo
@@ -234,10 +234,8 @@
  %7B%0A%0A
-/*
 %09@GE
@@ -453,185 +453,8 @@
 %0A%09%7D%0A
-*/%0A%09%0A%09@GET%0A%09@Path(%22/models%22)%0A%09@Produces(MediaType.APPLICATION_JSON)%0A%09public List%3CFCMModel%3E retrieveAllModels() throws Exception %7B%0A%09%09return FCMModels.retrieveFCMModelList();%0A%09%7D%0A%0A
 %09%0A%09@
@@ -706,24 +706,29 @@
   @POST 
+%0A    
 @Path(%22/
 list%22)%0A 
@@ -723,12 +723,14 @@
 h(%22/
-list
+models
 %22)%0A 
@@ -781,75 +781,447 @@
    @
-Transactional%0A    public Response createPodcasts(ArrayList%3C
+Produces(%7BMediaType.APPLICATION_JSON%7D)%0A    public Response createFCMModel(FCMModel fcmmodels) %7B%0A//        for(FCMModel fcmmodel : fcmmodels)%7B%0A  //      %09FCMModels.createFCMModel(fcmmodel);            %0A    //    %7D%0A %0A        return Response.status(204).build();     %0A    %7D%0A%0A    @PUT %0A    @Path(%22/models/%7Bid%7D%22)%0A    @Consumes(%7BMediaType.APPLICATION_JSON%7D)%0A    @Produces(%7BMediaType.APPLICATION_JSON%7D)%0A    public Response updateFCMModel(
 FCMModel
 %3E fc
@@ -1220,9 +1220,8 @@
 odel
-%3E
  fcm
@@ -1230,16 +1230,18 @@
 dels) %7B%0A
+//
         
@@ -1278,16 +1278,18 @@
 els)%7B%0A  
+//
       %09F
@@ -1335,24 +1335,347 @@
        %0A    
+//    %7D%0A %0A        return Response.status(204).build();     %0A    %7D%0A%0A    @DELETE %0A    @Path(%22/models/%7Bid%7D%22)%0A    @Produces(%7BMediaType.APPLICATION_JSON%7D)%0A    public Response deleteFCMModel(@PathParam(%22id%22) int id) %7B%0A//        for(FCMModel fcmmodel : fcmmodels)%7B%0A  //      %09FCMModels.createFCMModel(fcmmodel);            %0A    //
     %7D%0A %0A    

Add more functionalities