[PATCH 3 of 4] Add getArtifactsByName to collection

Wald Commits scm-commit at wald.intevation.org
Thu Jul 18 13:16:56 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1374146097 -7200
# Node ID df1140486ba49d025581e91eaf579dd5fa92e84f
# Parent  38ee580a30cb830fcfbb2e4950138368be6d8bea
Add getArtifactsByName to collection

    This helps to escape the narrow view of an artifact and
    use the data from other artifacts in that collection.

diff -r 38ee580a30cb -r df1140486ba4 artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java
--- a/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java	Thu Jul 18 13:13:51 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/collections/D4EArtifactCollection.java	Thu Jul 18 13:14:57 2013 +0200
@@ -628,6 +628,30 @@
         return persistent != null ? persistent.getArtifact() : null;
     }
 
-
+    /**
+     * Returns artifacts that name facetName.
+     *
+     * @param name The Artifact name to search
+     * @param context The CallContext
+     *
+     * @return a list of artifacts matching this name.
+     */
+    public List<Artifact> getArtifactsByName(String name, CallContext context)
+    {
+        log.debug("Searching for Artifacts: " + name);
+        List<Artifact> ret =  new ArrayList<Artifact>();
+        try {
+            for (String uuid: getArtifactUUIDs(context)) {
+                D4EArtifact subArt = (D4EArtifact)getArtifact(uuid, context);
+                if (subArt.getName() != null && subArt.getName().equals(name)) {
+                    ret.add(subArt);
+                }
+            }
+        } catch (ArtifactDatabaseException e) {
+            log.error("Unexpected Error!", e);
+        } finally {
+            return ret;
+        }
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4elements-commits mailing list