annotate gwt-client/src/main/java/org/dive4elements/river/client/server/ArtifactHelper.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 5e38e2924c07
children 0a5239a1e46e
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.server;
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
10
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 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
12 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
13
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
14 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
15
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
16 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
17 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
18 import java.util.Map;
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
19 import java.util.concurrent.Semaphore;
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
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.common.utils.CreationFilter;
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
23
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.artifacts.httpclient.utils.ArtifactNamespaceContext;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.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
29
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
30 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
31 import org.dive4elements.river.client.shared.model.Artifact;
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
32
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
33 import org.dive4elements.river.client.shared.model.Recommendation;
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
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 /**
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 * @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
37 */
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
38 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
39
6043
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
40 /** Private logging instance. */
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6450
diff changeset
41 private static final Logger log = Logger.getLogger(ArtifactHelper.class);
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
42
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1318
diff changeset
43
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
44 /** 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
45 * 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
46 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
47
6043
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
48 /** Name of the factory to generate a GaugeDischargeCurveArtifact. */
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8710
diff changeset
49 private static final String GAUGE_DISCHARGE_CURVE_ARTIFACT =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8710
diff changeset
50 "gaugedischargecurve";
6043
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
51
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
52 /** Name of the factory to generate a MainvaluesArtifact. */
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
53 private static final String MAINVALUE_ARTIFACT_FACTORY = "mainvalue";
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
54
5503
b660090b417d Create a new sq relation project on measurement station record click.
Raimund Renkert <rrenkert@intevation.de>
parents: 3865
diff changeset
55 private static final String SQ_RELATION_ARTIFACT = "staticsqrelation";
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
56
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
57 // To prevent pile up of create artifact calls only permit a limited
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
58 // number of parallel creates.
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
59 public static final int MAX_CREATE = 5;
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
60
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
61 private static final Semaphore CREATE_SEMAPHORE = new Semaphore(MAX_CREATE);
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
62
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
63 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
64 }
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
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
1318
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
67 /**
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
68 * @param factory ArtifactFactory to use.
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
69 */
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
70 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
71 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
72 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
73 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
74 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
75 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
76 {
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 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
78 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
79 CreationFilter filter;
6136
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
80 String targetOut;
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
81
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
82 if (recommendation != null) {
6136
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
83 uuid = recommendation.getMasterArtifact();
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
84 ids = recommendation.getIDs();
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
85 filter = convertFilter(recommendation.getFilter());
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
86 targetOut = recommendation.getTargetOut();
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
87 }
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
88 else {
6136
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
89 uuid = null;
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
90 ids = null;
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
91 filter = null;
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
92 targetOut = null;
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
93 }
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
94
8710
093146703b98 Improve ArtifactHelper creation debug output
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8313
diff changeset
95 log.debug("ArtifactHelper.create for master: " + uuid + " ids: " + ids +
093146703b98 Improve ArtifactHelper creation debug output
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8313
diff changeset
96 " filter: " + filter + " targetOut: " + targetOut);
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
97 Document create = ClientProtocolUtils.newCreateDocument(
6136
8d9859d776e5 Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents: 6044
diff changeset
98 factory, uuid, ids, filter, targetOut);
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
99
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
100 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
101 }
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 /**
6044
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
104 * Creates a new MainvaluesArtifact.
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
105 *
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
106 * @param river the name of the river
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
107 */
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
108 public static Artifact createMainvalueArtifact(
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
109 String serverUrl,
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
110 String locale,
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
111 String river,
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
112 Long gaugeRef)
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
113 throws ServerException
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
114 {
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
115 Document create = ClientProtocolUtils.newCreateDocument(
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
116 MAINVALUE_ARTIFACT_FACTORY);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
117
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
118 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
119 create,
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
120 ArtifactNamespaceContext.NAMESPACE_URI,
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
121 ArtifactNamespaceContext.NAMESPACE_PREFIX);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
122
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
123 Element root = create.getDocumentElement();
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
124
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
125 Element eriver = ec.create("river");
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
126 ec.addAttr(eriver, "name", river);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
127
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
128 Element egauge = ec.create("gauge");
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
129 ec.addAttr(egauge, "reference", gaugeRef.toString());
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
130
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
131 root.appendChild(eriver);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
132 root.appendChild(egauge);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
133
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
134 return sendCreate(serverUrl, locale, create);
477d2d18452e Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6043
diff changeset
135 }
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
136
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
137 /**
6043
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5993
diff changeset
138 * Sends a create document to the artifact server.
3865
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
139 */
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
140 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
141 String serverUrl,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
142 String locale,
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
143 Document doc)
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
144 throws ServerException
436eec3be6ff Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 1367
diff changeset
145 {
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
146 try {
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
147 CREATE_SEMAPHORE.acquire();
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
148 }
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
149 catch (InterruptedException ie) {
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
150 throw new ServerException(ERROR_CREATE_ARTIFACT);
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
151 }
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
152 try {
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
153 HttpClient client = new HttpClientImpl(serverUrl, locale);
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
154
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
155 try {
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
156 return (Artifact) client.create(doc, new FLYSArtifactCreator());
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
157 }
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
158 catch (ConnectionException ce) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6450
diff changeset
159 log.error(ce, ce);
6450
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
160 }
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
161
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
162 throw new ServerException(ERROR_CREATE_ARTIFACT);
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
163 }
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
164 finally {
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
165 CREATE_SEMAPHORE.release();
eb4d0950ae87 GWT client: prevent too many create artifact calls at the same time by limiting them to 5.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6136
diff changeset
166 }
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
167 }
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
168
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
169
1318
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
170 /**
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
171 * Create CreationFilter from Recommendation.Filter.
ecd0243bc09e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 905
diff changeset
172 */
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
173 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
174
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
175 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
176 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
177 }
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
178
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
179 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
180
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
181 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
182
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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 }
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
191 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
192 }
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
193
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
194 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
195 }
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
196 }
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
197 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org