Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java @ 2040:cd9bcdcf6597
Make only newest CrossSection intially active in diagrams.
flys-artifacts/trunk@3526 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 22 Dec 2011 12:52:12 +0000 |
parents | 986820795c3b |
children | f021080cb409 |
comparison
equal
deleted
inserted
replaced
2039:f7e2a84a6d88 | 2040:cd9bcdcf6597 |
---|---|
45 public static final String DATA_KM = "cross_section.km"; | 45 public static final String DATA_KM = "cross_section.km"; |
46 | 46 |
47 /** Name of data item keeping the database id of this c.s.. */ | 47 /** Name of data item keeping the database id of this c.s.. */ |
48 public static final String DATA_DBID = "cross_section.dbid"; | 48 public static final String DATA_DBID = "cross_section.dbid"; |
49 | 49 |
50 /** Name of data item keeping the database id of this c.s.. */ | 50 /** Name of data item flagging whether we think that we are master. */ |
51 public static final String DATA_IS_MASTER = "cross_section.master?"; | 51 public static final String DATA_IS_MASTER = "cross_section.master?"; |
52 | |
53 /** Name of data item flagging whether we are the newest. */ | |
54 public static final String DATA_IS_NEWEST = "cross_section.newest?"; | |
52 | 55 |
53 /** Own logger. */ | 56 /** Own logger. */ |
54 private static final Logger logger = | 57 private static final Logger logger = |
55 Logger.getLogger(CrossSectionArtifact.class); | 58 Logger.getLogger(CrossSectionArtifact.class); |
56 | 59 |
83 logger.debug("CrossSectionArtifacts db-id: " + ids); | 86 logger.debug("CrossSectionArtifacts db-id: " + ids); |
84 } | 87 } |
85 else { | 88 else { |
86 throw new IllegalArgumentException("No attribute 'ids' found!"); | 89 throw new IllegalArgumentException("No attribute 'ids' found!"); |
87 } | 90 } |
88 | |
89 | |
90 addStringData(DATA_IS_MASTER, "0"); | |
91 | 91 |
92 List<Facet> fs = new ArrayList<Facet>(); | 92 List<Facet> fs = new ArrayList<Facet>(); |
93 CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids)); | 93 CrossSection cs = CrossSectionFactory.getCrossSection(Integer.valueOf(ids)); |
94 CrossSectionLine csl = cs.getLines().get(0); | 94 CrossSectionLine csl = cs.getLines().get(0); |
95 // Find min-km of cross sections, than set DATA_KM to min(DATA_KM, minCross). | 95 // Find min-km of cross sections, than set DATA_KM to min(DATA_KM, minCross). |
98 if (masterKm < csl.getKm().doubleValue()) { | 98 if (masterKm < csl.getKm().doubleValue()) { |
99 addStringData(DATA_KM, csl.getKm().toString()); | 99 addStringData(DATA_KM, csl.getKm().toString()); |
100 } | 100 } |
101 } | 101 } |
102 fs.add(new CrossSectionFacet(0, cs.getDescription())); | 102 fs.add(new CrossSectionFacet(0, cs.getDescription())); |
103 | |
104 // Find out if we are newest. | |
105 boolean isNewest = CrossSectionFactory.isNewest(cs); | |
106 String newString = (isNewest) ? "1" : "0"; | |
107 addStringData(DATA_IS_NEWEST, newString); | |
108 addStringData(DATA_IS_MASTER, newString); | |
103 | 109 |
104 StaticState state = (StaticState) getCurrentState(context); | 110 StaticState state = (StaticState) getCurrentState(context); |
105 | 111 |
106 if (!fs.isEmpty()) { | 112 if (!fs.isEmpty()) { |
107 facets.put(getCurrentStateId(), fs); | 113 facets.put(getCurrentStateId(), fs); |
250 oldDiff = diff; | 256 oldDiff = diff; |
251 oldLine = line; | 257 oldLine = line; |
252 } | 258 } |
253 return oldLine; | 259 return oldLine; |
254 } | 260 } |
261 | |
262 | |
263 /** | |
264 * Determines Facets initial disposition regarding activity (think of | |
265 * selection in Client ThemeList GUI). This will be checked one time | |
266 * when the facet enters a collections describe document. | |
267 * | |
268 * @param outputName Ignored. | |
269 * @param facetName Ignored. | |
270 * @param index Ignored. | |
271 * @return 0 if not active | |
272 */ | |
273 @Override | |
274 public int getInitialFacetActivity(String outputName, String facetName, int index) { | |
275 return (getDataAsString(DATA_IS_NEWEST) != null | |
276 && getDataAsString(DATA_IS_NEWEST).equals("1")) ? 1 : 0; | |
277 } | |
255 } | 278 } |
256 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 279 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |