Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java @ 1366:d0eb2202ffbe
Added a BaseServlet that is used to setup config things like log4j.
flys-client/trunk@3067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 25 Oct 2011 11:07:14 +0000 |
parents | a3c04eb326f3 |
children | ab8eb2f544f2 |
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 |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
3 import java.util.ArrayList; |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
4 import java.util.HashMap; |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
5 |
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
|
6 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
|
7 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
|
8 import de.intevation.flys.client.shared.model.Collection; |
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 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
|
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 de.intevation.flys.client.client.services.LoadArtifactService; |
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 |
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 /** |
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 * This service creates a new Artifact based on a given Recommendation and puts |
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 * this new artifact into a specified Collection. |
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 * |
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 * @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
|
18 */ |
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 public class LoadArtifactServiceImpl |
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 extends ArtifactServiceImpl |
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 implements LoadArtifactService |
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 { |
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 public static final String ERROR_LOAD_ARTIFACT = "error_load_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
|
24 |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
25 |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
26 /** |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
27 * Clones or creates a single artifact and adds it to a collection. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
28 * |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
29 * Note that in contrast to loadMany, always the given factory is used |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
30 * to clone the artifact. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
31 * |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
32 * @param parent collection to add recommendation to. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
33 * @param recom recommendation to create clone for. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
34 * @param factory factory to use. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
35 * @param url servers url. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
36 * @param locale the locale to translate messages. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
37 */ |
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
|
38 public Artifact load( |
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 Collection parent, |
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 Recommendation recom, |
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
|
41 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
|
42 String url, |
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 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
|
44 ) |
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 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
|
46 System.out.println( |
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 "LoadArtifactServiceImpl.load: " + recom.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
|
48 |
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
|
49 // 1) Clone the Artifact specified in >>recom<< |
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
|
50 Artifact clone = ArtifactHelper.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
|
51 url, locale, factory, recom); |
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 |
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 if (clone != 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
|
54 System.out.println("Successfully create Artifact Clone. Add now!"); |
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 Collection c = CollectionHelper.addArtifact( |
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 parent, clone, url, 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
|
57 |
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
|
58 if (c != 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
|
59 System.out.println("Successfully added Clone to Collection."); |
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 |
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 return clone; |
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 } |
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 |
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 throw new ServerException(ERROR_LOAD_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
|
66 } |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
67 |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
68 |
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
69 /** |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
70 * Clone/create one or more artifacts and add it to a collection, avoiding |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
71 * duplicates. |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
72 * |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
73 * @param parent Collection where clones will be added to. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
74 * @param recoms definitions of source of clone. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
75 * @param factory name of factory to use when cloning artifacts (can be |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
76 * null in which case the recommendations getFactory() will |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
77 * be used. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
78 * @param url servers url. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
79 * @param locale the locale to translate messages. |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
80 * |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
81 * @return cloned artifacts (same artifact might be contained multiple |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
82 * times). |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
83 */ |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
84 public Artifact[] loadMany( |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
85 Collection parent, |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
86 Recommendation[] recoms, |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
87 String factory, |
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
88 String url, |
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
89 String locale |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
90 ) |
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
91 throws ServerException { |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
92 System.out.println("LoadArtifactServiceImpl.loadMany"); |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
93 |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
94 ArrayList<Artifact> artifacts = new ArrayList<Artifact>(); |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
95 HashMap<Recommendation, Artifact> cloneMap = |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
96 new HashMap<Recommendation, Artifact>(); |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
97 |
1272
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
98 // TODO Respect the index of what to clone. |
2ce5d7ac9e60
Cosmetics, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
913
diff
changeset
|
99 |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
100 // 1) Clone the Artifacts specified in >>recoms<< |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
101 for (Recommendation recom : recoms) { |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
102 // Do not do two clones of two identical recommendations. |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
103 Artifact prevClone = cloneMap.get(recom); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
104 if (prevClone != null) { |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
105 // Already cloned a recommendation like this. |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
106 System.out.println("LoadArtifactServiceImpl: Avoid reclones, " |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
107 + "clone already exists."); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
108 artifacts.add(prevClone); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
109 } |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
110 else { |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
111 // Not already cloned. |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
112 String realFactory = factory != null |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
113 ? factory |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
114 : recom.getFactory(); |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
115 |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
116 System.out.println("One will be cloned with : " + realFactory); |
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
117 |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
118 Artifact clone = ArtifactHelper.createArtifact( |
1346
a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1307
diff
changeset
|
119 url, locale, realFactory, recom); |
1307
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
120 |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
121 if (clone != null) { |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
122 System.out.println("LoadArtifactServiceImple: Successfully " |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
123 + "loaded Artifact Clone."); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
124 Collection c = CollectionHelper.addArtifact( |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
125 parent, clone, url, locale); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
126 |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
127 if (c != null) { |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
128 artifacts.add(clone); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
129 // Remember we cloned a recommendation like this. |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
130 cloneMap.put(recom, clone); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
131 } |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
132 else { |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
133 throw new ServerException(ERROR_LOAD_ARTIFACT); |
489e6a82fe84
Partial fix for flys/issue304 (Erweiterte Funktionen W-Differenzen).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1272
diff
changeset
|
134 } |
913
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
135 } |
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
136 } |
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
137 } |
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
138 return artifacts.toArray(new Artifact[artifacts.size()]); |
9976d99aea34
Added loadMany-function to LoadArtifactService.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
905
diff
changeset
|
139 } |
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
|
140 } |
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
|
141 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |