# HG changeset patch # User Ingo Weinzierl # Date 1316104027 0 # Node ID 7f72239e56c8e646eab3f8614a95e937f9e6e5a1 # Parent 794d1af42987d7202e1f86b4851797bc887fbf99 #259 Use the LoadArtifactService to clone Artifacts and add them to the current Collection. flys-client/trunk@2767 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 794d1af42987 -r 7f72239e56c8 flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Sep 15 16:02:23 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 15 16:27:07 2011 +0000 @@ -1,3 +1,12 @@ +2011-09-15 Ingo Weinzierl + + flys/issue259 (Daten aus Datenkorb in Diagramm einladen) + + * src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java: + Don't abuse the mechanism to load recommendations any longer. Selected + Facets/Artifacts in this Window are cloned and loaded into the current + Collection using the LoadArtifactService. + 2011-09-15 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/ui/UIProvider.java: diff -r 794d1af42987 -r 7f72239e56c8 flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Thu Sep 15 16:02:23 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWindow.java Thu Sep 15 16:27:07 2011 +0000 @@ -1,15 +1,22 @@ package de.intevation.flys.client.client.ui; import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Window; +import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.DatacageHandler; +import de.intevation.flys.client.client.services.LoadArtifactService; +import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; + import de.intevation.flys.client.shared.model.Artifact; import de.intevation.flys.client.shared.model.ArtifactDescription; +import de.intevation.flys.client.shared.model.Collection; import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; @@ -27,6 +34,9 @@ protected FLYSConstants messages = GWT.create(FLYSConstants.class); + protected LoadArtifactServiceAsync loadService = + GWT.create(LoadArtifactService.class); + protected CollectionView view; public DatacageWindow( @@ -60,8 +70,7 @@ public void toLoad(ToLoad toLoad) { destroy(); List recs = toLoad.toRecommendations(); - view.loadRecommendedArtifacts( - recs.toArray(new Recommendation[recs.size()])); + loadArtifacts(recs.toArray(new Recommendation[recs.size()])); } @@ -86,5 +95,43 @@ return ""; } + + + protected void loadArtifacts(Recommendation[] recommendations) { + Config cfg = Config.getInstance(); + + final Collection collection = view.getCollection(); + final Artifact masterArtifact = view.getArtifact(); + final String serverUrl = cfg.getServerUrl(); + final String locale = cfg.getLocale(); + + for (final Recommendation recommendation: recommendations) { + // XXX: UGLY! If no reference artifact given use uuid of + // current artifact as reference. + if (recommendation.getMasterArtifact() == null) { + recommendation.setMasterArtifact(masterArtifact.getUuid()); + } + + final String factory = recommendation.getFactory(); + + GWT.log("Load new artifact with factory: " + factory); + + loadService.load( + collection, + recommendation, + factory, + serverUrl, + locale, + new AsyncCallback() { + public void onFailure(Throwable caught) { + SC.warn(caught.getMessage()); + } + + public void onSuccess(Artifact artifact) { + GWT.log("Created new artifact: " + artifact.getUuid()); + } + }); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :