package org.jboss.da.rest.reports;

import org.jboss.da.reports.api.GAV;
import org.jboss.da.reports.backend.api.VersionFinder;
import org.jboss.da.rest.reports.model.GAVRequest;
import org.jboss.da.rest.reports.model.LookupReport;
import org.jboss.da.rest.reports.model.Report;
import org.jboss.da.rest.reports.model.SCMRequest;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

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

/**
 * Main end point for the reports
 * 
 * @author Dustin Kut Moy Cheung
 * @author Jakub Bartecek <jbartece@redhat.com>
 *
 */
@Path("/reports")
public class Reports {

    @Inject
    private VersionFinder versionFinder;

    @POST
    @Path("/scm")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Report scmGenerator(SCMRequest scmRequest) {
        // TODO Auto-generated method stub
        return null;
    }

    @POST
    @Path("/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Report gavGenerator(GAVRequest gavRequest) {
        // TODO Auto-generated method stub
        return null;
    }

    @POST
    @Path("/lookup/gav")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public List<LookupReport> lookupGav(List<GAV> gavRequest) {
        List<LookupReport> reportsList = new ArrayList<>();
        gavRequest.forEach((gav) -> reportsList.add(toLookupReport(gav)));
        return reportsList;
    }

    private LookupReport toLookupReport(GAV gav) {
        return new LookupReport(gav, versionFinder.getBestMatchVersionFor(gav));
    }
}

@@ -29,16 +29,113 @@
 ports;%0A%0A
+import com.wordnik.swagger.annotations.Api;%0Aimport com.wordnik.swagger.annotations.ApiOperation;%0A
 import o
@@ -163,16 +163,16 @@
 pi.GAV;%0A
-
 import o
@@ -793,16 +793,97 @@
 ports%22)%0A
+@Api(value = %22/reports%22, description = %22Get report of dependencies of projects%22)%0A
 public c
@@ -1056,32 +1056,127 @@
 PLICATION_JSON)%0A
+    @ApiOperation(value = %22Get dependency report for a project specified in a repository url%22)%0A
     public Repor
@@ -1390,32 +1390,93 @@
 PLICATION_JSON)%0A
+    @ApiOperation(value = %22Get dependency report for a GAV%22)%0A
     public Repor
@@ -1655,32 +1655,32 @@
 PLICATION_JSON)%0A
-
     @Produces(Me
@@ -1701,24 +1701,109 @@
 ATION_JSON)%0A
+    @ApiOperation(value = %22Get best matching version for the list of GAVs provided%22)%0A
     public L

Add swagger annotation for REST documentation to Reports class