teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.model.fixings; sascha@3450: teichmann@6877: import org.apache.log4j.Logger; teichmann@5831: import org.dive4elements.river.artifacts.model.Parameters; sascha@3450: teichmann@5831: import org.dive4elements.river.utils.KMIndex; sascha@3450: sascha@3450: import java.io.Serializable; teichmann@6877: import java.util.Collection; teichmann@6877: import java.util.Date; gernotbelger@9348: import java.util.Set; teichmann@6877: import java.util.TreeMap; teichmann@6877: import java.util.TreeSet; sascha@3450: sascha@3450: public class FixResult sascha@3450: implements Serializable sascha@3450: { teichmann@6877: private static Logger log = teichmann@6877: Logger.getLogger(FixResult.class); teichmann@6877: sascha@3450: protected Parameters parameters; sascha@3450: protected KMIndex referenced; gernotbelger@9348: protected KMIndex outliers; sascha@3450: sascha@3450: public FixResult() { sascha@3450: } sascha@3450: sascha@3450: public FixResult( sascha@3450: Parameters parameters, sascha@3450: KMIndex referenced, gernotbelger@9348: KMIndex outliers sascha@3450: ) { sascha@3450: this.parameters = parameters; sascha@3450: this.referenced = referenced; sascha@3450: this.outliers = outliers; sascha@3450: } sascha@3450: sascha@3450: public KMIndex getReferenced() { sascha@3450: return referenced; sascha@3450: } sascha@3450: sascha@3450: public void setReferenced(KMIndex referenced) { sascha@3450: this.referenced = referenced; sascha@3450: } sascha@3450: teichmann@6877: public void makeReferenceEventsDatesUnique() { gernotbelger@9348: final DateUniqueMaker dum = new DateUniqueMaker(); gernotbelger@9348: teichmann@6877: for (KMIndex.Entry entry: referenced) { gernotbelger@9348: for (QWD ref: entry.getValue()) teichmann@6877: dum.makeUnique(ref); teichmann@6877: } gernotbelger@9348: gernotbelger@9348: // FIXME gernotbelger@9348: // for (KMIndex.Entry entry: outliers) { gernotbelger@9348: // for (QWD ref: entry.getValue()) gernotbelger@9348: // dum.makeUnique(ref); gernotbelger@9348: // } teichmann@6877: } teichmann@6877: gernotbelger@9348: private Collection getReferenceEventsIndices() { gernotbelger@9348: final TreeMap dates = new TreeMap<>(); gernotbelger@9348: teichmann@6877: for (KMIndex.Entry entry: referenced) { gernotbelger@9348: for (QWD value: entry.getValue()) teichmann@6877: dates.put(value.date, value.index); teichmann@6877: } gernotbelger@9348: // FIXME gernotbelger@9348: // for (KMIndex.Entry entry: outliers) { gernotbelger@9348: // for (QWD value: entry.getValue()) gernotbelger@9348: // dates.put(value.date, value.index); gernotbelger@9348: // } gernotbelger@9348: teichmann@6877: return dates.values(); teichmann@6877: } teichmann@6877: teichmann@6877: public void remapReferenceIndicesToRank() { gernotbelger@9348: final RankRemapper remapper = new RankRemapper(); gernotbelger@9348: for (Integer idx: getReferenceEventsIndices()) teichmann@6891: remapper.toMap(idx); gernotbelger@9348: gernotbelger@9348: for (KMIndex.Entry entry: referenced) { gernotbelger@9348: for (QWD value: entry.getValue()) gernotbelger@9348: remapper.remap(value); teichmann@6877: } gernotbelger@9348: // FIXME gernotbelger@9348: // for (KMIndex.Entry entry: outliers) { gernotbelger@9348: // for (QWD value: entry.getValue()) gernotbelger@9348: // remapper.remap(value); gernotbelger@9348: // } teichmann@6877: } teichmann@6877: teichmann@6877: public Collection getReferenceEventsDates() { gernotbelger@9348: gernotbelger@9348: final Set dates = new TreeSet<>(); gernotbelger@9348: gernotbelger@9348: for (final KMIndex.Entry entry: referenced) { gernotbelger@9348: for (final QWD qwd: entry.getValue()) teichmann@6877: dates.add(qwd.date); teichmann@6877: } gernotbelger@9348: gernotbelger@9348: // FIXME, but not always... gernotbelger@9348: // for (final KMIndex.Entry entry: outliers) { gernotbelger@9348: // for (final QWD qwd: entry.getValue()) gernotbelger@9348: // dates.add(qwd.date); gernotbelger@9348: // } gernotbelger@9348: teichmann@6877: return dates; teichmann@6877: } teichmann@6877: teichmann@6877: gernotbelger@9348: public KMIndex getOutliers() { sascha@3450: return outliers; sascha@3450: } sascha@3450: gernotbelger@9348: public void setOutliers(KMIndex outliers) { sascha@3450: this.outliers = outliers; sascha@3450: } sascha@3450: sascha@3450: public Parameters getParameters() { sascha@3450: return parameters; sascha@3450: } sascha@3450: sascha@3450: public void setParameters(Parameters parameters) { sascha@3450: this.parameters = parameters; sascha@3450: } sascha@3450: } sascha@3450: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :