Mercurial > dive4elements > river
changeset 71:987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
flys-client/trunk@1573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 25 Mar 2011 11:51:54 +0000 |
parents | 493efc8e4e28 |
children | 9b726350ab07 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/CreateCollectionService.java flys-client/src/main/java/de/intevation/flys/client/client/services/CreateCollectionServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java |
diffstat | 5 files changed, 80 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Mar 25 11:41:55 2011 +0000 +++ b/flys-client/ChangeLog Fri Mar 25 11:51:54 2011 +0000 @@ -1,3 +1,17 @@ +2011-03-25 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/services/CreateCollectionService.java, + src/main/java/de/intevation/flys/client/client/services/CreateCollectionServiceAsync.java, + src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java: + Changed the return type to 'Collection' - returned a UUID (String) + before. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + The artifact is put into the collection (or new collection) if we reach + a step in the parameterization in that an artifact has reachable + outputs. Furthermore, some adjustments related to the changes of the + return type in the CreateCollectionService. + 2011-03-25 Ingo Weinzierl <ingo@intevation.de> * src/main/webapp/WEB-INF/web.xml: Made the AddArtifactService accessible.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/CreateCollectionService.java Fri Mar 25 11:41:55 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/CreateCollectionService.java Fri Mar 25 11:51:54 2011 +0000 @@ -3,6 +3,8 @@ import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; +import de.intevation.flys.client.shared.model.Collection; + /** * This interface describes the service for creating new collections. @@ -18,6 +20,6 @@ * * @return the uuid of the created collection. */ - String create(String serverUrl, String ownerId); + Collection create(String serverUrl, String ownerId); } // 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/CreateCollectionServiceAsync.java Fri Mar 25 11:41:55 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/CreateCollectionServiceAsync.java Fri Mar 25 11:51:54 2011 +0000 @@ -2,6 +2,8 @@ import com.google.gwt.user.client.rpc.AsyncCallback; +import de.intevation.flys.client.shared.model.Collection; + /** * This interface describes the service for creating new collections. @@ -10,6 +12,9 @@ */ public interface CreateCollectionServiceAsync { - void create(String serverUrl, String owner, AsyncCallback<String> callback); + void create( + String serverUrl, + String owner, + AsyncCallback<Collection> callback); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Fri Mar 25 11:41:55 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Fri Mar 25 11:51:54 2011 +0000 @@ -22,7 +22,9 @@ import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.River; +import de.intevation.flys.client.shared.model.User; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYS; @@ -39,6 +41,8 @@ import de.intevation.flys.client.client.event.StepBackHandler; import de.intevation.flys.client.client.event.StepForwardEvent; import de.intevation.flys.client.client.event.StepForwardHandler; +import de.intevation.flys.client.client.services.AddArtifactService; +import de.intevation.flys.client.client.services.AddArtifactServiceAsync; import de.intevation.flys.client.client.services.AdvanceService; import de.intevation.flys.client.client.services.AdvanceServiceAsync; import de.intevation.flys.client.client.services.ArtifactService; @@ -75,6 +79,10 @@ protected CreateCollectionServiceAsync createCollectionService = GWT.create(CreateCollectionService.class); + /** The AddArtifactService used to add an artifact to a collection. */ + protected AddArtifactServiceAsync addArtifactService = + GWT.create(AddArtifactService.class); + /** The message class that provides i18n strings.*/ FLYSMessages messages = GWT.create(FLYSMessages.class); @@ -166,20 +174,34 @@ * @param ownerId The uuid of the user that should own the new collection. */ protected void createNewCollection(String ownerId) { - Config config = Config.getInstance(); - String serverUrl = config.getServerUrl(); + Config config = Config.getInstance(); + final String serverUrl = config.getServerUrl(); createCollectionService.create( serverUrl, ownerId, - new AsyncCallback<String>() { + new AsyncCallback<Collection>() { public void onFailure(Throwable caught) { GWT.log("Could not create the new collection."); GWT.log(caught.getMessage()); } - public void onSuccess(String uuid) { + public void onSuccess(Collection collection) { GWT.log("Successfully created a new collection."); - GWT.log("NEW collection uuid: " + uuid); + + Artifact artifact = getArtifact(); + addArtifactService.add(collection, artifact, serverUrl, + new AsyncCallback<Collection>() { + + public void onFailure(Throwable caught) { + GWT.log("An error occured while adding artifact."); + } + + public void onSuccess(Collection newCollection) { + GWT.log("Successfully added artifact."); + setCollection(newCollection); + } + } + ); } }); } @@ -246,7 +268,7 @@ * @return true, if the Collection is new. */ public boolean isNew() { - return collection.getArtifactLength() == 0 ? true : false; + return collection.getItemLength() == 0 ? true : false; } @@ -323,6 +345,16 @@ /** + * Returns the artifact that is used for the parameterization. + * + * @return the artifact that is used for the parameterization. + */ + protected Artifact getArtifact() { + return artifact; + } + + + /** * Set the current artifact that is the master of the parameterization. * * @param artifact The new artifact. @@ -342,8 +374,17 @@ * @param event The ParameterChangeEvent. */ public void onParameterChange(ParameterChangeEvent event) { + Artifact art = event.getNewValue(); + ArtifactDescription desc = art.getArtifactDescription(); + OutputMode[] outs = desc.getOutputModes(); - updateView(); + if (outs != null) { + User user = getFlys().getCurrentUser(); + createNewCollection(user.identifier()); + } + else { + updateView(); + } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Fri Mar 25 11:41:55 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java Fri Mar 25 11:51:54 2011 +0000 @@ -2,7 +2,6 @@ import org.w3c.dom.Document; -import com.google.gwt.core.client.GWT; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import de.intevation.artifacts.common.ArtifactNamespaceContext; @@ -14,6 +13,8 @@ import de.intevation.artifacts.httpclient.http.HttpClientImpl; import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; +import de.intevation.flys.client.shared.model.Collection; +import de.intevation.flys.client.shared.model.DefaultCollection; import de.intevation.flys.client.client.services.CreateCollectionService; @@ -32,18 +33,21 @@ "/art:result/art:artifact-collection/@art:uuid"; - public String create(String serverUrl, String ownerId) { - GWT.log("Start creating a new collection."); + public Collection create(String serverUrl, String ownerId) { + System.out.println("Start creating a new collection."); - Document create = ClientProtocolUtils.newCreateDocument(null); + Document create = + ClientProtocolUtils.newCreateCollectionDocument(null); HttpClient client = new HttpClientImpl(serverUrl); try { Document doc = (Document) client.createCollection( create, ownerId, new DocumentResponseHandler()); - return XMLUtils.xpathString( + String uuid = XMLUtils.xpathString( doc, XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE); + + return new DefaultCollection(uuid); } catch (ConnectionException ce) { System.err.println(ce.getLocalizedMessage());