comparison flys-artifacts/src/main/java/de/intevation/flys/collections/OutputParser.java @ 1779:2fe270661b20

Let Output and Attribute Parsers collect Facets during processing. flys-artifacts/trunk@3101 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 28 Oct 2011 09:08:48 +0000
parents e8a98eee816d
children 22732713c54d
comparison
equal deleted inserted replaced
1778:5a1d59926a72 1779:2fe270661b20
30 30
31 protected ArtifactDatabase db; 31 protected ArtifactDatabase db;
32 protected CallMeta meta; 32 protected CallMeta meta;
33 protected CallContext context; 33 protected CallContext context;
34 34
35 /** Map outputs name to Output. */
35 protected Map<String, Output> outs; 36 protected Map<String, Output> outs;
37
38 /** Map facets name to list of Facets. */
39 protected List<Facet> facets;
36 40
37 41
38 /** 42 /**
39 * @param db Database used to fetch artifacts, outputs and facets. 43 * @param db Database used to fetch artifacts, outputs and facets.
40 */ 44 */
41 public OutputParser(ArtifactDatabase db, CallContext context) { 45 public OutputParser(ArtifactDatabase db, CallContext context) {
42 this.db = db; 46 this.db = db;
43 this.meta = context.getMeta(); 47 this.meta = context.getMeta();
44 this.context = context; 48 this.context = context;
45 this.outs = new HashMap<String, Output>(); 49 this.outs = new HashMap<String, Output>();
50 this.facets = new ArrayList<Facet>();
46 } 51 }
47 52
48 53
49 /** 54 /**
50 * Gets raw facet with given id and sorts outputs in mapping. 55 * Gets raw artifact with given id and sorts outputs in mapping.
51 * Converts Facets to ManagedFacets on the way. 56 * Converts Facets to ManagedFacets on the way.
52 * @param uuid uuid of artifact to load from database. 57 * @param uuid uuid of artifact to load from database.
53 */ 58 */
54 public void parse(String uuid) 59 public void parse(String uuid)
55 throws ArtifactDatabaseException 60 throws ArtifactDatabaseException
78 else { 83 else {
79 logger.debug("OutputParser.parse: Use 'old' Output"); 84 logger.debug("OutputParser.parse: Use 'old' Output");
80 pos = o.getFacets().size() + 1; 85 pos = o.getFacets().size() + 1;
81 } 86 }
82 87
83 List<Facet> facets = facet2ManagedFacet(uuid, out.getFacets(), pos); 88 List<Facet> mfacets = facet2ManagedFacet(uuid, out.getFacets(), pos);
84 o.addFacets(facets); 89 o.addFacets(mfacets);
90 this.facets.addAll(mfacets);
85 } 91 }
86 } 92 }
87 93
88 94
89 /** 95 /**
92 public Map<String, Output> getOuts() { 98 public Map<String, Output> getOuts() {
93 return outs; 99 return outs;
94 } 100 }
95 101
96 102
103 /**
104 * Access all facets.
105 */
106 public List<Facet> getFacets() {
107 return this.facets;
108 }
109
110
111 /**
112 * Creates a list of ManagedFacets from list of Facets.
113 * @param pos Position of first facet (for each other the positions
114 * will be increased).
115 */
97 protected List<Facet> facet2ManagedFacet( 116 protected List<Facet> facet2ManagedFacet(
98 String uuid, 117 String uuid,
99 List<Facet> old, 118 List<Facet> old,
100 int pos) 119 int pos)
101 { 120 {

http://dive4elements.wald.intevation.org