comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoad.java @ 4370:6a65e7ef43c0

Updated data object and factory for sediment load. * Added new data fields to object and cache key. * Fixed SQL statement in factory and fill load objects correctly. *
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 02 Nov 2012 14:48:16 +0100
parents 3051bc28ac43
children 3937c6a85db4
comparison
equal deleted inserted replaced
4369:8ddab49ff297 4370:6a65e7ef43c0
1 package de.intevation.flys.artifacts.model.minfo; 1 package de.intevation.flys.artifacts.model.minfo;
2 2
3 import gnu.trove.TDoubleArrayList; 3 import gnu.trove.TDoubleArrayList;
4 import gnu.trove.TDoubleByteHashMap;
5 import gnu.trove.TDoubleHash;
6 import gnu.trove.TDoubleHashSet;
4 7
5 import java.util.Date; 8 import java.util.Date;
9 import java.util.HashMap;
10 import java.util.Set;
6 11
7 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
8 13
9 import de.intevation.flys.artifacts.model.NamedObjectImpl; 14 import de.intevation.flys.artifacts.model.NamedObjectImpl;
10 15
17 protected String description; 22 protected String description;
18 protected Date start; 23 protected Date start;
19 protected Date end; 24 protected Date end;
20 protected boolean isEpoch; 25 protected boolean isEpoch;
21 26
22 protected TDoubleArrayList sand_values; 27 protected HashMap<Double, SedimentLoadFraction> kms;
23 protected TDoubleArrayList fine_middle_values;
24 protected TDoubleArrayList coarse_values;
25 protected TDoubleArrayList susp_sediment_values;
26 protected TDoubleArrayList susp_sand_bed_values;
27
28 28
29 public SedimentLoad() { 29 public SedimentLoad() {
30 kms = new HashMap<Double, SedimentLoadFraction>();
30 } 31 }
31 32
32 public SedimentLoad( 33 public SedimentLoad(
33 String description, 34 String description,
34 Date start, 35 Date start,
35 Date end, 36 Date end,
36 boolean isEpoch 37 boolean isEpoch
37 ) { 38 ) {
39 this();
38 this.description = description; 40 this.description = description;
39 this.start = start; 41 this.start = start;
40 this.end = end; 42 this.end = end;
41 this.isEpoch = isEpoch; 43 this.isEpoch = isEpoch;
42 } 44 }
71 73
72 public void setEpoch(boolean isEpoch) { 74 public void setEpoch(boolean isEpoch) {
73 this.isEpoch = isEpoch; 75 this.isEpoch = isEpoch;
74 } 76 }
75 77
76 public void addSandValue(double value) { 78 public Set<Double> getKms() {
77 this.sand_values.add(value); 79 return kms.keySet();
78 } 80 }
79 81
80 public void addSandValues(TDoubleArrayList values) { 82 public void addKm(double km, SedimentLoadFraction fraction) {
81 this.sand_values.add(values.toNativeArray()); 83 kms.put(km, fraction);
82 } 84 }
83 85
84 public TDoubleArrayList getSandValues() { 86 public SedimentLoadFraction getFraction(double km) {
85 return this.sand_values; 87 if (kms.get(km) == null) {
88 return new SedimentLoadFraction();
89 }
90 return kms.get(km);
86 } 91 }
87 92
88 public void addFineMiddleValue(double value) { 93 public void setCoarse(double km, double coarse) {
89 this.fine_middle_values.add(value); 94 if (kms.containsKey(km)) {
95 kms.get(km).setCoarse(coarse);
96 }
97 else {
98 SedimentLoadFraction f = new SedimentLoadFraction();
99 f.setCoarse(coarse);
100 kms.put(km, f);
101 }
90 } 102 }
91 103
92 public void addFineMiddleValues(TDoubleArrayList values) { 104 public void setFineMiddle(double km, double fine_middle) {
93 this.fine_middle_values.add(values.toNativeArray()); 105 if (kms.containsKey(km)) {
106 kms.get(km).setFine_middle(fine_middle);
107 }
108 else {
109 SedimentLoadFraction f = new SedimentLoadFraction();
110 f.setFine_middle(fine_middle);
111 kms.put(km, f);
112 }
94 } 113 }
95 114
96 public TDoubleArrayList getFineMiddleValues() { 115 public void setSand(double km, double sand) {
97 return this.fine_middle_values; 116 if (kms.containsKey(km)) {
117 kms.get(km).setSand(sand);
118 }
119 else {
120 SedimentLoadFraction f = new SedimentLoadFraction();
121 f.setSand(sand);
122 kms.put(km, f);
123 }
98 } 124 }
99 125
100 public void addCoarseValue(double value) { 126 public void setSuspSand(double km, double susp_sand) {
101 this.coarse_values.add(value); 127 if (kms.containsKey(km)) {
128 kms.get(km).setSusp_sand(susp_sand);
129 }
130 else {
131 SedimentLoadFraction f = new SedimentLoadFraction();
132 f.setSusp_sand(susp_sand);
133 kms.put(km, f);
134 }
102 } 135 }
103 136
104 public void addCoarseValues(TDoubleArrayList values) { 137 public void setSuspSandBed(double km, double susp_sand_bed) {
105 this.coarse_values.add(values.toNativeArray()); 138 if (kms.containsKey(km)) {
139 kms.get(km).setSusp_sand_bed(susp_sand_bed);
140 }
141 else {
142 SedimentLoadFraction f = new SedimentLoadFraction();
143 f.setSusp_sand_bed(susp_sand_bed);
144 kms.put(km, f);
145 }
106 } 146 }
107 147
108 public TDoubleArrayList getCoarseValues() { 148 public void setSuspSediment(double km, double susp_sediment) {
109 return this.coarse_values; 149 if (kms.containsKey(km)) {
150 kms.get(km).setSusp_sediment(susp_sediment);
151 }
152 else {
153 SedimentLoadFraction f = new SedimentLoadFraction();
154 f.setSusp_sediment(susp_sediment);
155 kms.put(km, f);
156 }
110 } 157 }
111 158
112 public void addSuspSedimentValue(double value) { 159 public void setTotal(double km, double total) {
113 this.susp_sediment_values.add(value); 160 if (kms.containsKey(km)) {
114 } 161 kms.get(km).setTotal(total);
115 162 }
116 public void addSuspSedimentValues(TDoubleArrayList values) { 163 else {
117 this.susp_sediment_values.add(values.toNativeArray()); 164 SedimentLoadFraction f = new SedimentLoadFraction();
118 } 165 f.setTotal(total);
119 166 kms.put(km, f);
120 public TDoubleArrayList getSuspSedimentValues() { 167 }
121 return this.susp_sediment_values;
122 }
123
124 public void addSuspSandBedValue(double value) {
125 this.susp_sand_bed_values.add(value);
126 }
127
128 public void addSuspSandBedValues(TDoubleArrayList values) {
129 this.susp_sand_bed_values.add(values.toNativeArray());
130 }
131
132 public TDoubleArrayList getSuspSandBedValues() {
133 return this.susp_sand_bed_values;
134 } 168 }
135 } 169 }

http://dive4elements.wald.intevation.org