comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 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 25c3a62863d2
children 61fd22f65bd4
comparison
equal deleted inserted replaced
8238:be3c11bef6e8 8239:b207eeb66edd
121 121
122 public static class Load implements Serializable { 122 public static class Load implements Serializable {
123 123
124 private int id; 124 private int id;
125 private int kind; 125 private int kind;
126 private int sqTiId; 126 private Integer sqTiId;
127 127
128 private String description; 128 private String description;
129 129
130 private Date startTime; 130 private Date startTime;
131 private Date stopTime; 131 private Date stopTime;
150 this.description = description; 150 this.description = description;
151 this.startTime = startTime; 151 this.startTime = startTime;
152 this.stopTime = stopTime; 152 this.stopTime = stopTime;
153 this.sqStartTime = sqStartTime; 153 this.sqStartTime = sqStartTime;
154 this.sqStopTime = sqStopTime; 154 this.sqStopTime = sqStopTime;
155 this.sqTiId = sqTiId == null ? 0 : sqTiId; 155 this.sqTiId = sqTiId;
156 } 156 }
157 157
158 public int getId() { 158 public int getId() {
159 return id; 159 return id;
160 } 160 }
161 161
162 public int getSQRelationTimeIntervalId() { 162 public Integer getSQRelationTimeIntervalId() {
163 return sqTiId; 163 return sqTiId;
164 } 164 }
165 165
166 public int getKind() { 166 public int getKind() {
167 return kind; 167 return kind;
435 }; 435 };
436 436
437 public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() { 437 public static final Comparator<Load> LOAD_SQ_TI_CMP = new Comparator<Load>() {
438 @Override 438 @Override
439 public int compare(Load a, Load b) { 439 public int compare(Load a, Load b) {
440 return a.getSQRelationTimeIntervalId() - b.getSQRelationTimeIntervalId(); 440 Integer a_id = a.getSQRelationTimeIntervalId();
441 Integer b_id = b.getSQRelationTimeIntervalId();
442 if (a_id == null && b_id == null) {
443 return 0;
444 }
445 if (a_id == null) {
446 return -1;
447 }
448 if (b_id == null) {
449 return 1;
450 }
451 return a_id - b_id;
441 } 452 }
442 }; 453 };
443 454
444 public static final Comparator<Load> LOAD_ID_SQ_TI_CMP = new Comparator<Load>() {
445 @Override
446 public int compare(Load a, Load b) {
447 return LOAD_ID_CMP.compare(a, b) + LOAD_SQ_TI_CMP.compare(a,b);
448 }
449 };
450
451 /** Find all loads in the range a/b with the according sq_time_interval */ 455 /** Find all loads in the range a/b with the according sq_time_interval */
452 public Collection<Load> findLoads(double a, double b, int sqRelationTimeInterval) { 456 public Collection<Load> findLoads(double a, double b, Integer sqRelationTimeInterval) {
453 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_SQ_TI_CMP); 457 final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
454 458
455 findStations(a, b, new Visitor() { 459 findStations(a, b, new Visitor() {
456 @Override 460 @Override
457 public void visit(Station station) { 461 public void visit(Station station) {
458 station.allLoads(loads); 462 station.allLoads(loads);

http://dive4elements.wald.intevation.org