annotate flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java @ 815:112f95d7b286

Removed superfluous imports. flys-client/trunk@2471 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 08 Aug 2011 16:24:07 +0000
parents e9337488bac3
children f14cefeed243
rev   line source
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
4 import java.util.HashMap;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import java.util.List;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
6 import java.util.Map;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import javax.xml.xpath.XPathConstants;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import org.w3c.dom.Document;
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
11 import org.w3c.dom.Element;
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
12 import org.w3c.dom.NamedNodeMap;
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
13 import org.w3c.dom.Node;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.NodeList;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.artifacts.common.ArtifactNamespaceContext;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.artifacts.common.utils.XMLUtils;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import de.intevation.artifacts.httpclient.http.HttpClient;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
27 import de.intevation.flys.client.shared.exceptions.ServerException;
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
28 import de.intevation.flys.client.shared.model.AttributedTheme;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import de.intevation.flys.client.shared.model.Collection;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 import de.intevation.flys.client.shared.model.CollectionItem;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import de.intevation.flys.client.shared.model.DefaultCollection;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.client.shared.model.DefaultCollectionItem;
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
33 import de.intevation.flys.client.shared.model.DefaultFacet;
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
34 import de.intevation.flys.client.shared.model.DefaultRecommendation;
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
35 import de.intevation.flys.client.shared.model.ChartMode;
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
36 import de.intevation.flys.client.shared.model.ExportMode;
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
37 import de.intevation.flys.client.shared.model.MapMode;
589
942bd0e7e332 Filter reports and dispatch them to updateReports().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 587
diff changeset
38 import de.intevation.flys.client.shared.model.ReportMode;
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
39 import de.intevation.flys.client.shared.model.Facet;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 import de.intevation.flys.client.shared.model.OutputMode;
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
41 import de.intevation.flys.client.shared.model.Recommendation;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
42 import de.intevation.flys.client.shared.model.Theme;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
43 import de.intevation.flys.client.shared.model.ThemeList;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 import de.intevation.flys.client.client.services.DescribeCollectionService;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 /**
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 * This service implements a method that queries the DESCRIBE document of a
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 * specific collection and returns a Collection object with the information of
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 * the document.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 */
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 public class DescribeCollectionServiceImpl
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 extends RemoteServiceServlet
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 implements DescribeCollectionService
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 {
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
58 /** The error message key that is thrown if an error occured while
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
59 * describe() a Collection.*/
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
60 public static final String ERROR_DESCRIBE_COLLECTION =
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
61 "error_describe_collection";
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
62
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
63 public static final String XPATH_FACETS = "art:facets/art:facet";
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
64
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
65 public static final String XPATH_LOADED_RECOMMENDATIONS =
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
66 "/art:artifact-collection/art:attribute/art:loaded-recommendations/art:recommendation";
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
67
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
68
229
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 215
diff changeset
69 public Collection describe(String uuid, String serverUrl, String locale)
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
70 throws ServerException
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
71 {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 System.out.println("DescribeCollectionServiceImpl.describe");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 Document describe = ClientProtocolUtils.newDescribeCollectionDocument(
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 uuid);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
229
924da6695800 Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 215
diff changeset
77 HttpClient client = new HttpClientImpl(serverUrl, locale);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 try {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 Document response = (Document) client.doCollectionAction(
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 describe, uuid, new DocumentResponseHandler());
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 Collection c = parseCollection(response);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 if (c == null) {
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
86 throw new ServerException(ERROR_DESCRIBE_COLLECTION);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
89 System.out.println("Collection successfully parsed.");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
90
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 return c;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 catch (ConnectionException ce) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 System.err.println(ce.getLocalizedMessage());
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
215
e02f50a3ad59 Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 101
diff changeset
97 throw new ServerException(ERROR_DESCRIBE_COLLECTION);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 /**
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 * This method takes the DESCRIBE document of the Collections describe()
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 * operation and extracts the information about the collection itself and
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 * the collection items.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 * @param description The DESCRIBE document of the Collections describe()
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 * operation.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 * @return a Collection with CollectionItems.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 */
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 protected Collection parseCollection(Document description) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 System.out.println("AddArtifactServiceImpl.parseCollection");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 if (description == null) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 System.err.println("The DESCRIBE of the Collection is null!");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 return null;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 String uuid = XMLUtils.xpathString(
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 description,
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 "art:artifact-collection/@art:uuid",
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 ArtifactNamespaceContext.INSTANCE);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
124 String ttlStr = XMLUtils.xpathString(
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
125 description,
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
126 "art:artifact-collection/@art:ttl",
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
127 ArtifactNamespaceContext.INSTANCE);
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
128
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
129 if (uuid.length() == 0 || ttlStr.length() == 0) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 System.err.println("Found an invalid Collection!");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 return null;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
134
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
135 long ttl = -1;
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
136 try {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
137 ttl = Long.valueOf(ttlStr);
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
138 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
139 catch (NumberFormatException nfe) {
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
140 // do nothing
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
141 }
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
142
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
143 Map<String, ThemeList> themeList = parseThemeLists(description);
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
144 List<Recommendation> recommended = parseRecommendations(description);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
145
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
146 Collection c = !themeList.isEmpty()
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
147 ? new DefaultCollection(uuid, ttl, recommended, themeList)
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
148 : new DefaultCollection(uuid, ttl, recommended);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 NodeList items = (NodeList) XMLUtils.xpath(
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 description,
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 "art:artifact-collection/art:artifacts/art:artifact",
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 XPathConstants.NODESET,
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 ArtifactNamespaceContext.INSTANCE);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 if (items == null || items.getLength() == 0) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 System.out.println("No collection item found for this collection.");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 return c;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162 int size = items.getLength();
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 for (int i = 0; i < size; i++) {
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
165 CollectionItem item = parseCollectionItem((Element)items.item(i));
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 if (item != null) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 c.addItem(item);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 System.out.println(
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 "Found " + c.getItemLength() + " collection items " +
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 "for the Collection '" + c.identifier() + "'.");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 return c;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
180 protected Map<String, ThemeList> parseThemeLists(Document description) {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
181 System.out.println("DescribeCollectionServiceImpl.parseThemeLists");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
182
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
183 NodeList lists = (NodeList) XMLUtils.xpath(
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
184 description,
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
185 "/art:artifact-collection/art:attribute/art:outputs/art:output",
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
186 XPathConstants.NODESET,
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
187 ArtifactNamespaceContext.INSTANCE);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
188
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
189 int num = lists != null ? lists.getLength() : 0;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
190
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
191 Map<String, ThemeList> themeList = new HashMap<String, ThemeList>(num);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
192
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
193 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
194
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
195 for (int i = 0; i < num; i++) {
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
196 Element node = (Element)lists.item(i);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
197
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
198 String outName = node.getAttribute("name");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
199
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
200 if (outName.length() > 0) {
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
201 ThemeList list = parseThemeList(node);
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
202 if (list.getThemeCount() > 0) {
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
203 themeList.put(outName, list);
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
204 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
205 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
206 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
207
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
208 return themeList;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
209 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
210
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
211
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
212 protected ThemeList parseThemeList(Element node) {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
213 System.out.println("DescribeCollectionServiceImpl.parseThemeList");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
214
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
215 NodeList themes = node.getElementsByTagNameNS(
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
216 ArtifactNamespaceContext.NAMESPACE_URI,
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
217 "facet");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
218
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
219 int num = themes != null ? themes.getLength() : 0;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
220
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
221 List<Theme> themeList = new ArrayList<Theme>(num);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
222
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
223 for (int i = 0; i < num; i++) {
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
224 Theme theme = parseTheme((Element)themes.item(i));
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
225
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
226 if (theme != null) {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
227 themeList.add(theme);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
228 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
229 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
230
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
231 return new ThemeList(themeList);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
232 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
233
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
234
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
235 protected Theme parseTheme(Element ele) {
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
236 System.out.println("DescribeCollectionServiceImpl.parseTheme");
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
237
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
238 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
239
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
240 NamedNodeMap attrMap = ele.getAttributes();
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
241 int attrNum = attrMap != null ? attrMap.getLength() : 0;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
242
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
243 AttributedTheme t = new AttributedTheme();
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
244
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
245 for (int i = 0; i < attrNum; i++) {
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
246 Node attr = attrMap.item(i);
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
247
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
248 String prefix = attr.getPrefix();
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
249 String name = attr.getNodeName().replace(prefix + ":", "");
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
250 String value = attr.getNodeValue();
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
251
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
252 t.addAttr(name, value);
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
253 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
254
804
374712890b94 Facets read from Collection's DESCRIBE document keep all their attributes after the Collection's attribute has been modified.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 796
diff changeset
255 return t;
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
256 }
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
257
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.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 270
diff changeset
258
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 /**
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 * This method extracts the CollectionItem from <i>node</i> with its output
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 * modes. The output modes are parsed using the parseOutputModes() method.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 * @param node A node that contains information about a CollectionItem.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 * @return a CollectionItem.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 */
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
267 protected CollectionItem parseCollectionItem(Element node) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 System.out.println("AddArtifactServiceImpl.parseCollectionItem");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270 if (node == null) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 System.err.println("The node for parsing CollectionItem is null!");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 return null;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
275 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
277 String uuid = node.getAttributeNS(uri, "uuid");
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
278 String hash = node.getAttributeNS(uri, "hash");
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279
587
53ad6dd2cb2b The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 582
diff changeset
280 if (uuid == null || uuid.length() == 0) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281 System.err.println("Found an invalid CollectionItem!");
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
282 return null;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
285 NodeList outputmodes = node.getElementsByTagNameNS(uri, "outputmodes");
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
287 if (outputmodes.getLength() < 1) {
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
288 return null;
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
289 }
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
290
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
291 Element om = (Element)outputmodes.item(0);
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
292
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
293 List<OutputMode> modes = parseOutputModes(om);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 return new DefaultCollectionItem(uuid, hash, modes);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
296 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
297
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
298
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
299 /**
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
300 * This method extracts the OutputModes available for a specific
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
301 * CollectionItem and returns them as list.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
302 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
303 * @param node The root node of the outputmodes list.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
304 *
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
305 * @return a list of OutputModes.
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
306 */
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
307 protected List<OutputMode> parseOutputModes(Element node) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
308 System.out.println("AddArtifactServiceImpl.parseOutputModes");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
309
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
310 if (node == null) {
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
311 System.err.println("The node for parsing OutputModes is null!");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
312 return null;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
313 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
314
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
315 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
316
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
317 NodeList list = node.getElementsByTagNameNS(uri, "output");
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
318
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
319 int size = list.getLength();
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
320
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
321 if (size == 0) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
322 System.err.println("No outputmode nodes found!");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
323 return null;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
324 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
325
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
326 List<OutputMode> modes = new ArrayList<OutputMode>(size);
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
327
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
328 for (int i = 0; i < size; i++) {
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
329 Element tmp = (Element)list.item(i);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
330
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
331 String name = tmp.getAttributeNS(uri, "name");
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
332 String desc = tmp.getAttributeNS(uri, "description");
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
333 String mime = tmp.getAttributeNS(uri, "mime-type");
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
334 String type = tmp.getAttributeNS(uri, "type");
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
335
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
336 if (name.length() == 0) {
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
337 System.err.println("Found an invalid output mode.");
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
338 continue;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
339 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
340
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
341 OutputMode outmode = null;
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
342 List<Facet> fs = extractFacets(tmp);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
343
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
344 if (type.equals("export")) {
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
345 outmode = new ExportMode(name, desc, mime, fs);
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
346 }
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
347 else if (type.equals("report")) {
589
942bd0e7e332 Filter reports and dispatch them to updateReports().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 587
diff changeset
348 outmode = new ReportMode(name, desc, mime, fs);
942bd0e7e332 Filter reports and dispatch them to updateReports().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 587
diff changeset
349 }
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
350 else if (type.equals("chart")){
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
351 outmode = new ChartMode(name, desc, mime, fs);
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
352 }
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
353 else if (type.equals("map")){
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
354 outmode = new MapMode(name, desc, mime, fs);
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
355 }
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
356 else {
796
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
357 System.err.println("Broken Output mode without type found.");
cd8603aaa730 Improved the process of creating OutputTabs. Added support for map output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 589
diff changeset
358 continue;
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
359 }
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
360
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
361 modes.add(outmode);
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
362 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
363
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
364 return modes;
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
365 }
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
366
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
367
581
210339fd1a34 Removed more expensive XPath.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 575
diff changeset
368 protected static List<Facet> extractFacets(Element outmode) {
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
369 System.out.println("DescribeCollectionServiceImpl - extractFacets()");
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
370
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
371 NodeList facetList = (NodeList) XMLUtils.xpath(
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
372 outmode,
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
373 XPATH_FACETS,
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
374 XPathConstants.NODESET,
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
375 ArtifactNamespaceContext.INSTANCE);
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
376
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
377 int num = facetList != null ? facetList.getLength() : 0;
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
378
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
379 List<Facet> facets = new ArrayList<Facet>(num);
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
380
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
381 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
382
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
383 for (int i = 0; i < num; i++) {
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
384 Element facetEl = (Element) facetList.item(i);
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
385
575
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
386 String name = facetEl.getAttributeNS(uri, "name");
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
387 String desc = facetEl.getAttributeNS(uri, "description");
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
388 String index = facetEl.getAttributeNS(uri, "index");
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
389
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
390 if (name != null && name.length() > 0 && index != null) {
5277f46a63c2 The description of a facet is now displayed in the ChartThemePanel.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 524
diff changeset
391 facets.add(new DefaultFacet(name, Integer.valueOf(index),desc));
270
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
392 }
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
393 }
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
394
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
395 return facets;
d01b0d81b92a Parse the facets of a Collection and distinguish between an ordinary OutputMode and an ExportMode (new).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
396 }
809
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
397
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
398
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
399 public static List<Recommendation> parseRecommendations(Document doc) {
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
400 System.out.println("DescribeCollectionServiceImpl.parseRecommendations");
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
401
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
402 NodeList list = (NodeList) XMLUtils.xpath(
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
403 doc,
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
404 XPATH_LOADED_RECOMMENDATIONS,
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
405 XPathConstants.NODESET,
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
406 ArtifactNamespaceContext.INSTANCE);
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
407
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
408 int num = list != null ? list.getLength() : 0;
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
409
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
410 List<Recommendation> recs = new ArrayList<Recommendation>(num);
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
411
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
412 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
413
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
414 for (int i = 0; i < num; i++) {
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
415 Element rec = (Element) list.item(i);
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
416
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
417 String factory = rec.getAttributeNS(uri, "factory");
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
418 String dbids = rec.getAttributeNS(uri, "db-ids");
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
419
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
420 if (factory != null && factory.length() > 0) {
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
421 recs.add(new DefaultRecommendation(factory, dbids));
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
422 }
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
423 }
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
424
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
425 return recs;
e9337488bac3 The Collection now knows its already loaded recommendations - the CollectionView will not load recommendations that have already been loaded before.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 804
diff changeset
426 }
99
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
427 }
5c3d685546a6 Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
428 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org