Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/server/ArtifactHelper.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
children |
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 |
9726 | 14 import org.apache.logging.log4j.Logger; |
15 import org.apache.logging.log4j.LogManager; | |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1318
diff
changeset
|
16 |
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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
22 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
23 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
|
24 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
25 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
26 import org.dive4elements.artifacts.httpclient.http.HttpClient; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
27 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
28 import org.dive4elements.artifacts.httpclient.utils.ArtifactNamespaceContext; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
29 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
|
30 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
31 import org.dive4elements.river.client.shared.exceptions.ServerException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
32 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
|
33 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
34 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
|
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 /** |
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 * @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
|
38 */ |
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 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
|
40 |
6043 | 41 /** Private logging instance. */ |
9726 | 42 private static final Logger log = LogManager.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
|
43 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1318
diff
changeset
|
44 |
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
|
45 /** 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
|
46 * 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
|
47 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
|
48 |
6043 | 49 /** Name of the factory to generate a GaugeDischargeCurveArtifact. */ |
8856 | 50 private static final String GAUGE_DISCHARGE_CURVE_ARTIFACT = |
51 "gaugedischargecurve"; | |
6043 | 52 |
53 /** Name of the factory to generate a MainvaluesArtifact. */ | |
54 private static final String MAINVALUE_ARTIFACT_FACTORY = "mainvalue"; | |
55 | |
5503
b660090b417d
Create a new sq relation project on measurement station record click.
Raimund Renkert <rrenkert@intevation.de>
parents:
3865
diff
changeset
|
56 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
|
57 |
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
|
58 // 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
|
59 // 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
|
60 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
|
61 |
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 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
|
63 |
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
|
64 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
|
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 |
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 |
1318
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
68 /** |
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
69 * @param factory ArtifactFactory to use. |
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
70 */ |
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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 { |
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 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
|
79 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
|
80 CreationFilter filter; |
6136
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
81 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
|
82 |
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
|
83 if (recommendation != null) { |
6136
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
84 uuid = recommendation.getMasterArtifact(); |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
85 ids = recommendation.getIDs(); |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
86 filter = convertFilter(recommendation.getFilter()); |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
87 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
|
88 } |
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
|
89 else { |
6136
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
90 uuid = null; |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
91 ids = null; |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
92 filter = null; |
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
93 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
|
94 } |
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
|
95 |
8710
093146703b98
Improve ArtifactHelper creation debug output
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8313
diff
changeset
|
96 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
|
97 " 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
|
98 Document create = ClientProtocolUtils.newCreateDocument( |
6136
8d9859d776e5
Handle target_out in the Recommendation / Client datacage code.
Andre Heinecke <aheinecke@intevation.de>
parents:
6044
diff
changeset
|
99 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
|
100 |
3865
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
101 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
|
102 } |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
103 |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
104 /** |
6044
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
105 * 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
|
106 * |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
107 * @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
|
108 */ |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
109 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
|
110 String serverUrl, |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
111 String locale, |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
112 String river, |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
113 Long gaugeRef) |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
114 throws ServerException |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
115 { |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
116 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
|
117 MAINVALUE_ARTIFACT_FACTORY); |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
118 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
119 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
|
120 create, |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
121 ArtifactNamespaceContext.NAMESPACE_URI, |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
122 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
123 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
124 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
|
125 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
126 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
|
127 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
|
128 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
129 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
|
130 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
|
131 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
132 root.appendChild(eriver); |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
133 root.appendChild(egauge); |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
134 |
477d2d18452e
Implement function to spawn a mainvalueartifact, given gauge and river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6043
diff
changeset
|
135 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
|
136 } |
3865
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
137 |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
138 /** |
6043 | 139 * 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
|
140 */ |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
141 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
|
142 String serverUrl, |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
143 String locale, |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
144 Document doc) |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
145 throws ServerException |
436eec3be6ff
Allow to create a discharge curve from a gauge info
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
1367
diff
changeset
|
146 { |
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
|
147 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
|
148 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
|
149 } |
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
|
150 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
|
151 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
|
152 } |
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
|
153 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
|
154 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
|
155 |
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
|
156 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
|
157 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
|
158 } |
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
|
159 catch (ConnectionException ce) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6450
diff
changeset
|
160 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
|
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 |
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 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
|
164 } |
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 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
|
166 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
|
167 } |
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
|
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 |
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
|
170 |
1318
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
171 /** |
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
172 * Create CreationFilter from Recommendation.Filter. |
ecd0243bc09e
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
173 */ |
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
|
174 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
|
175 |
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 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
|
177 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
|
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 |
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 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
|
181 |
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 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
|
183 |
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 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 } |
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 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
|
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 |
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 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
|
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 } |
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
|
198 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |