Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java @ 7570:f4c13fbde072
issue1020: Let WspDatacagePanel also handle non-winfo (prev. calc) rec.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 14 Nov 2013 11:54:02 +0100 |
parents | 663c159f3b43 |
children | 2e30d2c725fa |
comparison
equal
deleted
inserted
replaced
7569:3cbf8bab1a0f | 7570:f4c13fbde072 |
---|---|
85 */ | 85 */ |
86 @Override | 86 @Override |
87 public void onClick(ClickEvent e) { | 87 public void onClick(ClickEvent e) { |
88 List<String> errors = validate(); | 88 List<String> errors = validate(); |
89 if (errors == null || errors.isEmpty()) { | 89 if (errors == null || errors.isEmpty()) { |
90 // 1) Fetch selected recommendation | 90 // 1) Fetch selected recommendation. |
91 Config config = Config.getInstance(); | 91 Config config = Config.getInstance(); |
92 final String locale = config.getLocale(); | 92 final String locale = config.getLocale(); |
93 final Collection c = this.collection; | 93 final Collection c = this.collection; |
94 final Recommendation r = getSelectedRecommendation(); | 94 final Recommendation r = getSelectedRecommendation(); |
95 | 95 |
97 if (r == null) { | 97 if (r == null) { |
98 SC.warn(MSG.warning_no_wsp_selected()); | 98 SC.warn(MSG.warning_no_wsp_selected()); |
99 return; | 99 return; |
100 } | 100 } |
101 | 101 |
102 // 2) Create, load Artifact and fire event | 102 // TODO: This could eventually be handled server-side. |
103 // 2) Create, load Artifact and fire event. | |
103 loadService.load( | 104 loadService.load( |
104 c, r, "winfo", locale, | 105 c, r, r.getFactory(), locale, |
105 new AsyncCallback<Artifact>() { | 106 new AsyncCallback<Artifact>() { |
106 @Override | 107 @Override |
107 public void onFailure(Throwable caught) { | 108 public void onFailure(Throwable caught) { |
108 GWT.log("WspDatacagePanel", caught); | 109 GWT.log("WspDatacagePanel", caught); |
109 SC.warn(FLYS.getExceptionString(MSG, caught)); | 110 SC.warn(FLYS.getExceptionString(MSG, caught)); |
110 } | 111 } |
111 | 112 |
112 @Override | 113 @Override |
113 public void onSuccess(Artifact artifact) { | 114 public void onSuccess(Artifact newArtifact) { |
115 GWT.log("Created new artifact."); | |
114 fireStepForwardEvent(new StepForwardEvent( | 116 fireStepForwardEvent(new StepForwardEvent( |
115 getData(r, artifact))); | 117 getData(r, newArtifact))); |
116 } | 118 } |
117 } | 119 } |
118 ); | 120 ); |
119 } | 121 } |
120 else { | 122 else { |
147 /** Returns a Data Array with one default item. */ | 149 /** Returns a Data Array with one default item. */ |
148 protected Data[] getData(Recommendation r, Artifact newArtifact) { | 150 protected Data[] getData(Recommendation r, Artifact newArtifact) { |
149 String uuid = newArtifact.getUuid(); | 151 String uuid = newArtifact.getUuid(); |
150 r.setMasterArtifact(uuid); | 152 r.setMasterArtifact(uuid); |
151 | 153 |
152 String value = createDataString(uuid, r.getFilter()); | 154 String value = createDataString(uuid, r); |
153 | 155 |
154 DataItem item = new DefaultDataItem(dataName, dataName, value); | 156 DataItem item = new DefaultDataItem(dataName, dataName, value); |
155 return new Data[] { new DefaultData( | 157 return new Data[] { new DefaultData( |
156 dataName, null, null, new DataItem[] { item }) }; | 158 dataName, null, null, new DataItem[] { item }) }; |
157 } | 159 } |
158 | 160 |
159 | 161 |
160 protected String createDataString(String artifact, Filter filter) { | 162 protected String createDataString(String artifact, Recommendation recommendation) { |
161 Facet f = null; | 163 Facet f = null; |
164 | |
165 // The filter will only be available or previous calculation artifacts. | |
166 Filter filter = recommendation.getFilter(); | |
162 | 167 |
163 Map<String, List<Facet>> outs = filter.getOuts(); | 168 if (filter != null) { |
164 Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet(); | 169 Map<String, List<Facet>> outs = filter.getOuts(); |
170 Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet(); | |
165 | 171 |
166 for (Map.Entry<String, List<Facet>> entry: entries) { | 172 for (Map.Entry<String, List<Facet>> entry: entries) { |
167 List<Facet> fs = entry.getValue(); | 173 List<Facet> fs = entry.getValue(); |
168 | 174 |
169 f = fs.get(0); | 175 f = fs.get(0); |
170 if (f != null) { | 176 if (f != null) { |
171 break; | 177 break; |
178 } | |
172 } | 179 } |
180 | |
181 return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; | |
173 } | 182 } |
174 | 183 else { |
175 return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; | 184 return "[" + artifact + ";" + recommendation.getFactory() + ";" + 0 + "]"; |
185 } | |
176 } | 186 } |
177 } | 187 } |
178 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |