[PATCH 2 of 6] issue1020: Let WspDatacagePanel also handle non-winfo (prev. calc) rec
Wald Commits
scm-commit at wald.intevation.org
Thu Nov 14 12:14:53 CET 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1384426442 -3600
# Node ID f4c13fbde072dbff4e4e2bed0319e6486319c114
# Parent 3cbf8bab1a0fbdbc8ba25ffadffa436f0a11f95e
issue1020: Let WspDatacagePanel also handle non-winfo (prev. calc) rec.
diff -r 3cbf8bab1a0f -r f4c13fbde072 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java Thu Nov 14 06:44:11 2013 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WspDatacagePanel.java Thu Nov 14 11:54:02 2013 +0100
@@ -87,7 +87,7 @@
public void onClick(ClickEvent e) {
List<String> errors = validate();
if (errors == null || errors.isEmpty()) {
- // 1) Fetch selected recommendation
+ // 1) Fetch selected recommendation.
Config config = Config.getInstance();
final String locale = config.getLocale();
final Collection c = this.collection;
@@ -99,9 +99,10 @@
return;
}
- // 2) Create, load Artifact and fire event
+ // TODO: This could eventually be handled server-side.
+ // 2) Create, load Artifact and fire event.
loadService.load(
- c, r, "winfo", locale,
+ c, r, r.getFactory(), locale,
new AsyncCallback<Artifact>() {
@Override
public void onFailure(Throwable caught) {
@@ -110,9 +111,10 @@
}
@Override
- public void onSuccess(Artifact artifact) {
+ public void onSuccess(Artifact newArtifact) {
+ GWT.log("Created new artifact.");
fireStepForwardEvent(new StepForwardEvent(
- getData(r, artifact)));
+ getData(r, newArtifact)));
}
}
);
@@ -149,7 +151,7 @@
String uuid = newArtifact.getUuid();
r.setMasterArtifact(uuid);
- String value = createDataString(uuid, r.getFilter());
+ String value = createDataString(uuid, r);
DataItem item = new DefaultDataItem(dataName, dataName, value);
return new Data[] { new DefaultData(
@@ -157,22 +159,30 @@
}
- protected String createDataString(String artifact, Filter filter) {
+ protected String createDataString(String artifact, Recommendation recommendation) {
Facet f = null;
+
+ // The filter will only be available or previous calculation artifacts.
+ Filter filter = recommendation.getFilter();
- Map<String, List<Facet>> outs = filter.getOuts();
- Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet();
+ if (filter != null) {
+ Map<String, List<Facet>> outs = filter.getOuts();
+ Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet();
- for (Map.Entry<String, List<Facet>> entry: entries) {
- List<Facet> fs = entry.getValue();
+ for (Map.Entry<String, List<Facet>> entry: entries) {
+ List<Facet> fs = entry.getValue();
- f = fs.get(0);
- if (f != null) {
- break;
+ f = fs.get(0);
+ if (f != null) {
+ break;
+ }
}
+
+ return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]";
}
-
- return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]";
+ else {
+ return "[" + artifact + ";" + recommendation.getFactory() + ";" + 0 + "]";
+ }
}
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list