# HG changeset patch # User Felix Wolfsteller # Date 1318946916 0 # Node ID a3c04eb326f3415d9bce3487d0c640a0b4b2e023 # Parent 92074508a38759036eaa19aad7f366cd690d1c91 Allowed to load Artifacts with different factories in one go. flys-client/trunk@3009 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 92074508a387 -r a3c04eb326f3 flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Oct 18 12:33:23 2011 +0000 +++ b/flys-client/ChangeLog Tue Oct 18 14:08:36 2011 +0000 @@ -1,3 +1,9 @@ +2011-10-18 Felix Wolfsteller + + * src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java: + Allow to load Artifacts with different factories in one go (as + fallback). Documentation added. + 2011-10-18 Raimund Renkert * src/main/java/de/intevation/flys/client/shared/model/Style.java, diff -r 92074508a387 -r a3c04eb326f3 flys-client/src/main/java/de/intevation/flys/client/server/LoadArtifactServiceImpl.java --- 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 artifacts = new ArrayList(); HashMap cloneMap = new HashMap(); @@ -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 "