Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java @ 1346:a3c04eb326f3
Allowed to load Artifacts with different factories in one go.
flys-client/trunk@3009 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 18 Oct 2011 14:08:36 +0000 |
parents | 489e6a82fe84 |
children | ab8eb2f544f2 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Tue Oct 18 12:33:23 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java Tue Oct 18 14:08:36 2011 +0000 @@ -22,6 +22,19 @@ { public static final String ERROR_LOAD_ARTIFACT = "error_load_artifact"; + + /** + * Clones or creates a single artifact and adds it to a collection. + * + * Note that in contrast to loadMany, always the given factory is used + * to clone the artifact. + * + * @param parent collection to add recommendation to. + * @param recom recommendation to create clone for. + * @param factory factory to use. + * @param url servers url. + * @param locale the locale to translate messages. + */ public Artifact load( Collection parent, Recommendation recom, @@ -54,11 +67,17 @@ /** - * Clone one or more artifacts and add it to a collection, avoid duplicates. + * Clone/create one or more artifacts and add it to a collection, avoiding + * duplicates. * - * @param parent Collection where clones will be added to. - * @param recommendations definitions of source of clone. - * @param factory name of factory to use when cloning artifacts. + * @param parent Collection where clones will be added to. + * @param recoms definitions of source of clone. + * @param factory name of factory to use when cloning artifacts (can be + * null in which case the recommendations getFactory() will + * be used. + * @param url servers url. + * @param locale the locale to translate messages. + * * @return cloned artifacts (same artifact might be contained multiple * times). */ @@ -71,6 +90,7 @@ ) throws ServerException { System.out.println("LoadArtifactServiceImpl.loadMany"); + ArrayList<Artifact> artifacts = new ArrayList<Artifact>(); HashMap<Recommendation, Artifact> cloneMap = new HashMap<Recommendation, Artifact>(); @@ -89,8 +109,14 @@ } else { // Not already cloned. + String realFactory = factory != null + ? factory + : recom.getFactory(); + + System.out.println("One will be cloned with : " + realFactory); + Artifact clone = ArtifactHelper.createArtifact( - url, locale, factory, recom); + url, locale, realFactory, recom); if (clone != null) { System.out.println("LoadArtifactServiceImple: Successfully "