comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java @ 8146:ce35bdf3d750

Let the facet know the period of it's data.
author Tom Gottfried <tom@intevation.de>
date Wed, 27 Aug 2014 15:09:45 +0200
parents d4e4dde1d5cb
children f2bbe09e516e
comparison
equal deleted inserted replaced
8145:52504fc2cd58 8146:ce35bdf3d750
47 47
48 private static final String BASE_NAME = "sedimentload"; 48 private static final String BASE_NAME = "sedimentload";
49 49
50 public String fraction; 50 public String fraction;
51 51
52 public String period;
53
52 public SedimentLoadDataFacet() { 54 public SedimentLoadDataFacet() {
53 } 55 }
54 56
55 public SedimentLoadDataFacet(int idx, String fraction_name, String unit, 57 public SedimentLoadDataFacet(int idx, String fraction_name, String unit,
58 String periodString,
56 ComputeType type, String stateId, String hash, CallContext context) { 59 ComputeType type, String stateId, String hash, CallContext context) {
57 super(idx, /*name*/"", ""/*description*/, type, hash, stateId); 60 super(idx, /*name*/"", ""/*description*/, type, hash, stateId);
58 61
59 this.fraction = fraction_name; 62 this.fraction = fraction_name;
63 this.period = periodString;
60 64
61 String typeUnit; /* Gnah someone should unify unit strings,... */ 65 String typeUnit; /* Gnah someone should unify unit strings,... */
62 String i18nUnit; 66 String i18nUnit;
63 if (unit != null && unit.equals("m3/a")) { 67 if (unit != null && unit.equals("m3/a")) {
64 typeUnit = "m3a"; 68 typeUnit = "m3a";
78 fraction_name.equals("suspended_load") ? "calc." : ""; 82 fraction_name.equals("suspended_load") ? "calc." : "";
79 description = Resources.getMsg( 83 description = Resources.getMsg(
80 meta, 84 meta,
81 "facet.sedimentload." + isCalculated + fraction_name, 85 "facet.sedimentload." + isCalculated + fraction_name,
82 "Error: please add l10n for facet.sedimentload." + fraction_name, 86 "Error: please add l10n for facet.sedimentload." + fraction_name,
83 /* TODO handle multiple periods per fraction */ 87 new Object[] { periodString, i18nUnit });
84 new Object[] { "period", i18nUnit });
85 88
86 /* Is this necessary? */ 89 /* Is this necessary? */
87 metaData.put("X", "chart.longitudinal.section.xaxis.label"); 90 metaData.put("X", "chart.longitudinal.section.xaxis.label");
88 metaData.put("Y", ""); 91 metaData.put("Y", "");
89 } 92 }
101 logger.error("Invalid result!"); 104 logger.error("Invalid result!");
102 } 105 }
103 106
104 SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload; 107 SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload;
105 108
106 List<Fraction> fractions = sdResult.getFractionsByName(fraction); 109 List<Fraction> fractions = sdResult.getFractionsByNameAndPeriod(
110 fraction, period
111 );
107 if (fractions == null) { 112 if (fractions == null) {
108 logger.warn("No result for: " + fraction); 113 logger.warn("No result for fraction '" + fraction +
114 "' and period '" + period + "'");
109 return null; 115 return null;
110 } 116 }
111 117
112 /* TODO handle multiple periods per fraction */
113 if (fractions.size() > 1) { 118 if (fractions.size() > 1) {
114 logger.warn("Multiple periods not implemented."); 119 logger.error("Multiple results for fraction '" + fraction +
120 "' and period '" + period + "'");
115 } 121 }
116 122
117 return fractions.get(0).getData(); 123 return fractions.get(0).getData();
118 124
119 /* Are gaps neccessary now? 125 /* Are gaps neccessary now?

http://dive4elements.wald.intevation.org