annotate artifacts/src/main/java/org/dive4elements/river/collections/AttributeWriter.java @ 8325:02782ed6c8de

Reduce misspelled, superfluous logging.
author "Tom Gottfried <tom@intevation.de>"
date Thu, 25 Sep 2014 12:21:47 +0200
parents e4606eae8ea5
children 5e38e2924c07
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
9 package org.dive4elements.river.collections;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
11 import java.util.ArrayList;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import java.util.List;
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
13 import java.util.HashMap;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import java.util.Map;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import org.apache.log4j.Logger;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
18 import org.dive4elements.artifacts.ArtifactDatabase;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
19 import org.dive4elements.artifacts.ArtifactDatabaseException;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
21 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
22 import org.dive4elements.artifactdatabase.state.FacetActivity;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
23 import org.dive4elements.artifactdatabase.state.Output;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
25 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5150
diff changeset
26 import org.dive4elements.river.artifacts.model.ManagedFacet;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
28 /**
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
29 * Create attribute- element of describe document of an ArtifactCollection.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
30 * The attribute-element contains the merged output of all outputmodes and
1780
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1709
diff changeset
31 * facets that are part of the collection.
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
32 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public class AttributeWriter {
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
35 /** ArtifactDatabase used to fetch Artifacts. */
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
36 protected ArtifactDatabase db = null;
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
37
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 protected Map<String, Output> oldAttr;
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
39
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 protected Map<String, Output> newAttr;
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
42 /** List of already seen facets. */
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
43 protected List<Facet> oldFacets;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
44
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
45 /** List of "new" facets. */
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
46 protected List<Facet> newFacets;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
47
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
48 /**
6647
d4a3031448d3 Fix doc typo.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6140
diff changeset
49 * "Compatibility matrix", maps list of facet names to output names.
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
50 * Any facet that is not found in the list for a specific output will
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
51 * not be added to the resulting document.
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
52 */
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
53 protected Map<String, List<String>> compatibilities;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
54
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
55
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
56 /** The result of the <i>write()</i> operation.*/
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
57 protected CollectionAttribute attribute;
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
58
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
59
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
60 private static Logger log = Logger.getLogger(AttributeWriter.class);
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
63 /**
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
64 * Create a AttributeWriter.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
65 * Attributes not present in newAttr will not be included in the document.
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
66 * @param db Database to fetch artifacts.
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
67 * @param oldAttr "Old" (possibly user-changed) outputs.
1780
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1709
diff changeset
68 * @param newAttr "New" (eventually re-read in its original, unchanged
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
69 * form) outputs.
4924
725de57d3774 AttributeWriter: Doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4499
diff changeset
70 * @param matrix Compatibility matrix, mapping output names to list of
725de57d3774 AttributeWriter: Doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4499
diff changeset
71 * facet names that can be included in this out.
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
72 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 public AttributeWriter(
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
74 ArtifactDatabase db,
1993
85132c9edd64 Make reuse of the old CollectionAttribute during the describe() operation of FLYSArtifactCollection - remove the old facets only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1984
diff changeset
75 CollectionAttribute attribute,
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 Map<String, Output> oldAttr,
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
77 List<Facet> oldFacets,
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
78 Map<String, Output> newAttr,
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
79 List<Facet> newFacets,
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
80 Map<String, List<String>> matrix)
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 {
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
82 this.db = db;
1993
85132c9edd64 Make reuse of the old CollectionAttribute during the describe() operation of FLYSArtifactCollection - remove the old facets only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1984
diff changeset
83 this.attribute = attribute;
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
84 this.oldAttr = oldAttr;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
85 this.newAttr = newAttr;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
86 this.oldFacets = oldFacets;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
87 this.newFacets = newFacets;
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
88 this.compatibilities = matrix;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
92 /**
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
93 * Create document by merging outputs given in
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
94 * constructor.
1780
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1709
diff changeset
95 *
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
96 * The "new" set rules about existance of attributes, so anything not
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
97 * present in it will not be included in the resulting document.
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
98 * The "old" set rules about the content of attributes (as user changes
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
99 * are recorded here and not in the new set).
1780
b503d92dd709 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1709
diff changeset
100 *
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
101 * @return document with merged outputs as described.
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
102 */
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
103 protected CollectionAttribute write() {
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
104
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
105 boolean debug = log.isDebugEnabled();
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
106
1995
f114c0d55d19 Little optimisation when writing CollectionAttributes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1993
diff changeset
107 for (Map.Entry<String, Output> entry: newAttr.entrySet()) {
f114c0d55d19 Little optimisation when writing CollectionAttributes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1993
diff changeset
108 String outName = entry.getKey();
f114c0d55d19 Little optimisation when writing CollectionAttributes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1993
diff changeset
109 Output a = entry.getValue();
1996
c6432e8ea31e Bugfix: add new Outputs during merge process in AttributeWriter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1995
diff changeset
110
4925
57609ffb3843 AttributeWriter: Use new CollectionAttribute.hasOutput .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4924
diff changeset
111 if (!attribute.hasOutput(outName)) {
1996
c6432e8ea31e Bugfix: add new Outputs during merge process in AttributeWriter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1995
diff changeset
112 attribute.addOutput(outName, a);
c6432e8ea31e Bugfix: add new Outputs during merge process in AttributeWriter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1995
diff changeset
113 }
c6432e8ea31e Bugfix: add new Outputs during merge process in AttributeWriter.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1995
diff changeset
114
1993
85132c9edd64 Make reuse of the old CollectionAttribute during the describe() operation of FLYSArtifactCollection - remove the old facets only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1984
diff changeset
115 attribute.clearFacets(outName);
2094
22732713c54d Made classes to merge Collection Outs more verbose for better debugging.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2079
diff changeset
116
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
117 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
118 log.debug("Merge Output: " + outName);
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
119 log.debug(" old Facets: " + oldFacets.size());
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
120 log.debug(" new Facets: " + newFacets.size());
2094
22732713c54d Made classes to merge Collection Outs more verbose for better debugging.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2079
diff changeset
121 }
22732713c54d Made classes to merge Collection Outs more verbose for better debugging.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2079
diff changeset
122
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
123 writeOutput(a.getName(), newFacets, oldFacets);
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125
2079
ca6ccf722c24 #447 removed empty Outputs from Collection's attribute.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1996
diff changeset
126 // THIS CALL IS ABSOLUTELY NECESSARY!
ca6ccf722c24 #447 removed empty Outputs from Collection's attribute.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1996
diff changeset
127 attribute.cleanEmptyOutputs();
ca6ccf722c24 #447 removed empty Outputs from Collection's attribute.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1996
diff changeset
128
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
129 return attribute;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131
1634
cc47828a1390 Added documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1628
diff changeset
132
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
133 /**
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
134 * @param outputName the "new" outputs name
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
135 * @param newOutFacets Facets of the new outputs
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
136 * @param oldOutFacets Facets of the old outputs (can be null)
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
137 */
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 protected void writeOutput(
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
139 String outputName,
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
140 List<Facet> newOutFacets,
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
141 List<Facet> oldOutFacets
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
142 ) {
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
143 List<String> compatFacets = this.compatibilities.get(outputName);
2094
22732713c54d Made classes to merge Collection Outs more verbose for better debugging.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2079
diff changeset
144
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
145 try {
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
146 writeFacets(outputName, newOutFacets, oldOutFacets, compatFacets);
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
147 }
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
148 catch (ArtifactDatabaseException ade) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
149 log.error(ade, ade);
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
150 }
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
154 /**
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
155 * @param newFacets the new facets
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
156 * @param oldFacets the old facets
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
157 * @param compatibleFacets List of facets to accept
1831
490ab097f58c Prevent empty output-nodes in flyscollections attributes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1810
diff changeset
158 * @return true if any facets are written to the out.
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
159 */
1831
490ab097f58c Prevent empty output-nodes in flyscollections attributes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1810
diff changeset
160 protected boolean writeFacets(
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
161 String outputName,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
162 List<Facet> newFacets,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
163 List<Facet> oldFacets,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
164 List<String> compatibleFacets)
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
165 throws ArtifactDatabaseException
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166 {
1788
d5d2bffb26ca Avoid NPE when compatibility matrix is empty for given output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1785
diff changeset
167 if (compatibleFacets == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
168 log.warn("No compatible facets, not generating out " + outputName + ".");
1831
490ab097f58c Prevent empty output-nodes in flyscollections attributes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1810
diff changeset
169 return false;
1788
d5d2bffb26ca Avoid NPE when compatibility matrix is empty for given output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1785
diff changeset
170 }
d5d2bffb26ca Avoid NPE when compatibility matrix is empty for given output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1785
diff changeset
171
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
172 int num = newFacets.size();
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
174 // Add all new Facets either in their old state or (if really
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
175 // new) as they are.
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
176 List<ManagedFacet> currentFacets = new ArrayList<ManagedFacet>();
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
177 List<ManagedFacet> genuinelyNewFacets = new ArrayList<ManagedFacet>();
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
178
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
179 boolean debug = log.isDebugEnabled();
4499
b74399bd0960 Improve debugging while merging outs and facets
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4433
diff changeset
180 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
181 log.debug("Compatible facets are " + compatibleFacets);
4499
b74399bd0960 Improve debugging while merging outs and facets
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4433
diff changeset
182 }
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
183
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
184 for (Facet fac: newFacets) {
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
185 ManagedFacet facet = (ManagedFacet) fac;
2094
22732713c54d Made classes to merge Collection Outs more verbose for better debugging.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2079
diff changeset
186
7178
12248d9eb326 Only filter the facets for unbound outs
Andre Heinecke <aheinecke@intevation.de>
parents: 6961
diff changeset
187 String bondage = facet.getBoundToOut();
12248d9eb326 Only filter the facets for unbound outs
Andre Heinecke <aheinecke@intevation.de>
parents: 6961
diff changeset
188 if (bondage != null && bondage.equals(outputName)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
189 log.debug("Adding bound facet regardless of compatibility: " +
7178
12248d9eb326 Only filter the facets for unbound outs
Andre Heinecke <aheinecke@intevation.de>
parents: 6961
diff changeset
190 facet.getName());
12248d9eb326 Only filter the facets for unbound outs
Andre Heinecke <aheinecke@intevation.de>
parents: 6961
diff changeset
191 } else if (!compatibleFacets.contains(facet.getName())) {
8325
02782ed6c8de Reduce misspelled, superfluous logging.
"Tom Gottfried <tom@intevation.de>"
parents: 8202
diff changeset
192 log.debug("Skip incompatible facet " + facet.getName());
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
193 continue;
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
194 } else if (facet.getBoundToOut() != null &&
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
195 !facet.getBoundToOut().equals(outputName)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
196 log.debug("Skip facet " + facet.getName() +
6140
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
197 " because it is bound to: " + facet.getBoundToOut());
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
198 continue;
60b94dec104b Add handling of bound artifacts.
Andre Heinecke <aheinecke@intevation.de>
parents: 5994
diff changeset
199 } else {
8325
02782ed6c8de Reduce misspelled, superfluous logging.
"Tom Gottfried <tom@intevation.de>"
parents: 8202
diff changeset
200 log.debug("Compatible facet " + facet.getName() +
02782ed6c8de Reduce misspelled, superfluous logging.
"Tom Gottfried <tom@intevation.de>"
parents: 8202
diff changeset
201 " is bound to: " + facet.getBoundToOut());
4025
721d55bdab9e Add warning if no compatible facet is found
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3558
diff changeset
202 }
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
204 ManagedFacet picked = pickFacet(facet, oldFacets);
1785
661dfad9910a Use compatibility matrix when creating collections output.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1780
diff changeset
205
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
206 if (facet.equals(picked)) {
6961
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
207 if (!facetInTwoOuts(facet, genuinelyNewFacets)) {
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
208 genuinelyNewFacets.add(picked);
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
209 }
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
210 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
211 log.debug("Skip clone facet that shall be present in two outs");
6961
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
212 }
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
213 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
214 else {
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
215 currentFacets.add(picked);
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
216 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
217 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
218
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
219 FacetActivity.Registry registry = FacetActivity.Registry.getInstance();
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
220
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
221 // With each genuinely new Facet, figure out whether it comes to live
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
222 // in/activate.
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
223 for (ManagedFacet newMF: genuinelyNewFacets) {
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
224 D4EArtifact flys =
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
225 (D4EArtifact)db.getRawArtifact(newMF.getArtifact());
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
226
3558
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
227 boolean isActive = registry.isInitialActive(
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
228 flys.getName(), flys, newMF, outputName);
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
229
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
230 newMF.setActive(isActive ? 1 : 0);
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
231 }
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
232
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
233 // For each genuinely new Facet check positional conflicts.
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
234 for (ManagedFacet newMF: genuinelyNewFacets) {
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
235 boolean conflicts = true;
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
236 // Loop until all conflicts resolved.
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
237 while (conflicts) {
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
238 conflicts = false;
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
239 for (ManagedFacet oldMF: currentFacets) {
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
240 if (newMF.getPosition() == oldMF.getPosition()) {
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
241 conflicts = true;
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
242 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
243 log.debug(
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
244 "Positional conflict while merging " +
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
245 "facets, pushing newest facet 1 up (" +
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
246 newMF.getPosition() + ")");
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
247 }
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
248 newMF.setPosition(newMF.getPosition() + 1);
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
249 break;
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
250 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
251 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
252 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
253 currentFacets.add(newMF);
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
254 }
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
255
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
256 // Fill/correct "gaps" (e.g. position 1,2,5 are taken, after gap filling
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
257 // expect positions 1,2,3 [5->3])
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
258 // Preparations to be able to detect gaps.
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
259 Map<Integer, ManagedFacet> mfmap =
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
260 new HashMap<Integer, ManagedFacet>();
6958
d2bf655bd278 AttributeWriter: Even better variable name.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6957
diff changeset
261 int maxPosition = 0;
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
262 for (ManagedFacet mf: currentFacets) {
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
263 int pos = mf.getPosition();
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
264 mfmap.put(Integer.valueOf(pos), mf);
6958
d2bf655bd278 AttributeWriter: Even better variable name.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6957
diff changeset
265 if (pos > maxPosition) maxPosition = pos;
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
266 }
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
267
6957
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
268 // TODO issue1458: debug what happens
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
269
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
270 // Finally do gap correction
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
271 // (note that posistions start at 1, not at zero).
6958
d2bf655bd278 AttributeWriter: Even better variable name.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6957
diff changeset
272 if (maxPosition != currentFacets.size()) {
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
273 int gap = 0;
6958
d2bf655bd278 AttributeWriter: Even better variable name.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6957
diff changeset
274 for (int i = 1; i <= maxPosition; i++) {
1810
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
275 ManagedFacet mf = mfmap.get(Integer.valueOf(i));
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
276 if (mf == null) {
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
277 gap++;
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
278 continue;
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
279 }
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
280 mf.setPosition(mf.getPosition() - gap);
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
281 }
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
282 }
193a916d1ab5 Pass output name to artifacts getInitialFacetActivity, prevent gaps in collection attributes outputs facets positions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1788
diff changeset
283
1639
12235a2ace21 Add positional-conflict-awareness when merging Facets in attribute
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1635
diff changeset
284 // Now add all facets.
6957
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
285 for (ManagedFacet facet: currentFacets) {
67e01d9c0519 AttributeWriter: Slightly improved variable naming and comments.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6647
diff changeset
286 attribute.addFacet(outputName, facet);
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287 }
1831
490ab097f58c Prevent empty output-nodes in flyscollections attributes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1810
diff changeset
288
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2094
diff changeset
289 return !currentFacets.isEmpty();
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292
6961
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
293 /** Returns true if a likely clone of facet is
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
294 * contained in genuinelyNewFacets, as happens when same facet is defined
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
295 * for two outs. */
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
296 private boolean facetInTwoOuts(ManagedFacet facet, List<ManagedFacet> genuinelyNewFacets) {
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
297 for (ManagedFacet otherFacet: genuinelyNewFacets) {
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
298 if (facet.isSame(otherFacet)) {
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
299 return true;
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
300 }
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
301 }
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
302 return false;
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
303 }
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
304
6bc333c162d1 issue1458: Avoid facet duplicates.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6958
diff changeset
305
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
306 /**
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
307 * Returns the facet to be added to Document.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
308 * Return the new facet only if the "same" facet was not present before.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
309 * Return the "old" facet otherwise (user-defined information sticks
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
310 * to it).
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
311 * @param facet the new facet.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
312 * @param oldFacets the old facets, new facet is compared against each of
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
313 * these.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
314 * @return facet if genuinely new, matching old facet otherwise.
1628
16c74ca3586e Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1171
diff changeset
315 */
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
316 protected ManagedFacet pickFacet(ManagedFacet facet, List<Facet> oldFacets)
1709
f643ea084213 Allow simple codepaths to have Facets initially being 'inactive' (wrt rendering).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1639
diff changeset
317 {
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
318 if (oldFacets == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7178
diff changeset
319 log.debug("No old facets to compare a new to found.");
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
320 return facet;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
321 }
1976
0b466bd4ab24 Introduced a CollectionAttribute class that stores the information provided by the Collection's attribute document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1831
diff changeset
322
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
323 String hash = facet.getName() + facet.getIndex() + facet.getArtifact();
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
324
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
325 // Compare "new" facet with all old facets.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
326 // Take oldFacet if that facet was already present (otherwise
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
327 // information is lost, the new one otherwise.
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
328 for (Facet oFacet: oldFacets) {
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
329 ManagedFacet oldFacet = (ManagedFacet) oFacet;
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
330 String oldHash = oldFacet.getName()
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
331 + oldFacet.getIndex()
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
332 + oldFacet.getArtifact();
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
333 if (hash.equals(oldHash)) {
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
334 return oldFacet;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
335 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
336 }
1635
1b5204203e18 Minor refactoring, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1634
diff changeset
337 return facet;
346
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
338 }
16161de47662 The Attributes of a collection are written into its DESCRIBE now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
339 }
705
853dceead0f4 Only generate facets when needed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 694
diff changeset
340 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org