# HG changeset patch # User Felix Wolfsteller # 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 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() { @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; - - Map> outs = filter.getOuts(); - Set>> entries = outs.entrySet(); + + // The filter will only be available or previous calculation artifacts. + Filter filter = recommendation.getFilter(); - for (Map.Entry> entry: entries) { - List fs = entry.getValue(); + if (filter != null) { + Map> outs = filter.getOuts(); + Set>> entries = outs.entrySet(); - f = fs.get(0); - if (f != null) { - break; + for (Map.Entry> entry: entries) { + List fs = entry.getValue(); + + 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 :