Skip to content
Snippets Groups Projects
Commit a6f8e040 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added observations for user as endpoint

parent b6b032fb
Branches
Tags
No related merge requests found
...@@ -37,4 +37,7 @@ Crops, pests, diseases and weeds are all organisms subject to [classification](h ...@@ -37,4 +37,7 @@ Crops, pests, diseases and weeds are all organisms subject to [classification](h
### Crop categories ### Crop categories
Each organization (NIBIO, Jordbruksverket, ADAS etc.) has their own set of crop categories. They can be e.g. cereals, fruit, vegetables. Each of these links to one or more organisms. Each organization (NIBIO, Jordbruksverket, ADAS etc.) has their own set of crop categories. They can be e.g. cereals, fruit, vegetables. Each of these links to one or more organisms.
\ No newline at end of file
### Field observations
An Observation is a registration of a pest in space and time.
\ No newline at end of file
...@@ -100,7 +100,7 @@ public class AuthenticationService { ...@@ -100,7 +100,7 @@ public class AuthenticationService {
} }
/** /**
* * Provide the UUID as the contents of the Authorization header
* @return The VIPSLogic user associated with this uuid, or 404 if not found * @return The VIPSLogic user associated with this uuid, or 404 if not found
*/ */
@GET @GET
......
...@@ -49,8 +49,11 @@ import javax.ws.rs.client.ClientBuilder; ...@@ -49,8 +49,11 @@ import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity; import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget; import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
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 javax.ws.rs.core.Response.Status;
import no.nibio.vips.logic.entity.Gis; import no.nibio.vips.logic.entity.Gis;
import no.nibio.vips.logic.entity.Observation; import no.nibio.vips.logic.entity.Observation;
import no.nibio.vips.logic.entity.PolygonService; import no.nibio.vips.logic.entity.PolygonService;
...@@ -277,6 +280,29 @@ public class ObservationService { ...@@ -277,6 +280,29 @@ public class ObservationService {
return Response.ok().entity(SessionControllerGetter.getObservationBean().getObservations(organizationId, Observation.STATUS_TYPE_ID_APPROVED)).build(); return Response.ok().entity(SessionControllerGetter.getObservationBean().getObservations(organizationId, Observation.STATUS_TYPE_ID_APPROVED)).build();
} }
/**
* Get observations for a user
* Requires a valid UUID to be provided in the Authorization header
* @return
*/
@GET
@Path("list/user")
@Produces("application/json;charset=UTF-8")
public Response getObservationsForUser()
{
String uuidStr = httpServletRequest.getHeader(HttpHeaders.AUTHORIZATION);
UUID uuid = UUID.fromString(uuidStr);
VipsLogicUser user = SessionControllerGetter.getUserBean().findVipsLogicUser(uuid);
if(user != null)
{
return Response.ok().entity(SessionControllerGetter.getObservationBean().getObservationsForUser(user)).build();
}
else
{
return Response.status(Status.NOT_FOUND).build();
}
}
/** /**
* Publicly available observations per organization * Publicly available observations per organization
* @param organizationId * @param organizationId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment