Removed unused imports;

This commit is contained in:
neviyn 2018-09-17 13:02:38 +01:00
parent eb0c5abc7b
commit c1e0241f05
3 changed files with 14 additions and 21 deletions

View File

@ -3,8 +3,6 @@ package uk.co.neviyn.Observations.core;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.NonNull; import lombok.NonNull;
@ -44,8 +42,8 @@ public class Observation {
@JsonProperty @JsonProperty
private DateTime date; private DateTime date;
public Observation(int siteId, String observed, int monitoring, int control, int conservatism, public Observation(int siteId, String observed, int monitoring, int control, int conservatism, int teamwork,
int teamwork, int knowledge, String rawData) { int knowledge, String rawData) {
this.siteId = siteId; this.siteId = siteId;
this.observed = observed; this.observed = observed;
this.monitoring = monitoring; this.monitoring = monitoring;
@ -57,7 +55,7 @@ public class Observation {
} }
private Observation(int id, int siteId, String observed, String type, int monitoring, int control, int conservatism, private Observation(int id, int siteId, String observed, String type, int monitoring, int control, int conservatism,
int teamwork, int knowledge, String rawData, DateTime date) { int teamwork, int knowledge, String rawData, DateTime date) {
this.id = id; this.id = id;
this.siteId = siteId; this.siteId = siteId;
this.observed = observed; this.observed = observed;
@ -71,7 +69,7 @@ public class Observation {
this.date = date; this.date = date;
} }
public static class Mapper implements RowMapper<Observation>{ public static class Mapper implements RowMapper<Observation> {
public Observation map(ResultSet rs, StatementContext ctx) throws SQLException { public Observation map(ResultSet rs, StatementContext ctx) throws SQLException {
return new Observation(rs.getInt("id"), rs.getInt("siteId"), rs.getString("observed"), rs.getString("type"), return new Observation(rs.getInt("id"), rs.getInt("siteId"), rs.getString("observed"), rs.getString("type"),

View File

@ -1,8 +1,6 @@
package uk.co.neviyn.Observations.resources; package uk.co.neviyn.Observations.resources;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.co.neviyn.Observations.api.SelectOption; import uk.co.neviyn.Observations.api.SelectOption;
import uk.co.neviyn.Observations.dao.SiteDao; import uk.co.neviyn.Observations.dao.SiteDao;
@ -16,14 +14,13 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("/site") @Path("/site")
@Slf4j
public class SiteResource { public class SiteResource {
private final SiteDao dao; private final SiteDao dao;
@Path("/all") @Path("/all")
@GET @GET
public List<SelectOption<Integer>> allSites(){ public List<SelectOption<Integer>> allSites() {
return dao.allSites().stream().map(x -> new SelectOption<>(x.getName(), x.getId())).collect(Collectors.toList()); return dao.allSites().stream().map(x -> new SelectOption<>(x.getName(), x.getId())).collect(Collectors.toList());
} }
} }

View File

@ -10,7 +10,6 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.co.neviyn.Observations.api.SelectOption; import uk.co.neviyn.Observations.api.SelectOption;
import uk.co.neviyn.Observations.core.Tutor; import uk.co.neviyn.Observations.core.Tutor;
import uk.co.neviyn.Observations.dao.TutorDao; import uk.co.neviyn.Observations.dao.TutorDao;
@ -18,25 +17,24 @@ import uk.co.neviyn.Observations.dao.TutorDao;
@RequiredArgsConstructor @RequiredArgsConstructor
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("/tutor") @Path("/tutor")
@Slf4j
public class TutorResource { public class TutorResource {
private final TutorDao dao; private final TutorDao dao;
@Path("/all") @Path("/all")
@GET @GET
public List<Tutor> allTutors(){ public List<Tutor> allTutors() {
List<Tutor> tutors = dao.allTutors(); List<Tutor> tutors = dao.allTutors();
if(tutors != null && !tutors.isEmpty()) if (tutors != null && !tutors.isEmpty())
return tutors; return tutors;
throw new WebApplicationException("No tutors found!", Response.Status.NOT_FOUND); throw new WebApplicationException("No tutors found!", Response.Status.NOT_FOUND);
} }
@Path("/site/{id}") @Path("/site/{id}")
@GET @GET
public List<SelectOption<Integer>> tutorsForSite(@PathParam("id")int siteId){ public List<SelectOption<Integer>> tutorsForSite(@PathParam("id") int siteId) {
List<Tutor> tutors = dao.tutorsForSite(siteId); List<Tutor> tutors = dao.tutorsForSite(siteId);
if(tutors != null && !tutors.isEmpty()){ if (tutors != null && !tutors.isEmpty()) {
return tutors.stream().map(x -> new SelectOption<>(x.getName(), x.getId())).collect(Collectors.toList()); return tutors.stream().map(x -> new SelectOption<>(x.getName(), x.getId())).collect(Collectors.toList());
} }
throw new WebApplicationException("No tutors found!", Response.Status.NOT_FOUND); throw new WebApplicationException("No tutors found!", Response.Status.NOT_FOUND);