Mercurial > dive4elements > river
changeset 1518:e8706fec0ee9
Added feedMany() implementation to feed-service.
flys-client/trunk@3671 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 13 Jan 2012 09:50:39 +0000 |
parents | a9388fba0b46 |
children | a6f6c61b18be |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/FeedService.java flys-client/src/main/java/de/intevation/flys/client/client/services/FeedServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java |
diffstat | 4 files changed, 85 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Jan 13 09:47:27 2012 +0000 +++ b/flys-client/ChangeLog Fri Jan 13 09:50:39 2012 +0000 @@ -1,3 +1,14 @@ +2012-01-13 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Added feedMany() function to FeedService to feed multiple artifacts + at once. + + * src/main/java/de/intevation/flys/client/client/services/FeedService.java, + src/main/java/de/intevation/flys/client/client/services/FeedServiceAsync.java, + src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java: + (feedMany): New. Still issue single feeds per artifact but with only + one async callback. + 2012-01-13 Felix Wolfsteller <felix.wolfsteller@intevation.de> Cosmetics.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/FeedService.java Fri Jan 13 09:47:27 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/FeedService.java Fri Jan 13 09:50:39 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.client.services; +import java.util.List; + import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -27,5 +29,21 @@ Artifact artifact, Data[] data) throws ServerException; + + + /** + * Inserts (the same) new data into existing artifacts. + * + * @param locale The locale used for the request. + * @param artifact The artifact. + * @param data The data that should be inserted. + * + * @return the artifact which description might have been changed. + */ + public List<Artifact> feedMany( + String locale, + List<Artifact> artifacts, + Data[] data) + throws ServerException; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/FeedServiceAsync.java Fri Jan 13 09:47:27 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/FeedServiceAsync.java Fri Jan 13 09:50:39 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.client.client.services; +import java.util.List; + import com.google.gwt.user.client.rpc.AsyncCallback; import de.intevation.flys.client.shared.model.Artifact; @@ -11,10 +13,30 @@ */ public interface FeedServiceAsync { + /** + * Inserts new data into an existing artifact. + * + * @param locale The locale used for the request. + * @param artifact The artifact. + * @param data The data that should be inserted. + */ public void feed( String locale, Artifact artifact, Data[] data, AsyncCallback<Artifact> callback); + + /** + * Inserts (the same) new data into existing artifacts. + * + * @param locale The locale used for the request. + * @param artifact The artifact. + * @param data The data that should be inserted. + */ + public void feedMany( + String locale, + List<Artifact> artifacts, + Data[] data, + AsyncCallback<List<Artifact>> callback); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java Fri Jan 13 09:47:27 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java Fri Jan 13 09:50:39 2012 +0000 @@ -1,5 +1,8 @@ package de.intevation.flys.client.server; +import java.util.ArrayList; +import java.util.List; + import org.w3c.dom.Document; import org.apache.log4j.Logger; @@ -112,6 +115,37 @@ /** + * Triggers FEED operation, many artifacts, same data item(s). + * + * @param artifacts Artifacts that shall be fed. + * @param data An array of Data objects that contain the information that + * are used for the FEED operation. + * + * @return a new artifact parsed from the description of FEED. + */ + public List<Artifact> feedMany( + String locale, + List<Artifact> artifacts, + Data[] data) + throws ServerException + { + logger.info("StepForwardServiceImpl.feedMany"); + + String url = getServletContext().getInitParameter("server-url"); + + List<Artifact> resultArtifacts = new ArrayList<Artifact>(); + + for (Artifact artifact: artifacts) { + logger.info("feedMany: Relay to StepForwardServiceImpl.feed"); + Artifact fedArtifact = feed(locale, artifact, data); + resultArtifacts.add(fedArtifact); + } + + return resultArtifacts; + } + + + /** * This method creates an array of key/value pairs from an array of Data * objects. The string array is used as parameter for the feed() operation. *