annotate flys-client/src/main/java/de/intevation/flys/client/server/ArtifactServiceImpl.java @ 845:4db672cdacb2

Added outs/facet filters when creation new artifacts. flys-client/trunk@2569 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 24 Aug 2011 16:06:48 +0000
parents 78ef14dc1877
children 478a571f1f94
rev   line source
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
5 import java.util.ArrayList;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
6 import java.util.List;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
7 import java.util.Map;
843
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
8
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
14
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
11 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
12 import de.intevation.artifacts.common.utils.CreationFilter;
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
14
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
14 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
15 import de.intevation.artifacts.httpclient.http.HttpClient;
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
16 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
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: 14
diff changeset
18 import de.intevation.flys.client.shared.exceptions.ServerException;
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.shared.model.Artifact;
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.client.services.ArtifactService;
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
843
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
22 import de.intevation.flys.client.shared.model.Recommendation;
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /**
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * This interface provides artifact specific services as CREATE, DESCRIBE, FEED,
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * ADVANCE and OUT.
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 *
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 */
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public class ArtifactServiceImpl
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 extends RemoteServiceServlet
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 implements ArtifactService
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 {
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: 14
diff changeset
34 /** The error message key that is thrown if an error occured while artifact
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: 14
diff changeset
35 * creation.*/
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: 14
diff changeset
36 public static final String ERROR_CREATE_ARTIFACT = "error_create_artifact";
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: 14
diff changeset
37
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: 14
diff changeset
38
803
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
39 public Artifact create(
843
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
40 String serverUrl,
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
41 String locale,
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
42 String factory,
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
43 Recommendation recommendation
78ef14dc1877 Forward recommendations as a structure to RPC service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 807
diff changeset
44 )
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: 14
diff changeset
45 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: 14
diff changeset
46 {
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
47 System.out.println("ArtifactServiceImpl.create");
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
48
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
49 String uuid;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
50 String ids;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
51 CreationFilter filter;
803
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
52
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
53 if (recommendation != null) {
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
54 uuid = recommendation.getMasterArtifact();
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
55 ids = recommendation.getIDs();
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
56 filter = convertFilter(recommendation.getFilter());
803
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
57 }
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
58 else {
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
59 uuid = null;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
60 ids = null;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
61 filter = null;
803
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
62 }
653ae84533e7 Read/create recommended Artifacts and add them to the current Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 229
diff changeset
63
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
64 Document create = ClientProtocolUtils.newCreateDocument(
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
65 factory, uuid, ids, filter);
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
66
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
67 HttpClient client = new HttpClientImpl(serverUrl, locale);
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
14
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
69 try {
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
70 return (Artifact) client.create(create, new FLYSArtifactCreator());
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
71 }
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
72 catch (ConnectionException ce) {
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
73 System.err.println(ce.getLocalizedMessage());
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
74 }
fe2f4d1dd784 Integrated the httpclient for the communication between client and server. It is now possible to create a new WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 11
diff changeset
75
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: 14
diff changeset
76 throw new ServerException(ERROR_CREATE_ARTIFACT);
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
845
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
78
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
79 public static CreationFilter convertFilter(Recommendation.Filter filter) {
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
80
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
81 if (filter == null) {
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
82 return null;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
83 }
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
84
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
85 CreationFilter cf = new CreationFilter();
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
86
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
87 Map<String, List<Recommendation.Facet>> outs = filter.getOuts();
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
88
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
89 for (Map.Entry<String, List<Recommendation.Facet>> entry:
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
90 outs.entrySet()) {
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
91 List<Recommendation.Facet> rfs = entry.getValue();
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
92 List<CreationFilter.Facet> cfs =
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
93 new ArrayList<CreationFilter.Facet>(rfs.size());
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
94 for (Recommendation.Facet rf: rfs) {
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
95 cfs.add(new CreationFilter.Facet(rf.getName(), rf.getIndex()));
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
96 }
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
97 cf.add(entry.getKey(), cfs);
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
98 }
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
99
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
100 return cf;
4db672cdacb2 Added outs/facet filters when creation new artifacts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 843
diff changeset
101 }
11
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 }
6aeb4072eeb4 Added interfaces and a stub implementation of an artifact service the should provide the methods for communicating with the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org