Mercurial > dive4elements > river
changeset 270:d01b0d81b92a
Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
flys-client/trunk@1895 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 11 May 2011 09:11:40 +0000 |
parents | eb3c16df59db |
children | 65735765643d |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ExportMode.java flys-client/src/main/java/de/intevation/flys/client/shared/model/OutputMode.java |
diffstat | 6 files changed, 209 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed May 11 07:32:08 2011 +0000 +++ b/flys-client/ChangeLog Wed May 11 09:11:40 2011 +0000 @@ -1,3 +1,25 @@ +2011-05-11 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/shared/model/ExportMode.java: + New. A derived OutputMode that is used to mark an OutputMode as an + export. + + * src/main/java/de/intevation/flys/client/shared/model/OutputMode.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java: + Added methods to provide facets in output modes. + + * src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java: + Extract facets from DESCRIBE and distinguish between an ordinary + OutputMode or an ExportMode. + + * src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Replaced the determination of an export mode for creating new + OutputTabs. Now, we just create new OutputTabs for OutputModes that are + no instance of ExportMode. Furthermore, the computation output panel + is now displayed if there is an output mode which: + - is an ExportMode + - has a facet which name is "csv" + 2011-05-11 Ingo Weinzierl <ingo@intevation.de> ISSUE-41 (part1)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 11 07:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed May 11 09:11:40 2011 +0000 @@ -18,6 +18,7 @@ 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.ExportMode; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.shared.model.User; @@ -353,14 +354,16 @@ * @param name The name and title of the output. */ protected void addOutputTab(String name, OutputMode out) { - // XXX Maybe we should change this determination of visual outputs. I am - // not sure if the mimetype is the correct value for this! + if (out instanceof ExportMode) { + ExportMode export = (ExportMode) out; - if (out.getMimeType().equals("text/plain")) { - TableDataPanel p = new TableDataPanel(); - p.setUuid(collection.identifier()); - p.setName(out.getName()); - parameterList.setPanel (p); + if (export.getFacet("csv") != null) { + TableDataPanel p = new TableDataPanel(); + p.setUuid(collection.identifier()); + p.setName(out.getName()); + parameterList.setPanel (p); + } + return; }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Wed May 11 07:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Wed May 11 09:11:40 2011 +0000 @@ -25,7 +25,10 @@ import de.intevation.flys.client.shared.model.CollectionItem; import de.intevation.flys.client.shared.model.DefaultCollection; import de.intevation.flys.client.shared.model.DefaultCollectionItem; +import de.intevation.flys.client.shared.model.DefaultFacet; import de.intevation.flys.client.shared.model.DefaultOutputMode; +import de.intevation.flys.client.shared.model.ExportMode; +import de.intevation.flys.client.shared.model.Facet; import de.intevation.flys.client.shared.model.OutputMode; import de.intevation.flys.client.client.services.DescribeCollectionService; @@ -46,6 +49,8 @@ public static final String ERROR_DESCRIBE_COLLECTION = "error_describe_collection"; + public static final String XPATH_FACETS = "art:facets/art:facet"; + public Collection describe(String uuid, String serverUrl, String locale) throws ServerException @@ -221,12 +226,48 @@ continue; } - // TODO Parse Facets + OutputMode outmode = null; + List<Facet> fs = extractFacets(tmp); - modes.add(new DefaultOutputMode(name, desc, mime)); + if (name.indexOf("export") > -1) { + outmode = new ExportMode(name, desc, mime, fs); + } + else { + outmode = new DefaultOutputMode(name, desc, mime, fs); + } + + modes.add(outmode); } return modes; } + + + protected static List<Facet> extractFacets(Node outmode) { + System.out.println("ArtifactDescriptionFactory - extractFacets()"); + + NodeList facetList = (NodeList) XMLUtils.xpath( + outmode, + XPATH_FACETS, + XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + + int num = facetList != null ? facetList.getLength() : 0; + + List<Facet> facets = new ArrayList<Facet>(num); + + for (int i = 0; i < num; i++) { + Node facetNode = facetList.item(i); + + String name = XMLUtils.xpathString( + facetNode, "@art:name", ArtifactNamespaceContext.INSTANCE); + + if (name != null && name.length() > 0) { + facets.add(new DefaultFacet(name)); + } + } + + return facets; + } } // 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/DefaultOutputMode.java Wed May 11 07:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultOutputMode.java Wed May 11 09:11:40 2011 +0000 @@ -1,5 +1,8 @@ package de.intevation.flys.client.shared.model; +import java.util.ArrayList; +import java.util.List; + /** * The default implementation of an Output. @@ -17,9 +20,13 @@ /** The mime-type of this mode.*/ protected String mimeType; + /** The list of available facets of this export mode.*/ + protected List<Facet> facets; + /** A convinience constructor.*/ public DefaultOutputMode() { + facets = new ArrayList<Facet>(); } @@ -37,6 +44,17 @@ } + public DefaultOutputMode( + String name, + String description, + String mimeType, + List<Facet> facets) + { + this(name, description, mimeType); + this.facets = facets; + } + + public String getName() { return name; } @@ -50,5 +68,52 @@ public String getMimeType() { return mimeType; } + + + /** + * Adds a new facet to this export. + * + * @param facet The new facet. + */ + public void addFacet(Facet facet) { + facets.add(facet); + } + + + /** + * Returns the number of facets supported by this export. + * + * @return the number of facets. + */ + public int getFacetCount() { + return facets.size(); + } + + + /** + * Returns the facet at a given position. + * + * @param idx The position of a facet. + * + * @return a facet. + */ + public Facet getFacet(int idx) { + if (idx < getFacetCount()) { + return facets.get(idx); + } + + return null; + } + + + public Facet getFacet(String name) { + for (Facet facet: facets) { + if (name.equals(facet.getName())) { + return facet; + } + } + + return null; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/ExportMode.java Wed May 11 09:11:40 2011 +0000 @@ -0,0 +1,33 @@ +package de.intevation.flys.client.shared.model; + +import java.util.List; + + +/** + * An derived OutputMode that marks an OutputMode as an export. An export mode + * should at least support one (or more) facet which specify the type of export + * (e.g. CSV, WST). + * + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ExportMode extends DefaultOutputMode { + + public ExportMode() { + } + + + public ExportMode(String name, String desc, String mimeType) { + super(name, desc, mimeType); + } + + + public ExportMode( + String name, + String descrition, + String mimeType, + List<Facet> facets) + { + super(name, descrition, mimeType, facets); + } +} +// 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/OutputMode.java Wed May 11 07:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/OutputMode.java Wed May 11 09:11:40 2011 +0000 @@ -33,5 +33,41 @@ * @return the mime-type of this mode. */ String getMimeType(); + + + /** + * Adds a new facet to this mode. + * + * @param facet The new facet. + */ + void addFacet(Facet facet); + + + /** + * Returns the number of facets supported by this mode. + * + * @return the number of facets. + */ + int getFacetCount(); + + + /** + * Returns the facet at a given position. + * + * @param idx The position of a facet. + * + * @return a facet. + */ + Facet getFacet(int idx); + + + /** + * Returns a facet based on its name. + * + * @param name The name of the facet. + * + * @return a facet or null if no such facet is available. + */ + Facet getFacet(String name); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :