package org.openlmis.web.controller;

import lombok.NoArgsConstructor;
import org.openlmis.report.model.dto.Product;
import org.openlmis.report.model.dto.ProductCategory;
import org.openlmis.report.model.dto.RequisitionGroup;
import org.openlmis.report.service.ReportLookupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**

 */
@Controller
@NoArgsConstructor
@RequestMapping(value = "/reports")
public class ReportLookupController extends BaseController {

    public static final String USER_ID = "USER_ID";

    private ReportLookupService productReportService;

    @Autowired
    public ReportLookupController(ReportLookupService productReportService) {
        this.productReportService = productReportService;
    }


    @RequestMapping(value="/products", method = GET, headers = ACCEPT_JSON)
    public List<Product> getProducts(){
          return this.productReportService.getAllProducts();
    }

    @RequestMapping(value="/rgroups", method = GET, headers = ACCEPT_JSON)
    public List<RequisitionGroup> getRequisitionGroups(){
        return this.productReportService.getAllRequisitionGroups();
    }

    @RequestMapping(value="/productCategories", method = GET, headers = ACCEPT_JSON)
    public List<ProductCategory> getProductCategories(){
        return this.productReportService.getAllProductCategories();
    }


}

@@ -450,16 +450,77 @@
 Mapping;
+%0Aimport org.springframework.web.bind.annotation.RequestParam;
 %0A%0Aimport
@@ -830,37 +830,36 @@
 okupService 
-productReport
+reportLookup
 Service;%0A%0A  
@@ -958,37 +958,36 @@
        this.
-productReport
+reportLookup
 Service = pr
@@ -1148,37 +1148,36 @@
 return this.
-productReport
+reportLookup
 Service.getA
@@ -1346,37 +1346,486 @@
 return this.
-productReport
+reportLookupService.getAllRequisitionGroups();%0A    %7D%0A%0A    @RequestMapping(value=%22/reporting_groups_by_program_schedule%22, method = GET, headers = ACCEPT_JSON)%0A    public List%3CRequisitionGroup%3E getRequisitionGroupsByProgramSchedule(%0A            @RequestParam(value = %22program%22, required = true, defaultValue = %221%22) int program,%0A            @RequestParam(value = %22schedule%22, required = true, defaultValue = %2210%22) int schedule%0A    )%7B%0A        return this.reportLookup
 Service.getA
@@ -1815,35 +1815,32 @@
 ookupService.get
-All
 RequisitionGroup
@@ -1832,33 +1832,69 @@
 equisitionGroups
-(
+ByProgramAndSchedule(program,schedule
 );%0A    %7D%0A%0A    @R
@@ -1879,32 +1879,33 @@
 hedule);%0A    %7D%0A%0A
+%0A
     @RequestMapp
@@ -2050,29 +2050,28 @@
 rn this.
-productReport
+reportLookup
 Service.

add a requisition group service that will return requisition groups based on program and schedule id.