Mercurial > dive4elements > river
changeset 524:ba238f917b94
The theme list information stored in the attribute of a collection is read and added in form of Themes and ThemeLists to the Collection.
flys-client/trunk@2003 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 25 May 2011 13:42:04 +0000 |
parents | 0785a8ba5e6d |
children | fc994da131f9 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Theme.java flys-client/src/main/java/de/intevation/flys/client/shared/model/ThemeList.java |
diffstat | 9 files changed, 302 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/ChangeLog Wed May 25 13:42:04 2011 +0000 @@ -1,3 +1,32 @@ +2011-05-25 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java: + Parse the theme lists - contained in the attribute of the collection - + and add those lists to the collection. The lists are retrievable using + the method getThemeList(String outName). + + * src/main/java/de/intevation/flys/client/shared/model/Theme.java, + src/main/java/de/intevation/flys/client/shared/model/DefaultTheme.java: + The interface and its default implementation of a theme. A theme + represents a curve in a chart or a layer in a map. The default + implementation knows about the facet, the position, the status and the + artifact this theme belongs to. + + * src/main/java/de/intevation/flys/client/shared/model/ThemeList.java: + New. A ThemeList is a wrapper for themes and should provide some + functions to process regularly used operations on a list of themes. + + * src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java, + src/main/java/de/intevation/flys/client/shared/model/Collection.java: + Added a new constructor that takes a ThemeList as well and a method to + retrieve a ThemeList based on the name of the output. + + * src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java: + This record no longer stores facets but themes. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java: + Modified the process of adding new themes to the theme grid. + 2011-05-25 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartThemePanel.java Wed May 25 13:42:04 2011 +0000 @@ -17,6 +17,8 @@ import de.intevation.flys.client.shared.model.Facet; import de.intevation.flys.client.shared.model.FacetRecord; import de.intevation.flys.client.shared.model.OutputMode; +import de.intevation.flys.client.shared.model.Theme; +import de.intevation.flys.client.shared.model.ThemeList; import de.intevation.flys.client.client.FLYSConstants; @@ -119,10 +121,23 @@ protected void updateGrid() { clearGrid(); - List<Facet> facets = mode.getFacets(); + ThemeList themeList = collection.getThemeList(mode.getName()); - for (Facet facet: facets) { - list.addData(new FacetRecord(facet)); + if (themeList == null) { + GWT.log("ERROR: No theme list."); + return; + } + + int count = themeList.getThemeCount(); + + for (int i = 1; i <= count; i++) { + Theme theme = themeList.getThemeAt(i); + + if (theme == null) { + continue; + } + + list.addData(new FacetRecord(theme)); } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java Wed May 25 13:42:04 2011 +0000 @@ -1,7 +1,9 @@ package de.intevation.flys.client.server; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.xml.xpath.XPathConstants; @@ -27,9 +29,12 @@ 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.DefaultTheme; 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.shared.model.Theme; +import de.intevation.flys.client.shared.model.ThemeList; import de.intevation.flys.client.client.services.DescribeCollectionService; @@ -72,6 +77,8 @@ throw new ServerException(ERROR_DESCRIBE_COLLECTION); } + System.out.println("Collection successfully parsed."); + return c; } catch (ConnectionException ce) { @@ -110,7 +117,17 @@ return null; } - Collection c = new DefaultCollection(uuid); + Map<String, ThemeList> themeList = parseThemeLists(description); + + Collection c = null; + + if (themeList != null) { + c = new DefaultCollection(uuid, themeList); + //c = new DefaultCollection(uuid); + } + else { + c = new DefaultCollection(uuid); + } NodeList items = (NodeList) XMLUtils.xpath( description, @@ -142,6 +159,92 @@ } + protected Map<String, ThemeList> parseThemeLists(Document description) { + System.out.println("DescribeCollectionServiceImpl.parseThemeLists"); + + NodeList lists = (NodeList) XMLUtils.xpath( + description, + "/art:artifact-collection/art:attribute/art:outputs/art:output", + XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + + int num = lists != null ? lists.getLength() : 0; + + Map<String, ThemeList> themeList = new HashMap<String, ThemeList>(num); + + for (int i = 0; i < num; i++) { + Node node = lists.item(i); + + String outName = XMLUtils.xpathString( + node, "@name", ArtifactNamespaceContext.INSTANCE); + + ThemeList list = parseThemeList(node); + + if (list != null) { + themeList.put(outName, list); + } + } + + return themeList; + } + + + protected ThemeList parseThemeList(Node node) { + System.out.println("DescribeCollectionServiceImpl.parseThemeList"); + + NodeList themes = (NodeList) XMLUtils.xpath( + node, + "art:theme", + XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + + int num = themes != null ? themes.getLength() : 0; + + List<Theme> themeList = new ArrayList<Theme>(num); + + for (int i = 0; i < num; i++) { + Theme theme = parseTheme(themes.item(i)); + + if (theme != null) { + themeList.add(theme); + } + } + + return new ThemeList(themeList); + } + + + protected Theme parseTheme(Node node) { + System.out.println("DescribeCollectionServiceImpl.parseTheme"); + + String strAct = XMLUtils.xpathString( + node, "@art:active", ArtifactNamespaceContext.INSTANCE); + + String art = XMLUtils.xpathString( + node, "@art:artifact", ArtifactNamespaceContext.INSTANCE); + + String fac = XMLUtils.xpathString( + node, "@art:facet", ArtifactNamespaceContext.INSTANCE); + + String strPos = XMLUtils.xpathString( + node, "@art:pos", ArtifactNamespaceContext.INSTANCE); + + if (strAct != null && art != null && fac != null && strPos != null) { + try { + int pos = Integer.valueOf(strPos); + int active = Integer.valueOf(strAct); + + return new DefaultTheme(pos, active > 0, art, fac); + } + catch (NumberFormatException nfe) { + nfe.printStackTrace(); + } + } + + return null; + } + + /** * This method extracts the CollectionItem from <i>node</i> with its output * modes. The output modes are parsed using the parseOutputModes() method.
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Collection.java Wed May 25 13:42:04 2011 +0000 @@ -27,5 +27,7 @@ public CollectionItem getItem(int idx); public Map<String, OutputMode> getOutputModes(); + + public ThemeList getThemeList(String outName); } // 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/DefaultCollection.java Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java Wed May 25 13:42:04 2011 +0000 @@ -26,6 +26,8 @@ /** The list of artifacts that are managed by this Collection.*/ protected List<CollectionItem> items; + protected Map<String, ThemeList> themeLists; + /** * Constructor without arguments is necessary for GWT. @@ -40,8 +42,16 @@ * @param uuid The UUID. */ public DefaultCollection(String uuid) { - this.uuid = uuid; - this.items = new ArrayList<CollectionItem>(); + this.uuid = uuid; + this.items = new ArrayList<CollectionItem>(); + this.themeLists = new HashMap<String, ThemeList>(); + } + + + public DefaultCollection(String uuid, Map<String, ThemeList> themeLists) { + this(uuid); + + this.themeLists = themeLists; } @@ -132,5 +142,14 @@ return modes; } + + + public ThemeList getThemeList(String outName) { + if (themeLists != null) { + return themeLists.get(outName); + } + + 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/DefaultTheme.java Wed May 25 13:42:04 2011 +0000 @@ -0,0 +1,49 @@ +package de.intevation.flys.client.shared.model; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class DefaultTheme implements Theme { + + protected int position; + + protected boolean active; + + protected String artifact; + + protected String facet; + + + public DefaultTheme() { + } + + + public DefaultTheme(int pos, boolean active, String art, String facet) { + this.position = pos; + this.active = active; + this.artifact = artifact; + this.facet = facet; + } + + + public int getPosition() { + return position; + } + + + public boolean isActive() { + return active; + } + + + public String getArtifact() { + return artifact; + } + + + public String getFacet() { + return facet; + } +} +// 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/FacetRecord.java Wed May 25 11:34:34 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FacetRecord.java Wed May 25 13:42:04 2011 +0000 @@ -12,19 +12,19 @@ protected boolean active; - protected Facet facet; + protected Theme theme; - public FacetRecord(Facet facet) { - this.facet = facet; + public FacetRecord(Theme theme) { + this.theme = theme; - setActive(true); - setName(facet.getName()); + setActive(theme.isActive()); + setName(theme.getFacet()); } - public Facet getFacet() { - return facet; + public Theme getTheme() { + return theme; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Theme.java Wed May 25 13:42:04 2011 +0000 @@ -0,0 +1,19 @@ +package de.intevation.flys.client.shared.model; + +import java.io.Serializable; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public interface Theme extends Serializable { + + int getPosition(); + + boolean isActive(); + + String getArtifact(); + + String getFacet(); +} +// 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/ThemeList.java Wed May 25 13:42:04 2011 +0000 @@ -0,0 +1,53 @@ +package de.intevation.flys.client.shared.model; + +import java.io.Serializable; + +import java.util.List; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class ThemeList implements Serializable { + + public List<Theme> themes; + + + public ThemeList() { + } + + + public ThemeList(List<Theme> themes) { + this.themes = themes; + } + + + public List<Theme> getThemes() { + return themes; + } + + + public int getThemeCount() { + return themes.size(); + } + + + /** + * Returns a theme at a specific position. <b>NOTE: Themes start at position + * 1. So, take care in loops, that might start at index 0!</b> + * + * @param pos The position of the desired theme. + * + * @return a theme. + */ + public Theme getThemeAt(int pos) { + for (Theme theme: themes) { + if (theme.getPosition() == pos) { + return theme; + } + } + + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :