Mercurial > dive4elements > river
changeset 909:794d1af42987
Clone Artifacts and add them to the current Collection in the WspDatacagePanel.
flys-client/trunk@2766 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 16:02:23 +0000 (2011-09-15) |
parents | a680ccec5dd6 |
children | 7f72239e56c8 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java flys-client/src/main/java/de/intevation/flys/client/client/ui/WspDatacagePanel.java |
diffstat | 9 files changed, 189 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/ChangeLog Thu Sep 15 16:02:23 2011 +0000 @@ -1,3 +1,27 @@ +2011-09-15 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/UIProvider.java: + Defined a setter method to inject a Collection. + + * src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java: + Added a setter/getter method to inject a Collection. + + * src/main/java/de/intevation/flys/client/client/ui/ParameterList.java: + Inject the current Collection into the UIProvider and add Artifacts that + have been created to the Collection of CollectionView. + + * src/main/java/de/intevation/flys/client/client/ui/WspDatacagePanel.java: + Clone an Artifact that is selected in the datacage widget and add it to + the current Collection. Finally, return its UUID, the name of the facet + and the index. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added new error messages that will be displayed when an error occured + while cloning an Artifact or adding it to a Collection. + 2011-09-15 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Sep 15 16:02:23 2011 +0000 @@ -344,6 +344,8 @@ String error_invalid_double_value(); + String error_load_artifact(); + String bottom_edge(); String top_edge();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Sep 15 16:02:23 2011 +0000 @@ -178,6 +178,8 @@ error_no_meta_data_found = No meta data found. +error_load_artifact = Error while adding data to the current project. + ## map related strings digitize = images/digitize.png pipe1 = Pipe1
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Sep 15 16:02:23 2011 +0000 @@ -179,6 +179,8 @@ error_no_meta_data_found = Keine Meta-Daten gefunden. +error_load_artifact = Fehler beim Hinzu\u00fcgen neuer Daten in das aktuelle Projekt. + ## map related strings digitize = images/digitize.png pipe1 = Rohr1
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Sep 15 16:02:23 2011 +0000 @@ -173,6 +173,8 @@ error_no_meta_data_found = No meta data found. +error_load_artifact = Error while adding data to the current project. + ## map related strings digitize = images/digitize.png pipe1 = Pipe1
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AbstractUIProvider.java Thu Sep 15 16:02:23 2011 +0000 @@ -20,11 +20,12 @@ 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.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; -import de.intevation.flys.client.shared.model.Artifact; -import de.intevation.flys.client.shared.model.ArtifactDescription; /** * An abstract UIProvider that provides some basic methods. @@ -51,6 +52,9 @@ /** The artifact that contains status information.*/ protected Artifact artifact; + /** The Collection.*/ + protected Collection collection; + /** * Creates a new UIProvider instance of this class. */ @@ -125,15 +129,20 @@ fireStepForwardEvent(new StepForwardEvent(data)); } else { - StringBuilder sb = new StringBuilder(); + showErrors(errors); + } + } - for (String error: errors) { - sb.append(error); - sb.append("<br>"); - } - SC.warn(sb.toString()); + protected void showErrors(List<String> errors) { + StringBuilder sb = new StringBuilder(); + + for (String error: errors) { + sb.append(error); + sb.append("<br>"); } + + SC.warn(sb.toString()); } @@ -192,6 +201,16 @@ } + public void setCollection(Collection collection) { + this.collection = collection; + } + + + public Collection getCollection() { + return collection; + } + + /** * This method greps the Data with name <i>name</i> from the list and * returns it.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Thu Sep 15 16:02:23 2011 +0000 @@ -371,6 +371,7 @@ public void onSuccess(Artifact artifact) { GWT.log("Successfully feed the artifact."); old.clear(); + cView.addArtifactToCollection(artifact); setArtifact(artifact); } }); @@ -469,7 +470,9 @@ if (oldStorage.get(state) == null) { String provider = dataList.getUIProvider(); - UIProvider uiprovider = UIProviderFactory.getProvider(provider, flys.getCurrentUser()); + UIProvider uiprovider = UIProviderFactory.getProvider( + provider, + flys.getCurrentUser()); ((HasStepBackHandlers) uiprovider).addStepBackHandler(this); Canvas c = uiprovider.createOld(dataList); @@ -671,10 +674,13 @@ if (currentData != null) { // the user has to enter some attributes String uiProvider = currentData.getUIProvider(); - UIProvider provider = UIProviderFactory.getProvider(uiProvider, flys.getCurrentUser()); + UIProvider provider = UIProviderFactory.getProvider( + uiProvider, + flys.getCurrentUser()); provider.setContainer(helperPanel); provider.setArtifact(art); + provider.setCollection(cView.getCollection()); ((HasStepForwardHandlers) provider).addStepForwardHandler(this); ((HasStepBackHandlers) provider).addStepBackHandler(this); @@ -689,6 +695,7 @@ // data is required. UIProvider ui = UIProviderFactory.getProvider("continue", null); ui.setArtifact(art); + ui.setCollection(cView.getCollection()); ((ContinuePanel) ui).addAdvanceHandler(this);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProvider.java Thu Sep 15 16:02:23 2011 +0000 @@ -7,6 +7,7 @@ import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.Artifact; +import de.intevation.flys.client.shared.model.Collection; /** * This interface describes a method that creates a Canvas element displaying @@ -52,5 +53,11 @@ * @param artifact The artifact containing status information. */ public void setArtifact(Artifact artifact); + + + /** + * Sets the parent Collection of the Artifact. + */ + public void setCollection(Collection collection); } // 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/WspDatacagePanel.java Thu Sep 15 15:55:30 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WspDatacagePanel.java Thu Sep 15 16:02:23 2011 +0000 @@ -1,16 +1,47 @@ package de.intevation.flys.client.client.ui; +import java.util.List; +import java.util.Map; +import java.util.Set; + +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.events.ClickEvent; + +import de.intevation.flys.client.shared.model.Artifact; +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.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.Recommendation; +import de.intevation.flys.client.shared.model.Recommendation.Facet; +import de.intevation.flys.client.shared.model.Recommendation.Filter; +import de.intevation.flys.client.shared.model.ToLoad; import de.intevation.flys.client.shared.model.User; +import de.intevation.flys.client.client.Config; +import de.intevation.flys.client.client.FLYSConstants; +import de.intevation.flys.client.client.event.StepForwardEvent; +import de.intevation.flys.client.client.services.LoadArtifactService; +import de.intevation.flys.client.client.services.LoadArtifactServiceAsync; + public class WspDatacagePanel extends DatacagePanel { public static final String WATERLEVEL_OUTS = "longitudinal_section"; + public static final FLYSConstants MSG = GWT.create(FLYSConstants.class); + + + protected LoadArtifactServiceAsync loadService = + GWT.create(LoadArtifactService.class); + + protected Recommendation recommendation; + protected Artifact artifact; + public WspDatacagePanel() { super(); @@ -28,12 +59,94 @@ } + /** + * We need to override this method (defined in AbstractUIProvider) because + * we have to create a new Artifact specified by the Datacage selection via + * Async request. + * + * @param The ClickEvent. + */ + @Override + public void onClick(ClickEvent e) { + List<String> errors = validate(); + if (errors == null || errors.isEmpty()) { + // 1) Fetch selected recommendation + Config config = Config.getInstance(); + final String url = config.getServerUrl(); + final String locale = config.getLocale(); + final Collection c = this.collection; + final Recommendation r = getSelectedRecommendation(); + + // 2) Create, load Artifact and fire event + loadService.load( + c, r, "winfo", url, locale, + new AsyncCallback<Artifact>() { + public void onFailure(Throwable caught) { + SC.warn(MSG.getString(caught.getMessage())); + } + + public void onSuccess(Artifact artifact) { + fireStepForwardEvent(new StepForwardEvent( + getData(r, artifact))); + } + } + ); + } + else { + showErrors(errors); + } + } + + + protected Recommendation getSelectedRecommendation() { + ToLoad toLoad = widget.getSelection(); + List<Recommendation> recoms = toLoad.toRecommendations(); + + return recoms.get(0); + } + + + /** + * Nothing is done in this method. It returns null, because we serve the + * Data another way! + * + * @return always null! + */ @Override protected Data[] getData() { - String value = "TODO:FIND VALUE"; + // do nothing here, the Data is fetched on another way in this panel. + return null; + } + + + protected Data[] getData(Recommendation r, Artifact newArtifact) { + String uuid = newArtifact.getUuid(); + r.setMasterArtifact(uuid); + + String value = createDataString(uuid, r.getFilter()); + DataItem item = new DefaultDataItem(dataName, dataName, value); return new Data[] { new DefaultData( dataName, null, null, new DataItem[] { item }) }; } + + + protected String createDataString(String artifact, Filter filter) { + Facet f = null; + + Map<String, List<Facet>> outs = filter.getOuts(); + Set<Map.Entry<String, List<Facet>>> entries = outs.entrySet(); + + for (Map.Entry<String, List<Facet>> entry: entries) { + List<Facet> fs = entry.getValue(); + + f = fs.get(0); + if (f != null) { + break; + } + } + + return "[" + artifact + ";" + f.getName() + ";" + f.getIndex() + "]"; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :