Mercurial > dive4elements > river
changeset 8239:b207eeb66edd
(issue1448) Objectify sq_time_interval id.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 08 Sep 2014 19:47:01 +0200 |
parents | be3c11bef6e8 |
children | 61fd22f65bd4 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java |
diffstat | 5 files changed, 30 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Mon Sep 08 19:01:26 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java Mon Sep 08 19:47:01 2014 +0200 @@ -27,7 +27,7 @@ private int [] period; - private int sqTiId; + private Integer sqTiId; public SedimentLoadAccess(D4EArtifact artifact) { super(artifact); @@ -115,10 +115,9 @@ } /** Returns the selected time interval id */ - public int getSQTiId () { - if (sqTiId == 0) { - Integer obj = getInteger("sq_ti_id"); - sqTiId = obj == null ? 0 : obj; + public Integer getSQTiId () { + if (sqTiId == null) { + sqTiId = getInteger("sq_ti_id"); } return sqTiId; }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Mon Sep 08 19:01:26 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java Mon Sep 08 19:47:01 2014 +0200 @@ -123,7 +123,7 @@ private int id; private int kind; - private int sqTiId; + private Integer sqTiId; private String description; @@ -152,14 +152,14 @@ this.stopTime = stopTime; this.sqStartTime = sqStartTime; this.sqStopTime = sqStopTime; - this.sqTiId = sqTiId == null ? 0 : sqTiId; + this.sqTiId = sqTiId; } public int getId() { return id; } - public int getSQRelationTimeIntervalId() { + public Integer getSQRelationTimeIntervalId() { return sqTiId; } @@ -437,20 +437,24 @@ public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { @Override public int compare(Load a, Load b) { - return a.getSQRelationTimeIntervalId() - b.getSQRelationTimeIntervalId(); - } - }; - - public static final Comparator<Load> LOAD_ID_SQ_TI_CMP = new Comparator<Load>() { - @Override - public int compare(Load a, Load b) { - return LOAD_ID_CMP.compare(a, b) + LOAD_SQ_TI_CMP.compare(a,b); + Integer a_id = a.getSQRelationTimeIntervalId(); + Integer b_id = b.getSQRelationTimeIntervalId(); + if (a_id == null && b_id == null) { + return 0; + } + if (a_id == null) { + return -1; + } + if (b_id == null) { + return 1; + } + return a_id - b_id; } }; /** Find all loads in the range a/b with the according sq_time_interval */ - public Collection<Load> findLoads(double a, double b, int sqRelationTimeInterval) { - final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_SQ_TI_CMP); + public Collection<Load> findLoads(double a, double b, Integer sqRelationTimeInterval) { + final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP); findStations(a, b, new Visitor() { @Override
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Mon Sep 08 19:01:26 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Mon Sep 08 19:47:01 2014 +0200 @@ -172,7 +172,7 @@ double from = access.getLowerKM(); double to = access.getUpperKM(); - int sqTiId = access.getSQTiId(); + Integer sqTiId = access.getSQTiId(); if (yearEpoch.equals("year")) { years = access.getPeriod();
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Mon Sep 08 19:01:26 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java Mon Sep 08 19:47:01 2014 +0200 @@ -112,25 +112,25 @@ public static final class SQTimeInterval implements Filter { - private int sqTiId; + private Integer sqTiId; - public SQTimeInterval(int sqTiId) { + public SQTimeInterval(Integer sqTiId) { this.sqTiId = sqTiId; } @Override public boolean accept(Value value) { - if (sqTiId == 0) { + if (sqTiId == null) { /* Nothing set, nothing filtered */ return true; } - if (value.getLoad().getSQRelationTimeIntervalId() == 0) { + if (value.getLoad().getSQRelationTimeIntervalId() == null) { /* Loads without sqRelationTimeInterval are "Schwebstoffe" and should * be included. */ return true; } /* All other values should be filtered accordingly. */ - return value.getLoad().getSQRelationTimeIntervalId() == sqTiId; + return value.getLoad().getSQRelationTimeIntervalId().equals(sqTiId); } } // class SQTimeInterval
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Mon Sep 08 19:01:26 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java Mon Sep 08 19:47:01 2014 +0200 @@ -92,13 +92,13 @@ for (Iterator<Load> it = loads.iterator(); it.hasNext();) { /* Skip loads without time interval for this info type. */ - if (it.next().getSQRelationTimeIntervalId() == 0) { + if (it.next().getSQRelationTimeIntervalId() == null) { it.remove(); } } } else { if (!sq_ti_id.isEmpty()) { - int id = Integer.parseInt(sq_ti_id); + Integer id = Integer.parseInt(sq_ti_id); log.debug("Finding only items for id"); loads = allLoadData.findLoads(fromD, toD, id); } else { @@ -135,7 +135,7 @@ String.valueOf(calendar.get(Calendar.YEAR))); } /* SQ Time interval */ - if (load.getSQRelationTimeIntervalId() != 0) { + if (load.getSQRelationTimeIntervalId() != null) { ele.setAttribute("sq_ti_id", String.valueOf(load.getSQRelationTimeIntervalId())); Date start = load.getSQStartTime(); Date stop = load.getSQStopTime();