comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/timeseries/TimeSeriesOutputState.java @ 540:80630520e25a

merged gnv-artifacts/0.4
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:13:49 +0200
parents f1dc3c2f9be7
children 6484464d2059
comparison
equal deleted inserted replaced
415:9f4a0b990d27 540:80630520e25a
1 /**
2 *
3 */
4 package de.intevation.gnv.state.timeseries;
5
6 import au.com.bytecode.opencsv.CSVWriter;
7
8 import de.intevation.artifactdatabase.Config;
9 import de.intevation.artifactdatabase.XMLUtils;
10
11 import de.intevation.artifacts.ArtifactNamespaceContext;
12 import de.intevation.artifacts.CallContext;
13 import de.intevation.artifacts.CallMeta;
14 import de.intevation.artifacts.PreferredLocale;
15
16 import de.intevation.gnv.artifacts.context.GNVArtifactContext;
17
18 import de.intevation.gnv.artifacts.ressource.RessourceFactory;
19
20 import de.intevation.gnv.chart.Chart;
21 import de.intevation.gnv.chart.ChartLabels;
22 import de.intevation.gnv.chart.TimeSeriesChart;
23 import de.intevation.gnv.chart.XMLChartTheme;
24
25 import de.intevation.gnv.chart.exception.TechnicalChartException;
26
27 import de.intevation.gnv.exports.ChartExportHelper;
28 import de.intevation.gnv.exports.DefaultDataCollector;
29 import de.intevation.gnv.exports.DefaultExport;
30 import de.intevation.gnv.exports.DefaultProfile;
31
32 import de.intevation.gnv.exports.Export.Profile;
33
34 import de.intevation.gnv.exports.SimpleOdvDataCollector;
35
36 import de.intevation.gnv.geobackend.base.Result;
37
38 import de.intevation.gnv.state.InputData;
39 import de.intevation.gnv.state.OutputStateBase;
40
41 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
42 import de.intevation.gnv.state.describedata.NamedCollection;
43
44 import de.intevation.gnv.state.exception.StateException;
45
46 import de.intevation.gnv.statistics.Statistic;
47 import de.intevation.gnv.statistics.StatisticSet;
48 import de.intevation.gnv.statistics.Statistics;
49 import de.intevation.gnv.statistics.TimeseriesStatistics;
50
51 import de.intevation.gnv.statistics.exception.StatisticsException;
52
53 import de.intevation.gnv.timeseries.gap.DefaultTimeGap;
54 import de.intevation.gnv.timeseries.gap.TimeGap;
55
56 import de.intevation.gnv.utils.ArtifactXMLUtilities;
57
58 import java.io.File;
59 import java.io.IOException;
60 import java.io.OutputStream;
61 import java.io.UnsupportedEncodingException;
62
63 import java.util.ArrayList;
64 import java.util.Collection;
65 import java.util.Iterator;
66 import java.util.List;
67 import java.util.Locale;
68 import java.util.Vector;
69
70 import org.apache.log4j.Logger;
71
72 import org.jfree.chart.ChartTheme;
73
74 import org.w3c.dom.Document;
75 import org.w3c.dom.Element;
76 import org.w3c.dom.Node;
77 import org.w3c.dom.NodeList;
78
79
80 /**
81 * @author Tim Englich (tim.englich@intevation.de)
82 * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
83 */
84 public class TimeSeriesOutputState extends OutputStateBase {
85
86 protected static final boolean CACHE_CHART =
87 Boolean.parseBoolean(System.getProperty("cache.chart", "false"));
88
89 protected static final boolean PDF_FORMAT_LANDSCAPE =
90 Boolean.parseBoolean(System.getProperty("export.pdf.landscape","true"));
91
92 protected static final String[] IMG_EXPORT_FORMAT = {
93 "PNG", "JPEG", "GIF"
94 };
95
96 /**
97 * The UID of this Class
98 */
99 private static final long serialVersionUID = 4178407570503098858L;
100
101 /**
102 * the logger, used to log exceptions and additonaly information
103 */
104 private static Logger log = Logger
105 .getLogger(TimeSeriesOutputState.class);
106
107 private static List<TimeGap> timeGapDefinitions = null;
108
109 protected String domainLable = "chart.timeseries.title.xaxis";
110
111 protected String featureValuesName = "featureid";
112 protected String parameterValuesName = "parameterid";
113 protected String measuremenValueName = "measurementid";
114 protected String dateValueName = "dateid";
115
116 public static final String [] TIMESERIES_CSV_PROFILE_COLUMNS = {
117 "XORDINATE",
118 "YORDINATE",
119 "GROUP1",
120 "GROUP2",
121 "GROUP3"
122 };
123
124
125 public static final String [] TIMESERIES_TIMESERIES_CSV_COLUMN_LABEL = {
126 "Date/Time",
127 "Value",
128 "ParameterID",
129 "MeasurementID",
130 "TimeseriesID"
131 };
132
133 public static final String [] TIMESERIES_MESH_CSV_COLUMN_LABEL = {
134 "Date/Time",
135 "Value",
136 "ParameterID",
137 "FeatureID",
138 "MeshID"
139 };
140
141 public static final String [] TIMESERIES_ODV_PROFILE_NAMES = {
142 "CRUISE",
143 "STATION",
144 "TYPE",
145 "SHAPE",
146 "BOTDEPTH",
147 "DEPTH",
148 "TIMEVALUE",
149 "DATAVALUE",
150 "PARAMETER"
151 };
152
153
154 public static final String [] ODV_COLUMN_HEADER = {
155 "Cruise",
156 "Station",
157 "Type",
158 "Longitude [deegrees_east]",
159 "Latitude [deegrees_north]",
160 "Bot. Depth [m]",
161 "Depth [m]",
162 "Date/Time",
163 "Value",
164 "Parameterid"
165 };
166
167 /**
168 * Profile for exporting data to odv
169 * TODO Change TIMESERIES_PROFILE_NAMES, which belong to CSV exports
170 */
171 public static final Profile TIMESERIES_ODV_PROFILE =
172 new DefaultProfile(
173 ODV_COLUMN_HEADER,
174 '\t',
175 CSVWriter.NO_QUOTE_CHARACTER,
176 CSVWriter.NO_ESCAPE_CHARACTER,
177 "ODV",
178 "ISO-8859-1");
179
180 /**
181 * Constructor
182 */
183 public TimeSeriesOutputState() {
184 super();
185 }
186
187
188 @Override
189 public void initialize(String uuid, CallContext context)
190 throws StateException
191 {
192 getChartResult(uuid, context);
193 }
194
195
196 /**
197 * @see de.intevation.gnv.transition.OutputTransition#out(java.lang.String,
198 * java.util.Collection, java.io.OutputStream, java.lang.String,
199 * de.intevation.artifacts.CallMeta)
200 */
201 public void out(
202 Document format,
203 Collection<InputData> inputData,
204 OutputStream outputStream,
205 String uuid,
206 CallContext callContext
207 ) throws StateException
208 {
209 log.debug("TimeSeriesOutputTransition.out");
210
211 String outputMode = XMLUtils.xpathString(
212 format, XPATH_OUTPUT_MODE, ArtifactNamespaceContext.INSTANCE);
213
214 String mimeType = XMLUtils.xpathString(
215 format, XPATH_MIME_TYPE, ArtifactNamespaceContext.INSTANCE);
216
217 CallMeta callMeta = callContext.getMeta();
218
219 int chartWidth = 600;
220 int chartHeight = 400;
221 boolean sVisible = false;
222
223 // lines are always visible. if lines should be configurable we need a
224 // parameter in the user interface
225 boolean lVisible = true;
226
227 try {
228 if (inputData != null) {
229 Iterator<InputData> it = inputData.iterator();
230 while (it.hasNext()) {
231 InputData ip = it.next();
232 String optionName = ip.getName().trim();
233
234 if (optionName.equals("width")) {
235 chartWidth = Integer.parseInt(ip.getValue());
236 }
237 else if (optionName.equals("height")) {
238 chartHeight = Integer.parseInt(ip.getValue());
239 }
240 else if (optionName.equals("points")) {
241 sVisible = Boolean.parseBoolean(ip.getValue());
242 }
243 }
244 }
245 } catch (NumberFormatException e) {
246 log.error(e, e);
247 throw new StateException(e);
248 }
249
250 try {
251 if (outputMode.equalsIgnoreCase("chart")) {
252 log.debug("Chart will be generated.");
253
254 PreferredLocale[] locales = callMeta.getLanguages();
255 Locale[] serverLocales =
256 RessourceFactory.getInstance().getLocales();
257 Locale locale =
258 callMeta.getPreferredLocale(serverLocales);
259
260 log.debug(
261 "Best locale - regarding intersection of server and " +
262 "browser locales - is " + locale.toString()
263 );
264
265 Collection parameters = this.getCleanedParameters(uuid);
266 Collection measurements = this.getMeasurements(uuid);
267 Collection dates = this.getDates(uuid);
268
269 ChartLabels chartLables = createChartLabels(locale, uuid);
270
271 String exportFormat = getExportFormat(mimeType);
272
273 this.createChart(
274 outputStream,
275 parameters,
276 measurements,
277 dates,
278 chartLables,
279 callContext,
280 uuid,
281 exportFormat,
282 locale,
283 chartWidth,
284 chartHeight,
285 lVisible,
286 sVisible,
287 callContext
288 );
289 }
290 else if (outputMode.equalsIgnoreCase("pdf")) {
291 log.debug("Output mode == pdf");
292
293 Locale[] serverLocales =
294 RessourceFactory.getInstance().getLocales();
295 Locale locale =
296 callMeta.getPreferredLocale(serverLocales);
297
298 log.debug(
299 "Best locale - regarding intersection of server and " +
300 "browser locales - is " + locale.toString()
301 );
302
303 createPDF(
304 outputStream,
305 getCleanedParameters(uuid),
306 getMeasurements(uuid),
307 getDates(uuid),
308 createChartLabels(locale, uuid),
309 uuid,
310 "A4",
311 true,
312 lVisible,
313 sVisible,
314 locale,
315 callContext
316 );
317 }
318 else if (outputMode.equalsIgnoreCase("svg")) {
319 log.debug("Output mode == svg");
320
321 Locale[] serverLocales =
322 RessourceFactory.getInstance().getLocales();
323 Locale locale =
324 callMeta.getPreferredLocale(serverLocales);
325
326 log.debug(
327 "Best locale - regarding intersection of server and " +
328 "browser locales - is " + locale.toString()
329 );
330
331 createSVG(
332 outputStream,
333 getCleanedParameters(uuid),
334 getMeasurements(uuid),
335 getDates(uuid),
336 createChartLabels(locale, uuid),
337 uuid,
338 locale,
339 chartWidth,
340 chartHeight,
341 lVisible,
342 sVisible,
343 callContext
344 );
345 }
346 else if (outputMode.equalsIgnoreCase("csv")) {
347 log.debug("CSV-File will be generated.");
348 Object result = getChartResult(uuid, callContext);
349 if (result instanceof Collection) {
350 this.createCSV(
351 outputStream,
352 (Collection<Result>)result);
353 }
354 } else if (outputMode.equalsIgnoreCase("statistics")) {
355 log.debug("Statistics will be generated.");
356
357 Collection<StatisticSet> statistics;
358
359 Statistics s = getStatisticsGenerator();
360 Object result = getChartResult(uuid, callContext);
361
362 if (result != null && s != null) {
363 Collection<KeyValueDescibeData> parameters =
364 getParameters(uuid);
365
366 Collection<KeyValueDescibeData> measurements =
367 getMeasurements(uuid);
368
369 Collection<KeyValueDescibeData> dates =
370 getDates(uuid);
371
372 statistics = s.calculateStatistics(
373 result,
374 parameters,
375 measurements,
376 dates);
377 }
378 else {
379 statistics = new ArrayList<StatisticSet>();
380 }
381
382 Document doc = writeStatistics2XML(statistics);
383
384 XMLUtils.toStream(doc, outputStream);
385
386 } else if (outputMode.equalsIgnoreCase("odv")) {
387 Collection<Result> odvResult = this.getODVResult(uuid);
388 this.createODV(outputStream, odvResult);
389 }
390 } catch (IOException e) {
391 log.error(e, e);
392 throw new StateException(e);
393 } catch (TechnicalChartException e) {
394 log.error(e, e);
395 throw new StateException(e);
396 } catch (StatisticsException e) {
397 log.error(e, e);
398 throw new StateException(e);
399 }
400 }
401
402
403 protected String getExportFormat(String mime) {
404 for(int i = 0; i < IMG_EXPORT_FORMAT.length; i++) {
405 if (mime.trim().toUpperCase().indexOf(IMG_EXPORT_FORMAT[i]) > 0)
406 return IMG_EXPORT_FORMAT[i];
407 }
408
409 // no format found relating to mimeType, default export as PNG
410 return IMG_EXPORT_FORMAT[0];
411 }
412
413
414 protected Collection getCleanedParameters(Collection parameters) {
415 Iterator iter = parameters.iterator();
416 Collection parameter = new Vector(parameters);
417 while (iter.hasNext()) {
418 KeyValueDescibeData data = (KeyValueDescibeData)iter.next();
419 if (!data.isSelected())
420 parameter.remove(data);
421 }
422
423 return parameter;
424 }
425
426
427 protected Collection getCleanedParameters(String uuid) {
428 return getCleanedParameters(getParameters(uuid));
429 }
430
431
432 protected void createCSV(OutputStream out, Collection<Result> results)
433 throws UnsupportedEncodingException, IOException, StateException
434 {
435 Iterator iter = results.iterator();
436 Result res = iter.hasNext() ? (Result) iter.next() : null;
437
438 if (res == null)
439 return;
440
441 Profile profile = null;
442 int dataid = res.getInteger("DATAID").intValue();
443
444 // on meshes
445 if (dataid == 2) {
446 profile = new DefaultProfile(
447 TIMESERIES_MESH_CSV_COLUMN_LABEL,
448 ',',
449 '"',
450 '"',
451 "CSV",
452 "ISO-8859-1");
453 }
454
455 // on timeseries
456 else {
457 profile = new DefaultProfile(
458 TIMESERIES_TIMESERIES_CSV_COLUMN_LABEL,
459 ',',
460 '"',
461 '"',
462 "CSV",
463 "ISO-8859-1");
464 }
465
466 DefaultExport export = new DefaultExport(
467 new DefaultDataCollector(TIMESERIES_CSV_PROFILE_COLUMNS));
468 export.create(profile, out, results);
469 }
470
471
472 /**
473 * TODO Result is not used at the moment. Change result with correct data.
474 */
475 protected void createODV(OutputStream outputStream, Collection result)
476 throws IOException, StateException {
477
478 DefaultExport export = new DefaultExport(new SimpleOdvDataCollector(
479 TIMESERIES_ODV_PROFILE_NAMES));
480
481 if (result == null)
482 log.error("#################### RESULT == NULL #################");
483 export.create(TIMESERIES_ODV_PROFILE, outputStream, result);
484 }
485
486 /**
487 * @return
488 */
489 protected Statistics getStatisticsGenerator() {
490 Statistics s = new TimeseriesStatistics();
491 return s;
492 }
493
494 protected Document writeStatistics2XML( Collection<StatisticSet> statistic) {
495 ArtifactXMLUtilities xmlUtilities = new ArtifactXMLUtilities();
496 Document doc = XMLUtils.newDocument();
497 if (statistic != null) {
498 Node statisticResults = xmlUtilities.createArtifactElement(doc,
499 "statistics");
500 doc.appendChild(statisticResults);
501 Iterator<StatisticSet> it = statistic.iterator();
502 while (it.hasNext()) {
503 StatisticSet set = it.next();
504 Element setElement = xmlUtilities.createArtifactElement(doc,
505 "statistic");
506 setElement.setAttribute("name", set.getName());
507
508 Iterator<Statistic> sit = set.getStatistics().iterator();
509 while (sit.hasNext()){
510 Statistic s = sit.next();
511 Element result = xmlUtilities.createArtifactElement(doc,
512 "statistic-value");
513 result.setAttribute("name", s.getKey());
514 result.setAttribute("value", s.getStringValue());
515 setElement.appendChild(result);
516 }
517 statisticResults.appendChild(setElement);
518 }
519
520 }
521 return doc;
522 }
523
524
525 protected String getSelectedFeatureName(String uuid) {
526 Collection values = getCollection(featureValuesName, uuid);
527
528 if (values != null) {
529 Iterator it = values.iterator();
530
531 while (it.hasNext()) {
532 KeyValueDescibeData data = (KeyValueDescibeData) it.next();
533
534 if (data.isSelected()) {
535 return data.getValue();
536 }
537 }
538 }
539 return null;
540 }
541
542
543 /**
544 * @param outputStream
545 * @param parameters
546 * @param measurements
547 * @param timeSeriesName
548 * @param chartStyle
549 * @param chartLables
550 * @throws IOException
551 * @throws TechnicalChartException
552 */
553 protected void createChart(
554 OutputStream outputStream,
555 Collection parameters,
556 Collection measurements,
557 Collection dates,
558 ChartLabels chartLables,
559 CallContext context,
560 String uuid,
561 String exportFormat,
562 Locale locale,
563 int width,
564 int height,
565 boolean linesVisible,
566 boolean shapesVisible,
567 CallContext callContext
568 )
569 throws IOException, TechnicalChartException
570 {
571 log.debug("Create chart.");
572 Chart chart = getChart(
573 chartLables,
574 createStyle(context),
575 parameters,
576 measurements,
577 dates,
578 getChartResult(uuid, callContext),
579 locale, // Locale
580 uuid,
581 linesVisible,
582 shapesVisible,
583 callContext
584 );
585
586 if (chart == null) {
587 log.error("Could not initialize chart.");
588 return;
589 }
590
591 log.debug(
592 "export chart as " + exportFormat +
593 " in " + width + "x" + height
594 );
595
596 ChartExportHelper.exportImage(
597 outputStream,
598 chart.generateChart(),
599 exportFormat,
600 width,
601 height
602 );
603 }
604
605
606 protected void createPDF(
607 OutputStream outputStream,
608 Collection parameters,
609 Collection measurements,
610 Collection dates,
611 ChartLabels chartLables,
612 String uuid,
613 String exportFormat,
614 boolean landscape,
615 boolean linesVisible,
616 boolean shapesVisible,
617 Locale locale,
618 CallContext context
619 ) {
620 Chart chart = getChart(
621 chartLables,
622 createStyle(context),
623 parameters,
624 measurements,
625 dates,
626 getChartResult(uuid, context),
627 locale,
628 uuid,
629 linesVisible,
630 shapesVisible,
631 context
632 );
633
634 if (chart == null) {
635 log.error("Could not initialize chart.");
636 return;
637 }
638
639 ChartExportHelper.exportPDF(
640 outputStream,
641 chart.generateChart(),
642 "A4",
643 PDF_FORMAT_LANDSCAPE,
644 50F, 50F, 50F, 50F
645 );
646 }
647
648
649 protected void createSVG(
650 OutputStream outputStream,
651 Collection parameters,
652 Collection measurements,
653 Collection dates,
654 ChartLabels chartLables,
655 String uuid,
656 Locale locale,
657 int width,
658 int height,
659 boolean linesVisible,
660 boolean shapesVisible,
661 CallContext callContext
662 ) {
663 Chart chart = getChart(
664 chartLables,
665 createStyle(callContext),
666 parameters,
667 measurements,
668 dates,
669 getChartResult(uuid, callContext),
670 locale,
671 uuid,
672 linesVisible,
673 shapesVisible,
674 callContext
675 );
676
677 if (chart == null) {
678 log.error("Could not initialize chart.");
679 return;
680 }
681
682 ChartExportHelper.exportSVG(
683 outputStream,
684 chart.generateChart(),
685 null,
686 600, 400
687 );
688
689 log.debug("svg export finished.");
690 }
691
692
693 protected Chart getChart(
694 ChartLabels chartLables,
695 ChartTheme theme,
696 Collection parameters,
697 Collection measurements,
698 Collection dates,
699 Object result,
700 Locale locale,
701 String uuid,
702 boolean linesVisible,
703 boolean shapesVisible,
704 CallContext callContext
705 ) {
706 Chart chart = null;
707
708 if (CACHE_CHART) {
709 log.info("Try to get timeseries chart from cache.");
710 chart = (Chart) getChartFromCache(uuid, callContext);
711 }
712
713 if (chart != null)
714 return chart;
715
716 log.info("Chart not in cache yet.");
717 chart = new TimeSeriesChart(
718 chartLables,
719 theme,
720 parameters,
721 measurements,
722 dates,
723 (Collection)result,
724 timeGapDefinitions,
725 locale,
726 linesVisible,
727 shapesVisible
728 );
729 chart.generateChart();
730
731 if (CACHE_CHART) {
732 log.info("Put chart into cache.");
733 purifyChart(chart, uuid);
734 }
735
736 return chart;
737 }
738
739 protected ChartTheme createStyle(CallContext callContext) {
740 log.debug("Fetch chart theme from global context");
741
742 GNVArtifactContext context =
743 (GNVArtifactContext) callContext.globalContext();
744
745 XMLChartTheme theme = (XMLChartTheme) context.get(
746 GNVArtifactContext.CHART_TEMPLATE_KEY);
747
748 return theme;
749 }
750
751 protected ChartLabels createChartLabels(Locale locale, String uuid) {
752 return new ChartLabels(
753 createChartTitle(locale, uuid),
754 createChartSubtitle(locale, uuid),
755 RessourceFactory.getInstance().getRessource(
756 locale,
757 domainLable,
758 domainLable
759 )
760 );
761 }
762
763
764 protected String createChartTitle(Locale locale, String uuid) {
765 return getFisName(locale);
766
767 }
768
769
770 protected String createChartSubtitle(Locale locale, String uuid) {
771 return getSelectedFeatureName(uuid);
772 }
773
774
775 protected String getFisName(Locale locale) {
776 String returnValue = "";
777 InputData input = inputData.get("fisname");
778
779 if (input != null) {
780 String value = input.getValue();
781
782 returnValue = RessourceFactory.getInstance().getRessource(
783 locale,
784 value,
785 value
786 );
787 }
788 return returnValue;
789 }
790
791
792 protected String getSelectedInputDataName(String uuid, String key) {
793 Collection values = getCollection(key, uuid);
794
795 if (values != null) {
796 Iterator it = values.iterator();
797
798 while (it.hasNext()) {
799 KeyValueDescibeData data = (KeyValueDescibeData) it.next();
800
801 if (data.isSelected()) {
802 return data.getValue();
803 }
804 }
805 }
806 return null;
807 }
808
809
810 protected Collection<KeyValueDescibeData> getParameters(String uuid) {
811 return this.getCollection(parameterValuesName, uuid);
812 }
813
814 protected Collection<KeyValueDescibeData> getMeasurements(String uuid) {
815 return this.getCollection(measuremenValueName, uuid);
816 }
817 protected Collection<KeyValueDescibeData> getDates(String uuid) {
818 return this.getCollection(dateValueName,uuid);
819 }
820
821 @Override
822 public void setup(Node configuration) {
823 super.setup(configuration);
824 String featureNameValue = Config.getStringXPath(configuration,
825 "value-names/value-name[@name='feature']/@value");
826 if (featureNameValue != null) {
827 this.featureValuesName = featureNameValue;
828 }
829 String parameterNameValue = Config.getStringXPath(configuration,
830 "value-names/value-name[@name='parameter']/@value");
831 if (parameterNameValue != null) {
832 this.parameterValuesName = parameterNameValue;
833 }
834 String measurementNameValue = Config.getStringXPath(configuration,
835 "value-names/value-name[@name='measurement']/@value");
836 if (measurementNameValue != null) {
837 this.measuremenValueName = measurementNameValue;
838 }
839
840 String dateNameValue = Config.getStringXPath(configuration,
841 "value-names/value-name[@name='date']/@value");
842 if (dateNameValue != null) {
843 this.dateValueName = dateNameValue;
844 }
845 if (timeGapDefinitions == null){
846 Element gapDefinition = (Element)Config.getNodeXPath(configuration,
847 "time-gap-definition");
848 synchronized (this.getClass()) {
849 if (gapDefinition != null){
850 String link = gapDefinition.getAttribute("xlink:href");
851 if (link != null ){
852 String absolutFileName = Config.replaceConfigDir(link);
853 gapDefinition = (Element)new ArtifactXMLUtilities().
854 readConfiguration(absolutFileName);
855 }
856
857 NodeList gapDefinitions = Config.getNodeSetXPath(gapDefinition,
858 "/time-gaps/time-gap");
859 if (gapDefinition != null){
860 timeGapDefinitions = new ArrayList<TimeGap>(gapDefinitions.
861 getLength());
862 for (int i = 0; i < gapDefinitions.getLength(); i++){
863 Element gapNode = (Element)gapDefinitions.item(i);
864 String unit = gapNode.getAttribute("unit");
865 int key = Integer.parseInt(gapNode.getAttribute("key"));
866 int value = Integer.parseInt(gapNode.getAttribute("gap"));
867 log.info("Add new Timegap: "+key+" "+value+" "+ unit);
868 timeGapDefinitions.add(new DefaultTimeGap(unit,
869 key,
870 value));
871 }
872 }
873
874 }
875 }
876 }
877 }
878
879 /**
880 * @param collectionName
881 * @return
882 */
883 protected Collection<KeyValueDescibeData> getCollection(
884 String collectionName,
885 String uuid) {
886 Iterator<Object> it = this.getDescibeData(uuid).iterator();
887 while (it.hasNext()) {
888
889 Object o = it.next();
890
891 if (o instanceof NamedCollection<?>) {
892 NamedCollection<KeyValueDescibeData> nc = (NamedCollection<KeyValueDescibeData>) o;
893 if (nc.getName().equals(collectionName)) {
894 return nc;
895 }
896 }
897 }
898 return null;
899 }
900 }
901 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org