1
|
/**
|
2
|
* Copyright (C) 2019 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.api.service.description;
|
10
|
|
11
|
import java.util.Arrays;
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
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;
|
23
|
|
24
|
/**
|
25
|
* @author a.mueller
|
26
|
* @since 05.11.2019
|
27
|
*/
|
28
|
public class DistributionAggregationConfiguration
|
29
|
extends DescriptionAggregationConfigurationBase<DistributionAggregation> {
|
30
|
|
31
|
private static final long serialVersionUID = 2542246141660930545L;
|
32
|
|
33
|
private List<UUID> superAreasUuids;
|
34
|
|
35
|
private TermCollection<PresenceAbsenceTerm, TermNode> statusOrder;
|
36
|
|
37
|
private boolean ignoreAbsentStatusByArea = true;
|
38
|
|
39
|
private boolean ignoreAbsentStatusByRank = true;
|
40
|
|
41
|
// private boolean ignoreEndemicStatusByArea = true;
|
42
|
//
|
43
|
// private boolean ignoreEndemicStatusByRank = true;
|
44
|
|
45
|
|
46
|
private List<PresenceAbsenceTerm> byAreaIgnoreStatusList = null;
|
47
|
|
48
|
private List<PresenceAbsenceTerm> byRankIgnoreStatusList = null;
|
49
|
|
50
|
// **************************************** FACTORY ************************************/
|
51
|
|
52
|
public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<UUID> superAreas,
|
53
|
TaxonNodeFilter filter, IProgressMonitor monitor){
|
54
|
|
55
|
|
56
|
return new DistributionAggregationConfiguration(aggregationModes, superAreas, filter, monitor);
|
57
|
}
|
58
|
|
59
|
public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<UUID> superAreas,
|
60
|
TaxonNodeFilter filter, TermTree<PresenceAbsenceTerm> statusOrder, IProgressMonitor monitor){
|
61
|
|
62
|
DistributionAggregationConfiguration result = new DistributionAggregationConfiguration(aggregationModes, superAreas, filter, monitor);
|
63
|
result.setStatusOrder(statusOrder);
|
64
|
return result;
|
65
|
}
|
66
|
|
67
|
// ************************ CONSTRUCTOR *****************************/
|
68
|
|
69
|
private DistributionAggregationConfiguration(List<AggregationMode> aggregationModes, List<UUID> superAreas,
|
70
|
TaxonNodeFilter filter, IProgressMonitor monitor) {
|
71
|
super(filter, monitor, aggregationModes);
|
72
|
setWithinTaxonSourceMode(AggregationSourceMode.ALL_SAMEVALUE); //default mode for distribution aggregations
|
73
|
setToParentSourceMode(AggregationSourceMode.NONE); //default mode for distribution aggregations
|
74
|
|
75
|
this.superAreasUuids = superAreas;
|
76
|
}
|
77
|
|
78
|
// ******************** METHOD **************************************/
|
79
|
|
80
|
@Override
|
81
|
public DistributionAggregation getTaskInstance() {
|
82
|
return new DistributionAggregation();
|
83
|
}
|
84
|
|
85
|
// ******************* GETTER / SETTER ****************************/
|
86
|
|
87
|
public List<UUID> getSuperAreas() {
|
88
|
return superAreasUuids;
|
89
|
}
|
90
|
public void setSuperAreas(List<UUID> superAreas) {
|
91
|
this.superAreasUuids = superAreas;
|
92
|
}
|
93
|
|
94
|
public UUID getLowerRank() {
|
95
|
LogicFilter<Rank> rankMin = getTaxonNodeFilter().getRankMin();
|
96
|
return rankMin == null ? null: rankMin.getUuid();
|
97
|
}
|
98
|
|
99
|
public UUID getUpperRank() {
|
100
|
LogicFilter<Rank> rankMax = getTaxonNodeFilter().getRankMax();
|
101
|
return rankMax == null ? null: rankMax.getUuid();
|
102
|
}
|
103
|
|
104
|
public TermCollection<PresenceAbsenceTerm, TermNode> getStatusOrder() {
|
105
|
return statusOrder;
|
106
|
}
|
107
|
public void setStatusOrder(TermCollection<PresenceAbsenceTerm, TermNode> statusOrder) {
|
108
|
this.statusOrder = statusOrder;
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* byAreaIgnoreStatusList contains by default:
|
113
|
* <ul>
|
114
|
* <li>AbsenceTerm.CULTIVATED_REPORTED_IN_ERROR()</li>
|
115
|
* <li>AbsenceTerm.INTRODUCED_REPORTED_IN_ERROR()</li>
|
116
|
* <li>AbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED()</li>
|
117
|
* <li>AbsenceTerm.NATIVE_REPORTED_IN_ERROR()</li>
|
118
|
* <li>AbsenceTerm.NATIVE_FORMERLY_NATIVE()</li>
|
119
|
* </ul>
|
120
|
*
|
121
|
* @return the byAreaIgnoreStatusList
|
122
|
*/
|
123
|
public List<PresenceAbsenceTerm> getByAreaIgnoreStatusList() {
|
124
|
if(byAreaIgnoreStatusList == null ){
|
125
|
byAreaIgnoreStatusList = Arrays.asList(
|
126
|
new PresenceAbsenceTerm[] {
|
127
|
PresenceAbsenceTerm.CULTIVATED_REPORTED_IN_ERROR(),
|
128
|
PresenceAbsenceTerm.INTRODUCED_REPORTED_IN_ERROR(),
|
129
|
PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR(),
|
130
|
PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED(),
|
131
|
PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE()
|
132
|
// TODO what about PresenceAbsenceTerm.ABSENT() also ignore?
|
133
|
});
|
134
|
}
|
135
|
return byAreaIgnoreStatusList;
|
136
|
}
|
137
|
|
138
|
public void setByAreaIgnoreStatusList(List<PresenceAbsenceTerm> byAreaIgnoreStatusList) {
|
139
|
this.byAreaIgnoreStatusList = byAreaIgnoreStatusList;
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* Ranks to be ignored if aggregated to next higher rank.
|
144
|
* byRankIgnoreStatusList contains by default
|
145
|
* <ul>
|
146
|
* <li>PresenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA()</li>
|
147
|
* <li>PresenceTerm.ENDEMIC_DOUBTFULLY_PRESENT()</li>
|
148
|
* <li>PresenceTerm.ENDEMIC_REPORTED_IN_ERROR()</li>
|
149
|
* <li>PresenceTerm.NOT_ENDEMIC_FOR_THE_RELEVANT_AREA()</li>
|
150
|
* </ul>
|
151
|
*
|
152
|
* @return the byRankIgnoreStatusList
|
153
|
*/
|
154
|
public List<PresenceAbsenceTerm> getByRankIgnoreStatusList() {
|
155
|
|
156
|
if (byRankIgnoreStatusList == null) {
|
157
|
byRankIgnoreStatusList = Arrays.asList(
|
158
|
new PresenceAbsenceTerm[] {
|
159
|
PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA(),
|
160
|
PresenceAbsenceTerm.ENDEMIC_DOUBTFULLY_PRESENT(),
|
161
|
PresenceAbsenceTerm.ENDEMIC_REPORTED_IN_ERROR(),
|
162
|
PresenceAbsenceTerm.NOT_ENDEMIC_FOR_THE_RELEVANT_AREA()
|
163
|
});
|
164
|
}
|
165
|
return byRankIgnoreStatusList;
|
166
|
}
|
167
|
|
168
|
public void setByRankIgnoreStatusList(List<PresenceAbsenceTerm> byRankIgnoreStatusList) {
|
169
|
this.byRankIgnoreStatusList = byRankIgnoreStatusList;
|
170
|
}
|
171
|
|
172
|
public boolean isIgnoreAbsentStatusByArea() {
|
173
|
return ignoreAbsentStatusByArea;
|
174
|
}
|
175
|
public void setIgnoreAbsentStatusByArea(boolean ignoreAbsentStatusByArea) {
|
176
|
this.ignoreAbsentStatusByArea = ignoreAbsentStatusByArea;
|
177
|
}
|
178
|
|
179
|
public boolean isIgnoreAbsentStatusByRank() {
|
180
|
return ignoreAbsentStatusByRank;
|
181
|
}
|
182
|
public void setIgnoreAbsentStatusByRank(boolean ignoreAbsentStatusByRank) {
|
183
|
this.ignoreAbsentStatusByRank = ignoreAbsentStatusByRank;
|
184
|
}
|
185
|
}
|