comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/StaticWQKmsState.java @ 7653:e609722a1e86

issue1020 and others: Let StaticWQKmsState spawn other facets, implement computeAdvance.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 05 Dec 2013 17:38:10 +0100
parents c7638c971574
children 5484818087de
comparison
equal deleted inserted replaced
7652:974c858a5042 7653:e609722a1e86
21 21
22 import org.dive4elements.river.artifacts.D4EArtifact; 22 import org.dive4elements.river.artifacts.D4EArtifact;
23 import org.dive4elements.river.artifacts.StaticWQKmsArtifact; 23 import org.dive4elements.river.artifacts.StaticWQKmsArtifact;
24 24
25 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet; 25 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet;
26 import org.dive4elements.river.artifacts.model.DataFacet;
26 import org.dive4elements.river.artifacts.model.FacetTypes; 27 import org.dive4elements.river.artifacts.model.FacetTypes;
27 import org.dive4elements.river.artifacts.model.RelativePointFacet; 28 import org.dive4elements.river.artifacts.model.RelativePointFacet;
28 import org.dive4elements.river.artifacts.model.WQKms; 29 import org.dive4elements.river.artifacts.model.WQKms;
29 import org.dive4elements.river.artifacts.model.WQKmsFacet; 30 import org.dive4elements.river.artifacts.model.WQKmsFacet;
30 31
57 String hash, 58 String hash,
58 List<Facet> facets, 59 List<Facet> facets,
59 Object old 60 Object old
60 ) { 61 ) {
61 String id = getID(); 62 String id = getID();
62 63 String code = artifact.getDataAsString("ids");
64 String [] parts = code.split("-");
65
66 // Return from cache, if present.
63 WQKms res = old instanceof WQKms 67 WQKms res = old instanceof WQKms
64 ? (WQKms)old 68 ? (WQKms)old
65 : artifact.getWQKms(); 69 : artifact.getWQKms();
66 70
67 WQKms wqkms = res; 71 WQKms wqkms = res;
68 72
69 if (facets == null) { 73 if (facets == null) {
74 return res;
75 }
76
77 String wkmsName = wqkms.getName();
78
79 Facet wqfacet = new WQKmsFacet(
80 STATIC_WQ,
81 wkmsName);
82 facets.add(wqfacet);
83
84 if (parts[0].equals("officials_wq")) {
85 // Early stop. We only want wq-points in that case.
70 return res; 86 return res;
71 } 87 }
72 88
73 /* 89 /*
74 * TODO: re-enable HEIGHTMARKS_POINTS-thing 90 * TODO: re-enable HEIGHTMARKS_POINTS-thing
90 qEmpty = false; 106 qEmpty = false;
91 break; 107 break;
92 } 108 }
93 } 109 }
94 110
95 String wkmsName = wqkms.getName(); 111 // issue1494: Only spawn qfacet if discharges are given
96 if (!qEmpty) { 112 if (!qEmpty) {
97 Facet qfacet = new WQKmsFacet( 113 Facet qfacet = new WQKmsFacet(
98 STATIC_WQKMS_Q, 114 STATIC_WQKMS_Q,
99 wkmsName 115 wkmsName
100 // TODO re-enable translations. 116 // TODO re-enable translations.
107 } 123 }
108 124
109 Facet rpFacet = new RelativePointFacet(wkmsName); 125 Facet rpFacet = new RelativePointFacet(wkmsName);
110 facets.add(rpFacet); 126 facets.add(rpFacet);
111 127
112 wkmsName = "W (" + wkmsName + ")";
113
114 Facet csFacet = new CrossSectionWaterLineFacet(0, 128 Facet csFacet = new CrossSectionWaterLineFacet(0,
115 wkmsName); 129 wkmsName);
116 facets.add(csFacet); 130 facets.add(csFacet);
131
132 wkmsName = "W (" + wkmsName + ")";
117 133
118 Facet wfacet = new WQKmsFacet( 134 Facet wfacet = new WQKmsFacet(
119 STATIC_WQKMS_W, 135 STATIC_WQKMS_W,
120 wkmsName 136 wkmsName
121 /* 137 /*
124 metaLocale, 140 metaLocale,
125 wkmsName, 141 wkmsName,
126 wkmsName)*/); 142 wkmsName)*/);
127 facets.add(wfacet); 143 facets.add(wfacet);
128 144
145 Facet wstfacet = new DataFacet(
146 WST,
147 wkmsName,
148 ComputeType.ADVANCE, hash, id);
149 facets.add(wstfacet);
150
129 return res; 151 return res;
130 } 152 }
131 153
154 @Override
155 public Object computeAdvance(
156 D4EArtifact artifact,
157 String hash,
158 CallContext context,
159 List<Facet> facets,
160 Object old
161 ) {
162 return compute((StaticWQKmsArtifact) artifact, context.getMeta(),
163 hash, facets, old);
164 }
132 165
133 /** 166 /**
134 * Get data, create the facets. 167 * Get data, create the facets.
135 * 168 *
136 * @param context Ignored. 169 * @param context Ignored.
158 String hash, 191 String hash,
159 Object context, 192 Object context,
160 CallMeta meta, 193 CallMeta meta,
161 List<Facet> facets 194 List<Facet> facets
162 ) { 195 ) {
163 return compute((StaticWQKmsArtifact) artifact, meta, hash, facets, 196 return compute((StaticWQKmsArtifact) artifact, meta,
164 null); 197 hash, facets, null);
165 } 198 }
166 } 199 }
167 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 200 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org