comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 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
comparison
equal deleted inserted replaced
1055:61c051e53f9b 1056:bd1b751deab3
95 /** The data that have been inserted into this artifact.*/ 95 /** The data that have been inserted into this artifact.*/
96 protected Map<String, StateData> data; 96 protected Map<String, StateData> data;
97 97
98 /** The list of facets supported by this artifact.*/ 98 /** The list of facets supported by this artifact.*/
99 protected Map<String, List<Facet>> facets; 99 protected Map<String, List<Facet>> facets;
100
101 /** out -&gt; facets */
102 protected Map<String, List<Facet>> filterFacets;
100 103
101 104
102 /** 105 /**
103 * The default constructor that creates an empty FLYSArtifact. 106 * The default constructor that creates an empty FLYSArtifact.
104 */ 107 */
526 } 529 }
527 530
528 return getCurrentStateId() + hash; 531 return getCurrentStateId() + hash;
529 } 532 }
530 533
534 protected List<Output> filterOutputs(List<Output> outs) {
535
536 if (filterFacets == null || filterFacets.isEmpty()) {
537 return outs;
538 }
539
540 List<Output> filtered = new ArrayList<Output>();
541
542 for (Output out: outs) {
543
544 List<Facet> fFacets = filterFacets.get(out.getName());
545 if (fFacets != null) {
546
547 List<Facet> resultFacets = new ArrayList<Facet>();
548
549 for (Facet facet: out.getFacets()) {
550 for (Facet fFacet: fFacets) {
551 if (facet.getIndex() == fFacet.getIndex()
552 && facet.getName().equals(fFacet.getName())) {
553 resultFacets.add(facet);
554 break;
555 }
556 }
557 }
558
559 if (!resultFacets.isEmpty()) {
560 DefaultOutput nout = new DefaultOutput(
561 out.getName(),
562 out.getDescription(),
563 out.getMimeType(),
564 resultFacets);
565 filtered.add(nout);
566 }
567 }
568 }
569
570 return filtered;
571 }
572
531 573
532 public List<Output> getOutputs(Object context) { 574 public List<Output> getOutputs(Object context) {
533 List<String> stateIds = getPreviousStateIds(); 575 List<String> stateIds = getPreviousStateIds();
534 List<Output> generated = new ArrayList<Output>(); 576 List<Output> generated = new ArrayList<Output>();
535 577
542 generated.addAll(getOutputForState(state)); 584 generated.addAll(getOutputForState(state));
543 } 585 }
544 586
545 generated.addAll(getCurrentOutputs(context)); 587 generated.addAll(getCurrentOutputs(context));
546 588
547 return generated; 589 return filterOutputs(generated);
548 } 590 }
549 591
550 592
551 public List<Output> getCurrentOutputs(Object context) { 593 public List<Output> getCurrentOutputs(Object context) {
552 DefaultState cur = (DefaultState) getCurrentState(context); 594 DefaultState cur = (DefaultState) getCurrentState(context);

http://dive4elements.wald.intevation.org