[Lada-commits] [PATCH 3 of 5] Avoid fetching the whole table from DB if we don't need it at all
Wald Commits
scm-commit at wald.intevation.org
Thu Dec 8 16:12:40 CET 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1481205542 -3600
# Node ID 6e6134bf1d6dcd02a533236f9af33090cc6d252f
# Parent aed3332cfacc086f50d4c267586c4a4ff84289f5
Avoid fetching the whole table from DB if we don't need it at all.
diff -r aed3332cfacc -r 6e6134bf1d6d src/main/java/de/intevation/lada/rest/stamm/OrtService.java
--- a/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Thu Dec 08 14:47:21 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/stamm/OrtService.java Thu Dec 08 14:59:02 2016 +0100
@@ -8,6 +8,7 @@
package de.intevation.lada.rest.stamm;
import java.util.List;
+import java.util.ArrayList;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
@@ -112,7 +113,6 @@
@Context UriInfo info
) {
MultivaluedMap<String, String> params = info.getQueryParameters();
- List<Ort> orte = repository.getAllPlain(Ort.class, "stamm");
if (params.containsKey("ortId")) {
Integer id;
try {
@@ -131,6 +131,8 @@
Ort.class));
return new Response(true, 200, o);
}
+
+ List<Ort> orte = new ArrayList<Ort>();
if (params.containsKey("qid")) {
Integer id = null;
try {
@@ -169,6 +171,9 @@
orte = repository.filterPlain(builder.getQuery(), "stamm");
}
+ else {
+ orte = repository.getAllPlain(Ort.class, "stamm");
+ }
int size = orte.size();
if (params.containsKey("start") && params.containsKey("limit")) {
More information about the Lada-commits
mailing list