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

Fix negative,non-broadcasted obs search [VIPSUTV-483]

parent 53c3f8dd
Branches
Tags
No related merge requests found
......@@ -69,6 +69,8 @@ import no.nibio.vips.observationdata.ObservationDataSchema;
import no.nibio.vips.observationdata.ObservationDataSchemaPK;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.io.FilenameUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wololo.geojson.Feature;
import org.wololo.geojson.FeatureCollection;
import org.wololo.geojson.GeoJSONFactory;
......@@ -86,6 +88,8 @@ public class ObservationBean {
PointOfInterestBean pointOfInterestBean;
@EJB
UserBean userBean;
private static Logger LOGGER = LoggerFactory.getLogger(ObservationBean.class);
public List<Observation> getObservations(Integer organizationId)
{
......@@ -658,17 +662,18 @@ public class ObservationBean {
sql += "AND is_positive = :isPositive \n";
parameters.put("isPositive", isPositive);
}
LOGGER.debug(sql);
Query q = em.createNativeQuery(sql, Observation.class);
// Setting the parameters one by one
parameters.keySet().stream().forEach(
(key)->q.setParameter(key, parameters.get(key))
(key)->{LOGGER.debug(key + ": " + parameters.get(key)); q.setParameter(key, parameters.get(key));}
);
//Date start = new Date();
List<Observation> observations = q.getResultList();
//System.out.println("Finding obs took " + (new Date().getTime() - start.getTime()) + " milliseconds");
//start = new Date();
......@@ -688,6 +693,7 @@ public class ObservationBean {
retVal = this.getObservationsWithLocations(retVal);
//System.out.println("Finding locations took " + (new Date().getTime() - start.getTime()) + " milliseconds");
}
return retVal;
......
......@@ -588,7 +588,7 @@ public class Observation implements Serializable, no.nibio.vips.observation.Obse
*/
@Column(name = "location_is_private")
public Boolean getLocationIsPrivate() {
return locationIsPrivate;
return locationIsPrivate != null ? locationIsPrivate : false;
}
/**
......
......@@ -202,7 +202,6 @@ public class ObservationService {
return null;
}
}).collect(Collectors.toList());
//o.setObservationDataSchema(observationBean.getObservationDataSchema(observer.getOrganizationId().getOrganizationId(), o.getOrganismId()));
return Response.ok().entity(observations).build();
}
......@@ -775,7 +774,7 @@ public class ObservationService {
{
return filteredObservations;
}
List<Observation> retVal = filteredObservations.stream().filter(obs->obs.getBroadcastMessage()).collect(Collectors.toList());
List<Observation> retVal = filteredObservations.stream().filter(obs->obs.getBroadcastMessage() || (isPositive == null || !isPositive)).collect(Collectors.toList());
//retVal.forEach(o->System.out.println(o.getObservationId()));
retVal = this.maskObservations(retVal);
//retVal.forEach(o->System.out.println(o.getObservationId()));
......@@ -800,7 +799,7 @@ public class ObservationService {
// Placing all observations with a polygon service in the correct bucket.
Map<PolygonService, List<Observation>> registeredPolygonServicesInObservationList = new HashMap<>();
observations.stream().filter((obs) -> (!obs.getLocationIsPrivate() && obs.getPolygonService() != null)).forEachOrdered((obs) -> {
observations.stream().filter((obs) -> { return (!obs.getLocationIsPrivate() && obs.getPolygonService() != null);}).forEachOrdered((obs) -> {
List<Observation> obsWithPolyServ = registeredPolygonServicesInObservationList.getOrDefault(obs.getPolygonService(), new ArrayList<>());
obsWithPolyServ.add(obs);
registeredPolygonServicesInObservationList.put(obs.getPolygonService(), obsWithPolyServ);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment