# HG changeset patch # User Sascha L. Teichmann # Date 1314029140 0 # Node ID bd1b751deab30ec6da3a9e7a909193b56058d646 # Parent 61c051e53f9bc205b12f3d0d8969f1a3579e6231 Added optional positive filter for outs and facets. flys-artifacts/trunk@2526 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 61c051e53f9b -r bd1b751deab3 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Aug 22 15:25:48 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Aug 22 16:05:40 2011 +0000 @@ -1,3 +1,12 @@ +2011-08-22 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Added some code to filter outs/facets by an optional positive list. + This is needed to only expose parts of the facets. This + is needed for artifacts which are loaded into a collection. + TODO: create the filter from the XML document passed at creation + time. + 2011-08-22 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Moved all diff -r 61c051e53f9b -r bd1b751deab3 flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon Aug 22 15:25:48 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon Aug 22 16:05:40 2011 +0000 @@ -98,6 +98,9 @@ /** The list of facets supported by this artifact.*/ protected Map> facets; + /** out -> facets */ + protected Map> filterFacets; + /** * The default constructor that creates an empty FLYSArtifact. @@ -528,6 +531,45 @@ return getCurrentStateId() + hash; } + protected List filterOutputs(List outs) { + + if (filterFacets == null || filterFacets.isEmpty()) { + return outs; + } + + List filtered = new ArrayList(); + + for (Output out: outs) { + + List fFacets = filterFacets.get(out.getName()); + if (fFacets != null) { + + List resultFacets = new ArrayList(); + + for (Facet facet: out.getFacets()) { + for (Facet fFacet: fFacets) { + if (facet.getIndex() == fFacet.getIndex() + && facet.getName().equals(fFacet.getName())) { + resultFacets.add(facet); + break; + } + } + } + + if (!resultFacets.isEmpty()) { + DefaultOutput nout = new DefaultOutput( + out.getName(), + out.getDescription(), + out.getMimeType(), + resultFacets); + filtered.add(nout); + } + } + } + + return filtered; + } + public List getOutputs(Object context) { List stateIds = getPreviousStateIds(); @@ -544,7 +586,7 @@ generated.addAll(getCurrentOutputs(context)); - return generated; + return filterOutputs(generated); }