Mercurial > dive4elements > river
changeset 845:4db672cdacb2
Added outs/facet filters when creation new artifacts.
flys-client/trunk@2569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 24 Aug 2011 16:06:48 +0000 |
parents | ac70261bb3f8 |
children | e47ef0ca8f33 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactService.java flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java |
diffstat | 8 files changed, 127 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/ChangeLog Wed Aug 24 16:06:48 2011 +0000 @@ -1,3 +1,21 @@ +2011-08-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/client/client/services/ArtifactService.java, + src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java, + src/main/java/de/intevation/flys/client/client/services/ArtifactServiceAsync.java: + Removed the UUID of the master artifact from interface. + Its transported in the recommendation. Set the creation + filter if its set in the recommendation. + + * src/main/java/de/intevation/flys/client/shared/model/Recommendation.java: + Added Filter/Facets. Its merely a copy of CreationFilter + but this cannot be serialized from JS to the RPC side. + + * src/main/java/de/intevation/flys/client/client/FLYS.java, + src/main/java/de/intevation/flys/client/client/ui/ParameterList.java, + src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Adjusted the calls to fulfill the changed interface. + 2011-08-24 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/Recommendation.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Wed Aug 24 16:06:48 2011 +0000 @@ -397,7 +397,7 @@ String url = config.getServerUrl(); String locale = config.getLocale(); - artifactService.create(url, locale, factory, null, null, + artifactService.create(url, locale, factory, null, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Could not create the new artifact.");
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactService.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactService.java Wed Aug 24 16:06:48 2011 +0000 @@ -30,7 +30,6 @@ String serverUrl, String locale, String factory, - String uuid, Recommendation recommendation ) throws ServerException; }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactServiceAsync.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/ArtifactServiceAsync.java Wed Aug 24 16:06:48 2011 +0000 @@ -18,7 +18,6 @@ String serverUrl, String locale, String factory, - String uuid, Recommendation recommendation, AsyncCallback<Artifact> callback); }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Aug 24 16:06:48 2011 +0000 @@ -609,7 +609,6 @@ final String url = config.getServerUrl(); final String locale = config.getLocale(); final Collection collection = getCollection(); - final Artifact master = getArtifact(); if (recommendations == null) { GWT.log("WARNING: Currently no recommendations."); @@ -625,10 +624,8 @@ GWT.log("Load recommended artifact with factory: " + factory); - String uuid = master != null ? master.getUuid() : null; - createArtifactService.create( - url, locale, factory, uuid, recommendation, + url, locale, factory, recommendation, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Error loading recommendations: " +
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Wed Aug 24 16:06:48 2011 +0000 @@ -351,7 +351,7 @@ final Data[] feedData = new Data[] { data[1] }; artifactService.create( - url, locale, module.toLowerCase(), null, null, + url, locale, module.toLowerCase(), null, new AsyncCallback<Artifact>() { public void onFailure(Throwable caught) { GWT.log("Could not create the new artifact.");
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java Wed Aug 24 16:06:48 2011 +0000 @@ -2,10 +2,14 @@ import org.w3c.dom.Document; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.utils.ClientProtocolUtils; +import de.intevation.artifacts.common.utils.CreationFilter; import de.intevation.artifacts.httpclient.exceptions.ConnectionException; import de.intevation.artifacts.httpclient.http.HttpClient; @@ -36,27 +40,30 @@ String serverUrl, String locale, String factory, - String uuid, Recommendation recommendation ) throws ServerException { System.out.println("ArtifactServiceImpl.create"); - Document create = null; + String uuid; + String ids; + CreationFilter filter; - if (uuid != null && uuid.length() > 0) { - String ids = recommendation != null - ? recommendation.getIDs() - : null; - - create = ClientProtocolUtils.newCreateDocument( - factory, uuid, ids); + if (recommendation != null) { + uuid = recommendation.getMasterArtifact(); + ids = recommendation.getIDs(); + filter = convertFilter(recommendation.getFilter()); } else { - create = ClientProtocolUtils.newCreateDocument(factory); + uuid = null; + ids = null; + filter = null; } + Document create = ClientProtocolUtils.newCreateDocument( + factory, uuid, ids, filter); + HttpClient client = new HttpClientImpl(serverUrl, locale); try { @@ -68,5 +75,29 @@ throw new ServerException(ERROR_CREATE_ARTIFACT); } + + public static CreationFilter convertFilter(Recommendation.Filter filter) { + + if (filter == null) { + return null; + } + + CreationFilter cf = new CreationFilter(); + + Map<String, List<Recommendation.Facet>> outs = filter.getOuts(); + + for (Map.Entry<String, List<Recommendation.Facet>> entry: + outs.entrySet()) { + List<Recommendation.Facet> rfs = entry.getValue(); + List<CreationFilter.Facet> cfs = + new ArrayList<CreationFilter.Facet>(rfs.size()); + for (Recommendation.Facet rf: rfs) { + cfs.add(new CreationFilter.Facet(rf.getName(), rf.getIndex())); + } + cf.add(entry.getKey(), cfs); + } + + return cf; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Wed Aug 24 14:31:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Recommendation.java Wed Aug 24 16:06:48 2011 +0000 @@ -1,5 +1,10 @@ package de.intevation.flys.client.shared.model; + +import java.util.List; +import java.util.Map; +import java.util.HashMap; + import java.io.Serializable; /** @@ -7,25 +12,73 @@ */ public class Recommendation implements Serializable { + public static class Facet implements Serializable { + + protected String name; + protected String index; + + public Facet() { + } + + public Facet(String name, String index) { + this.name = name; + this.index = index; + } + + public String getName() { + return name; + } + + public String getIndex() { + return index; + } + } // class Facet + + public static class Filter implements Serializable { + + protected Map<String, List<Facet>> outs; + + public Filter() { + outs = new HashMap<String, List<Facet>>(); + } + + public void add(String out, List<Facet> facets) { + outs.put(out, facets); + } + + public Map<String, List<Facet>> getOuts() { + return outs; + } + } // class Filter + protected String factory; protected String ids; protected String masterArtifact; + protected Filter filter; public Recommendation() { } - public Recommendation(String factory, String ids) { - this.factory = factory; - this.ids = ids; + this(factory, ids, null, null); } + public Recommendation( + String factory, + String ids, + String masterArtifact, + Filter filter + ) { + this.factory = factory; + this.ids = ids; + this.masterArtifact = masterArtifact; + this.filter = filter; + } public String getFactory() { return factory; } - public String getIDs() { return ids; } @@ -37,5 +90,13 @@ public void setMasterArtifact(String masterArtifact) { this.masterArtifact = masterArtifact; } + + public Filter getFilter() { + return filter; + } + + public void setFilter(Filter filter) { + this.filter = filter; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :