2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.api
.service
.description
;
11 import java
.util
.Arrays
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
16 import eu
.etaxonomy
.cdm
.filter
.LogicFilter
;
17 import eu
.etaxonomy
.cdm
.filter
.TaxonNodeFilter
;
18 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
19 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
20 import eu
.etaxonomy
.cdm
.model
.term
.TermCollection
;
21 import eu
.etaxonomy
.cdm
.model
.term
.TermNode
;
22 import eu
.etaxonomy
.cdm
.model
.term
.TermTree
;
28 public class DistributionAggregationConfiguration
29 extends DescriptionAggregationConfigurationBase
<DistributionAggregation
> {
31 private static final long serialVersionUID
= 2542246141660930545L;
33 private List
<UUID
> superAreasUuids
;
35 private TermCollection
<PresenceAbsenceTerm
, TermNode
> statusOrder
;
37 private boolean ignoreAbsentStatusByArea
= true;
39 private boolean ignoreAbsentStatusByRank
= true;
41 // private boolean ignoreEndemicStatusByArea = true;
43 // private boolean ignoreEndemicStatusByRank = true;
46 private List
<PresenceAbsenceTerm
> byAreaIgnoreStatusList
= null;
48 private List
<PresenceAbsenceTerm
> byRankIgnoreStatusList
= null;
50 // **************************************** FACTORY ************************************/
52 public static DistributionAggregationConfiguration
NewInstance(List
<AggregationMode
> aggregationModes
, List
<UUID
> superAreas
,
53 TaxonNodeFilter filter
, IProgressMonitor monitor
){
56 return new DistributionAggregationConfiguration(aggregationModes
, superAreas
, filter
, monitor
);
59 public static DistributionAggregationConfiguration
NewInstance(List
<AggregationMode
> aggregationModes
, List
<UUID
> superAreas
,
60 TaxonNodeFilter filter
, TermTree
<PresenceAbsenceTerm
> statusOrder
, IProgressMonitor monitor
){
62 DistributionAggregationConfiguration result
= new DistributionAggregationConfiguration(aggregationModes
, superAreas
, filter
, monitor
);
63 result
.setStatusOrder(statusOrder
);
67 // ************************ CONSTRUCTOR *****************************/
69 private DistributionAggregationConfiguration(List
<AggregationMode
> aggregationModes
, List
<UUID
> superAreas
,
70 TaxonNodeFilter filter
, IProgressMonitor monitor
) {
71 super(filter
, monitor
, aggregationModes
);
72 this.superAreasUuids
= superAreas
;
75 // ******************** METHOD **************************************/
78 public DistributionAggregation
getTaskInstance() {
79 return new DistributionAggregation();
82 // ******************* GETTER / SETTER ****************************/
84 public List
<UUID
> getSuperAreas() {
85 return superAreasUuids
;
87 public void setSuperAreas(List
<UUID
> superAreas
) {
88 this.superAreasUuids
= superAreas
;
91 public UUID
getLowerRank() {
92 LogicFilter
<Rank
> rankMin
= getTaxonNodeFilter().getRankMin();
93 return rankMin
== null ?
null: rankMin
.getUuid();
96 public UUID
getUpperRank() {
97 LogicFilter
<Rank
> rankMax
= getTaxonNodeFilter().getRankMax();
98 return rankMax
== null ?
null: rankMax
.getUuid();
101 public TermCollection
<PresenceAbsenceTerm
, TermNode
> getStatusOrder() {
104 public void setStatusOrder(TermCollection
<PresenceAbsenceTerm
, TermNode
> statusOrder
) {
105 this.statusOrder
= statusOrder
;
109 * byAreaIgnoreStatusList contains by default:
111 * <li>AbsenceTerm.CULTIVATED_REPORTED_IN_ERROR()</li>
112 * <li>AbsenceTerm.INTRODUCED_REPORTED_IN_ERROR()</li>
113 * <li>AbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED()</li>
114 * <li>AbsenceTerm.NATIVE_REPORTED_IN_ERROR()</li>
115 * <li>AbsenceTerm.NATIVE_FORMERLY_NATIVE()</li>
118 * @return the byAreaIgnoreStatusList
120 public List
<PresenceAbsenceTerm
> getByAreaIgnoreStatusList() {
121 if(byAreaIgnoreStatusList
== null ){
122 byAreaIgnoreStatusList
= Arrays
.asList(
123 new PresenceAbsenceTerm
[] {
124 PresenceAbsenceTerm
.CULTIVATED_REPORTED_IN_ERROR(),
125 PresenceAbsenceTerm
.INTRODUCED_REPORTED_IN_ERROR(),
126 PresenceAbsenceTerm
.NATIVE_REPORTED_IN_ERROR(),
127 PresenceAbsenceTerm
.INTRODUCED_FORMERLY_INTRODUCED(),
128 PresenceAbsenceTerm
.NATIVE_FORMERLY_NATIVE()
129 // TODO what about PresenceAbsenceTerm.ABSENT() also ignore?
132 return byAreaIgnoreStatusList
;
135 public void setByAreaIgnoreStatusList(List
<PresenceAbsenceTerm
> byAreaIgnoreStatusList
) {
136 this.byAreaIgnoreStatusList
= byAreaIgnoreStatusList
;
140 * Ranks to be ignored if aggregated to next higher rank.
141 * byRankIgnoreStatusList contains by default
143 * <li>PresenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA()</li>
144 * <li>PresenceTerm.ENDEMIC_DOUBTFULLY_PRESENT()</li>
145 * <li>PresenceTerm.ENDEMIC_REPORTED_IN_ERROR()</li>
146 * <li>PresenceTerm.NOT_ENDEMIC_FOR_THE_RELEVANT_AREA()</li>
149 * @return the byRankIgnoreStatusList
151 public List
<PresenceAbsenceTerm
> getByRankIgnoreStatusList() {
153 if (byRankIgnoreStatusList
== null) {
154 byRankIgnoreStatusList
= Arrays
.asList(
155 new PresenceAbsenceTerm
[] {
156 PresenceAbsenceTerm
.ENDEMIC_FOR_THE_RELEVANT_AREA(),
157 PresenceAbsenceTerm
.ENDEMIC_DOUBTFULLY_PRESENT(),
158 PresenceAbsenceTerm
.ENDEMIC_REPORTED_IN_ERROR(),
159 PresenceAbsenceTerm
.NOT_ENDEMIC_FOR_THE_RELEVANT_AREA()
162 return byRankIgnoreStatusList
;
165 public void setByRankIgnoreStatusList(List
<PresenceAbsenceTerm
> byRankIgnoreStatusList
) {
166 this.byRankIgnoreStatusList
= byRankIgnoreStatusList
;
169 public boolean isIgnoreAbsentStatusByArea() {
170 return ignoreAbsentStatusByArea
;
172 public void setIgnoreAbsentStatusByArea(boolean ignoreAbsentStatusByArea
) {
173 this.ignoreAbsentStatusByArea
= ignoreAbsentStatusByArea
;
176 public boolean isIgnoreAbsentStatusByRank() {
177 return ignoreAbsentStatusByRank
;
179 public void setIgnoreAbsentStatusByRank(boolean ignoreAbsentStatusByRank
) {
180 this.ignoreAbsentStatusByRank
= ignoreAbsentStatusByRank
;