annotate flys-client/src/main/java/de/intevation/flys/client/server/ArtifactHelper.java @ 4237:640adb7bced5

Merged.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 24 Oct 2012 14:27:21 +0200
parents 436eec3be6ff
children b660090b417d
rev   line source
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
4 import org.w3c.dom.Element;
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
6 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
7
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import java.util.ArrayList;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import java.util.List;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import java.util.Map;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.common.utils.CreationFilter;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.httpclient.http.HttpClient;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
18 import de.intevation.artifacts.httpclient.utils.ArtifactNamespaceContext;
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
19 import de.intevation.artifacts.httpclient.utils.XMLUtils;
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.client.shared.exceptions.ServerException;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.client.shared.model.Artifact;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.client.shared.model.Recommendation;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 /**
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 */
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public class ArtifactHelper {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
31 private static final Logger logger = Logger.getLogger(ArtifactHelper.class);
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
32
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
33
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 /** The error message key that is thrown if an error occured while artifact
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 * creation.*/
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 public static final String ERROR_CREATE_ARTIFACT = "error_create_artifact";
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
38 /**
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
39 * Name of the factory to generate a GaugeDischargeCurveArtifact
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
40 */
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
41 private static final String GAUGE_DISCHARGE_CURVE_ARTIFACT = "gaugedischargecurve";
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
42
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 private ArtifactHelper() {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
1318
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
48 /**
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
49 * @param factory ArtifactFactory to use.
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
50 */
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 public static Artifact createArtifact(
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 String serverUrl,
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 String locale,
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 String factory,
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 Recommendation recommendation)
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 throws ServerException
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
58 logger.debug("ArtifactHelper.create");
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 String uuid;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 String ids;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62 CreationFilter filter;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 if (recommendation != null) {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 uuid = recommendation.getMasterArtifact();
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 ids = recommendation.getIDs();
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 filter = convertFilter(recommendation.getFilter());
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 else {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 uuid = null;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 ids = null;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 filter = null;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 Document create = ClientProtocolUtils.newCreateDocument(
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 factory, uuid, ids, filter);
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
78 return sendCreate(serverUrl, locale, create);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
79
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
80 }
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
81
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
82 /**
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
83 * Creates a new GaugeDischargeCurverArtifact
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
84 *
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
85 * @param river the name of the river
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
86 * @param reference the reference id of the gauge (official number)
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
87 */
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
88 public static Artifact createGaugeDischargeCurveArtifact(
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
89 String serverUrl,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
90 String locale,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
91 String river,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
92 Long reference)
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
93 throws ServerException
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
94 {
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
95 Document create = ClientProtocolUtils.newCreateDocument(
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
96 GAUGE_DISCHARGE_CURVE_ARTIFACT);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
97
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
98 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
99 create,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
100 ArtifactNamespaceContext.NAMESPACE_URI,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
101 ArtifactNamespaceContext.NAMESPACE_PREFIX);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
102
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
103 Element root = create.getDocumentElement();
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
104
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
105 Element eriver = ec.create("river");
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
106 ec.addAttr(eriver, "name", river);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
107
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
108 Element egauge = ec.create("gauge");
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
109 ec.addAttr(egauge, "reference", reference.toString());
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
110
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
111 root.appendChild(eriver);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
112 root.appendChild(egauge);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
113
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
114 return sendCreate(serverUrl, locale, create);
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
115 }
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
116
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
117 /**
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
118 * Sends a create document to the artifact server
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
119 */
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
120 private static Artifact sendCreate(
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
121 String serverUrl,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
122 String locale,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
123 Document doc)
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
124 throws ServerException
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
125 {
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 HttpClient client = new HttpClientImpl(serverUrl, locale);
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 try {
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
129 return (Artifact) client.create(doc, new FLYSArtifactCreator());
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 catch (ConnectionException ce) {
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
132 logger.error(ce, ce);
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 throw new ServerException(ERROR_CREATE_ARTIFACT);
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138
1318
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
139 /**
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
140 * Create CreationFilter from Recommendation.Filter.
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
141 */
905
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 public static CreationFilter convertFilter(Recommendation.Filter filter) {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 if (filter == null) {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 return null;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 CreationFilter cf = new CreationFilter();
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 Map<String, List<Recommendation.Facet>> outs = filter.getOuts();
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 for (Map.Entry<String, List<Recommendation.Facet>> entry:
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 outs.entrySet()) {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 List<Recommendation.Facet> rfs = entry.getValue();
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 List<CreationFilter.Facet> cfs =
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 new ArrayList<CreationFilter.Facet>(rfs.size());
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 for (Recommendation.Facet rf: rfs) {
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 cfs.add(new CreationFilter.Facet(rf.getName(), rf.getIndex()));
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 cf.add(entry.getKey(), cfs);
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 return cf;
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
478a571f1f94 Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org