# HG changeset patch # User Andre Heinecke # Date 1410198421 -7200 # Node ID b207eeb66edd51864b17f735cef78e85c8b9c86c # Parent be3c11bef6e83589dc686cb57e207ee343ea40e1 (issue1448) Objectify sq_time_interval id. diff -r be3c11bef6e8 -r b207eeb66edd artifacts/src/main/java/org/dive4elements/river/artifacts/access/SedimentLoadAccess.java --- 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; } diff -r be3c11bef6e8 -r b207eeb66edd artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java --- 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_SQ_TI_CMP = new Comparator() { @Override public int compare(Load a, Load b) { - return a.getSQRelationTimeIntervalId() - b.getSQRelationTimeIntervalId(); - } - }; - - public static final Comparator LOAD_ID_SQ_TI_CMP = new Comparator() { - @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 findLoads(double a, double b, int sqRelationTimeInterval) { - final TreeSet loads = new TreeSet(LOAD_ID_SQ_TI_CMP); + public Collection findLoads(double a, double b, Integer sqRelationTimeInterval) { + final TreeSet loads = new TreeSet(LOAD_ID_CMP); findStations(a, b, new Visitor() { @Override diff -r be3c11bef6e8 -r b207eeb66edd artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java --- 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(); diff -r be3c11bef6e8 -r b207eeb66edd artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java --- 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 diff -r be3c11bef6e8 -r b207eeb66edd artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java --- 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 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();