// Path: src/main/java/org/mockenize/model/LogBean.java
// @Data
// public class LogBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String key;
// 
// 	private LogType type;
// 
// 	private String url;
// 
// 	private String path;
// 
// 	private String method;
// 
// 	private RequestLogBean request;
// 
// 	private ResponseLogBean response;
// 
// 	private Date date = new Date();
// 
// 	protected LogBean() {
// 	}
// 
// 	public LogBean(UUID key, LogType type) {
// 		this.key = key.toString();
// 		this.type = type;
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/service/LoggingService.java
// @Service
// public class LoggingService {
// 
//     @Autowired
//     private LogRepository logRepository;
// 
//     public void save(LogBean logBean) {
//         logRepository.save(logBean);
//     }
// 
//     public Collection<LogBean> getAll() {
//         return logRepository.findAll();
//     }
// 
//     public LogBean getByKey(UUID key) {
//         return logRepository.findByKey(key.toString());
//     }
// 
// 
//     public LogBean delete(UUID key) {
//         return logRepository.delete(key.toString());
//     }
// 
//     public Collection<LogBean> deleteAll() {
//        return logRepository.deleteAll();
//     }
// 
// 	@SuppressWarnings("unchecked")
// 	public Collection<LogBean> findByFilters(JsonNode jsonNode) {
// 		Iterator<String> fieldNames = jsonNode.fieldNames();
// 		Predicate<String, LogBean> predicate = null;
// 		while(fieldNames.hasNext()) {
// 			String field = fieldNames.next();
// 			String value = jsonNode.get(field).asText();
// 
// 			Predicate<String, LogBean> tmp = Predicates.equal(field, value);
// 			if(predicate == null) {
// 				predicate = tmp;
// 			} else {
// 				predicate = Predicates.and(predicate, tmp);
// 			}
// 		}
// 		return logRepository.findByPredicate(predicate);
// 	}
// }


import java.util.Collection;
import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
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 org.mockenize.model.LogBean;
import org.mockenize.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.JsonNode;
package org.mockenize.controller;





@Controller
@Path("/_mockenize/logs")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class LogController {

    @Autowired
    private LoggingService loggingService;

    @GET
    public Response getAll() {
        Collection<LogBean> logs = loggingService.getAll();
        return Response.ok(logs).build();
    }

    @GET
    @Path("/{key}")
    public Response getByKey(@PathParam("key") UUID key) {
        LogBean logBean = loggingService.getByKey(key);
        return Response.ok(logBean).build();
    }
    
    @POST
    @Path("find")
    public Response findByFilters(JsonNode jsonNode) {
    	Collection<LogBean> logBeans = loggingService.findByFilters(jsonNode);
    	return Response.ok(logBeans).build();
    }

    @DELETE
    @Path("/{key}")
    public Response delete(@PathParam("key") UUID key) {
// Path: src/main/java/org/mockenize/model/LogBean.java
// @Data
// public class LogBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String key;
// 
// 	private LogType type;
// 
// 	private String url;
// 
// 	private String path;
// 
// 	private String method;
// 
// 	private RequestLogBean request;
// 
// 	private ResponseLogBean response;
// 
// 	private Date date = new Date();
// 
// 	protected LogBean() {
// 	}
// 
// 	public LogBean(UUID key, LogType type) {
// 		this.key = key.toString();
// 		this.type = type;
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/service/LoggingService.java
// @Service
// public class LoggingService {
// 
//     @Autowired
//     private LogRepository logRepository;
// 
//     public void save(LogBean logBean) {
//         logRepository.save(logBean);
//     }
// 
//     public Collection<LogBean> getAll() {
//         return logRepository.findAll();
//     }
// 
//     public LogBean getByKey(UUID key) {
//         return logRepository.findByKey(key.toString());
//     }
// 
// 
//     public LogBean delete(UUID key) {
//         return logRepository.delete(key.toString());
//     }
// 
//     public Collection<LogBean> deleteAll() {
//        return logRepository.deleteAll();
//     }
// 
// 	@SuppressWarnings("unchecked")
// 	public Collection<LogBean> findByFilters(JsonNode jsonNode) {
// 		Iterator<String> fieldNames = jsonNode.fieldNames();
// 		Predicate<String, LogBean> predicate = null;
// 		while(fieldNames.hasNext()) {
// 			String field = fieldNames.next();
// 			String value = jsonNode.get(field).asText();
// 
// 			Predicate<String, LogBean> tmp = Predicates.equal(field, value);
// 			if(predicate == null) {
// 				predicate = tmp;
// 			} else {
// 				predicate = Predicates.and(predicate, tmp);
// 			}
// 		}
// 		return logRepository.findByPredicate(predicate);
// 	}
// }


// Path: src/main/java/org/mockenize/controller/LogController.java
import java.util.Collection;
import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
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 org.mockenize.model.LogBean;
import org.mockenize.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.fasterxml.jackson.databind.JsonNode;

package org.mockenize.controller;





@Controller
@Path("/_mockenize/logs")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class LogController {

    @Autowired
    private LoggingService loggingService;

    @GET
    public Response getAll() {
        Collection<LogBean> logs = loggingService.getAll();
        return Response.ok(logs).build();
    }

    @GET
    @Path("/{key}")
    public Response getByKey(@PathParam("key") UUID key) {
        LogBean logBean = loggingService.getByKey(key);
        return Response.ok(logBean).build();
    }
    
    @POST
    @Path("find")
    public Response findByFilters(JsonNode jsonNode) {
    	Collection<LogBean> logBeans = loggingService.findByFilters(jsonNode);
    	return Response.ok(logBeans).build();
    }

    @DELETE
    @Path("/{key}")
    public Response delete(@PathParam("key") UUID key) {
        LogBean deletedLogBean = loggingService.delete(key);