package com.br.distanceCities.rest;

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

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import com.br.distanceCities.model.City;

@Path("/cities")
@RequestScoped
public class CityRESTService {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<City> listAllCities() {
    	List<City> retorno = new ArrayList<>();
    	City c = new City();
    	c.setId(99999l);
    	c.setName("Sampa");
    	retorno.add(c);
    	c = new City();
    	c.setId(88888l);
    	c.setName("rio");
    	retorno.add(c);
    	c = new City();
    	c.setId(77777l);
    	c.setName("floripa");
    	retorno.add(c);
        return retorno;
    }

    @GET
    @Path("/{type:[JX]}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response lookupMemberById(@PathParam("type") String type) {
    	City c = new City();
    	c.setId(99999l);
    	c.setName("Sampa");
    	String mediaType = type.equalsIgnoreCase("J")?MediaType.APPLICATION_JSON:MediaType.APPLICATION_XML;
    	
    	return Response.ok(c, mediaType).build();
    }

}

@@ -51,89 +51,14 @@
 til.
-Array
 List;%0A
-import java.util.List;%0A%0Aimport javax.enterprise.context.RequestScoped;
 %0Aimp
@@ -232,16 +232,57 @@
 ponse;%0A%0A
+import com.br.distanceCities.db.CityDAO;%0A
 import c
@@ -336,23 +336,8 @@
 s%22)%0A
-@RequestScoped%0A
 publ
@@ -426,26 +426,24 @@
  public 
-List%3CCity%3E
+Response
  listAll
@@ -462,342 +462,125 @@
    %09
-List%3CCity%3E retorno = new ArrayList%3C%3E();%0A    %09City c = new City();%0A    %09c.setId(99999l);%0A    %09c.setName(%22Sampa%22);%0A    %09retorno.add(c);%0A    %09c = new City();%0A    %09c.setId(88888l);%0A    %09c.setName(%22rio%22);%0A
+CityDAO dao = new CityDAO();%0A    %09List%3CCity%3E retorno = dao.buscarTodos();%0A    
     
-%09
 ret
-orno.add(c);%0A    %09c = new City();%0A    %09c.setId(77777l);%0A    %09c.setName(%22floripa%22);%0A    %09retorno.add(c);%0A        return retorno
+urn Response.ok(retorno).build()
 ;%0A  
@@ -805,17 +805,16 @@
 Id(99999
-l
 );%0A    %09

Ajuste para buscar cidade do banco