Mercurial > dive4elements > river
changeset 1056:bd1b751deab3
Added optional positive filter for outs and facets.
flys-artifacts/trunk@2526 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 22 Aug 2011 16:05:40 +0000 |
parents | 61c051e53f9b |
children | d4a5d3941cc0 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java |
diffstat | 2 files changed, 52 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + * 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 <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Moved all
--- 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<String, List<Facet>> facets; + /** out -> facets */ + protected Map<String, List<Facet>> filterFacets; + /** * The default constructor that creates an empty FLYSArtifact. @@ -528,6 +531,45 @@ return getCurrentStateId() + hash; } + protected List<Output> filterOutputs(List<Output> outs) { + + if (filterFacets == null || filterFacets.isEmpty()) { + return outs; + } + + List<Output> filtered = new ArrayList<Output>(); + + for (Output out: outs) { + + List<Facet> fFacets = filterFacets.get(out.getName()); + if (fFacets != null) { + + List<Facet> resultFacets = new ArrayList<Facet>(); + + 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<Output> getOutputs(Object context) { List<String> stateIds = getPreviousStateIds(); @@ -544,7 +586,7 @@ generated.addAll(getCurrentOutputs(context)); - return generated; + return filterOutputs(generated); }