Revision 19c6f3d6
Added by Andreas Müller over 6 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/filter/TaxonNodeFilter.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
private boolean includeRootNodes = false; |
48 | 48 |
|
49 |
private boolean includeUnpublished = false; |
|
50 |
|
|
49 | 51 |
//********************** FACTORY ***************************/ |
50 | 52 |
|
51 | 53 |
public static TaxonNodeFilter NewTaxonNodeInstance(UUID taxonNodeUuid){ |
... | ... | |
79 | 81 |
} |
80 | 82 |
|
81 | 83 |
public static TaxonNodeFilter NewRankInstance(Rank rankMin, Rank rankMax){ |
82 |
return new TaxonNodeFilter().orRank(rankMin, rankMax);
|
|
84 |
return new TaxonNodeFilter().setRankMin(rankMin).setRankMax(rankMax);
|
|
83 | 85 |
} |
84 | 86 |
|
85 | 87 |
public static TaxonNodeFilter NewInstance(Collection<UUID> classificationUuids, |
86 | 88 |
Collection<UUID> subtreeUuids, Collection<UUID> taxonNodeUuids, |
87 |
Collection<UUID> taxonUuids){ |
|
89 |
Collection<UUID> taxonUuids, Collection<UUID> areaUuids, |
|
90 |
UUID minRank, UUID maxRank){ |
|
88 | 91 |
|
89 |
TaxonNodeFilter result = new TaxonNodeFilter(); |
|
92 |
TaxonNodeFilter result = new TaxonNodeFilter().setRankMin(minRank).setRankMax(maxRank);
|
|
90 | 93 |
classificationUuids = classificationUuids == null ? new ArrayList<>(): classificationUuids; |
91 | 94 |
subtreeUuids = subtreeUuids == null ? new ArrayList<>(): subtreeUuids; |
92 | 95 |
taxonNodeUuids = taxonNodeUuids == null ? new ArrayList<>(): taxonNodeUuids; |
93 | 96 |
taxonUuids = taxonUuids == null ? new ArrayList<>(): taxonUuids; |
97 |
areaUuids = areaUuids == null ? new ArrayList<>(): areaUuids; |
|
94 | 98 |
|
95 | 99 |
for (UUID uuid : classificationUuids){ |
96 | 100 |
result.orClassification(uuid); |
... | ... | |
104 | 108 |
for (UUID uuid : taxonUuids){ |
105 | 109 |
result.orTaxon(uuid); |
106 | 110 |
} |
111 |
for (UUID uuid : areaUuids){ |
|
112 |
result.orArea(uuid); |
|
113 |
} |
|
107 | 114 |
return result; |
108 | 115 |
|
109 | 116 |
} |
... | ... | |
114 | 121 |
reset(); |
115 | 122 |
} |
116 | 123 |
|
124 |
/** |
|
125 |
* Constructor for a given subtree represented by a {@link TaxonNode} |
|
126 |
*/ |
|
117 | 127 |
public TaxonNodeFilter(TaxonNode node){ |
118 | 128 |
reset(); |
119 | 129 |
LogicFilter<TaxonNode> filter = new LogicFilter<>(node); |
... | ... | |
123 | 133 |
public TaxonNodeFilter(Rank rankMin, Rank rankMax){ |
124 | 134 |
reset(); |
125 | 135 |
if(rankMin!=null){ |
126 |
this.rankMin = new LogicFilter<Rank>(rankMin);
|
|
136 |
this.rankMin = new LogicFilter<>(rankMin); |
|
127 | 137 |
} |
128 | 138 |
if(rankMax!=null){ |
129 |
this.rankMax = new LogicFilter<Rank>(rankMax);
|
|
139 |
this.rankMax = new LogicFilter<>(rankMax); |
|
130 | 140 |
} |
131 | 141 |
} |
132 | 142 |
|
... | ... | |
233 | 243 |
return this; |
234 | 244 |
} |
235 | 245 |
|
246 |
/** |
|
247 |
* Adds a single {@link TaxonNode} to the filter.<BR><BR> |
|
248 |
* NOTE: this adds only the node to the filter, not it's children! |
|
249 |
*/ |
|
236 | 250 |
public TaxonNodeFilter orTaxonNode(TaxonNode taxonNode){ |
237 | 251 |
taxonNodes.add( new LogicFilter<>(taxonNode, Op.OR)); |
238 | 252 |
return this; |
239 | 253 |
} |
254 |
/** |
|
255 |
* Adds a single {@link TaxonNode} to the filter.<BR><BR> |
|
256 |
* NOTE: this adds only the node to the filter, not it's children! |
|
257 |
*/ |
|
240 | 258 |
public TaxonNodeFilter orTaxonNode(UUID uuid){ |
241 | 259 |
taxonNodes.add( new LogicFilter<>(TaxonNode.class, uuid, Op.OR)); |
242 | 260 |
return this; |
... | ... | |
246 | 264 |
taxonNodes.add( new LogicFilter<>(taxonNode, Op.NOT)); |
247 | 265 |
return this; |
248 | 266 |
} |
249 |
|
|
250 | 267 |
public TaxonNodeFilter andTaxonNode(TaxonNode taxonNode){ |
251 | 268 |
taxonNodes.add(new LogicFilter<>(taxonNode, Op.AND)); |
252 | 269 |
return this; |
... | ... | |
266 | 283 |
areaFilter.add( new LogicFilter<>(NamedArea.class, uuid, Op.OR)); |
267 | 284 |
return this; |
268 | 285 |
} |
286 |
public TaxonNodeFilter orArea(NamedArea area){ |
|
287 |
areaFilter.add( new LogicFilter<>(area, Op.OR)); |
|
288 |
return this; |
|
289 |
} |
|
269 | 290 |
|
270 | 291 |
public TaxonNodeFilter andArea(UUID uuid){ |
271 | 292 |
areaFilter.add( new LogicFilter<>(NamedArea.class, uuid, Op.AND)); |
272 | 293 |
return this; |
273 | 294 |
} |
295 |
public TaxonNodeFilter andArea(NamedArea area){ |
|
296 |
areaFilter.add( new LogicFilter<>(area, Op.AND)); |
|
297 |
return this; |
|
298 |
} |
|
274 | 299 |
|
275 |
public TaxonNodeFilter orRank(Rank rankMin, Rank rankMax){ |
|
276 |
if(rankMin!=null){
|
|
277 |
this.rankMin = new LogicFilter<Rank>(rankMin);
|
|
278 |
}
|
|
279 |
if(rankMax!=null){
|
|
280 |
this.rankMax = new LogicFilter<>(rankMax);
|
|
281 |
}
|
|
300 |
|
|
301 |
public TaxonNodeFilter setRankMin(Rank rankMin){
|
|
302 |
this.rankMin = rankMin == null? null : new LogicFilter<>(rankMin, Op.AND);
|
|
303 |
return this;
|
|
304 |
}
|
|
305 |
public TaxonNodeFilter setRankMin(UUID rankMinUuid){
|
|
306 |
this.rankMin = rankMinUuid == null? null : new LogicFilter<>(Rank.class, rankMinUuid, Op.AND);
|
|
282 | 307 |
return this; |
283 | 308 |
} |
284 | 309 |
|
285 |
public TaxonNodeFilter andRank(Rank rankMin, Rank rankMax){ |
|
286 |
if(rankMin!=null){ |
|
287 |
this.rankMin = new LogicFilter<Rank>(rankMin, Op.AND); |
|
288 |
} |
|
289 |
if(rankMax!=null){ |
|
290 |
this.rankMax = new LogicFilter<>(rankMax, Op.AND); |
|
291 |
} |
|
310 |
public TaxonNodeFilter setRankMax(Rank rankMax){ |
|
311 |
this.rankMax = rankMax == null? null : new LogicFilter<>(rankMax, Op.AND); |
|
312 |
return this; |
|
313 |
} |
|
314 |
public TaxonNodeFilter setRankMax(UUID rankMaxUuid){ |
|
315 |
this.rankMax = rankMaxUuid == null? null : new LogicFilter<>(Rank.class, rankMaxUuid, Op.AND); |
|
292 | 316 |
return this; |
293 | 317 |
} |
294 | 318 |
|
... | ... | |
306 | 330 |
return this; |
307 | 331 |
} |
308 | 332 |
|
333 |
public LogicFilter<Rank> getRankMax() { |
|
334 |
return rankMax; |
|
335 |
} |
|
336 |
public LogicFilter<Rank> getRankMin() { |
|
337 |
return rankMin; |
|
338 |
} |
|
339 |
|
|
340 |
public boolean isIncludeUnpublished() { |
|
341 |
return includeUnpublished; |
|
342 |
} |
|
343 |
public void setIncludeUnpublished(boolean includeUnpublished) { |
|
344 |
this.includeUnpublished = includeUnpublished; |
|
345 |
} |
|
346 |
|
|
347 |
|
|
348 |
/** |
|
349 |
* If <code>true</code> the result will include the root node of |
|
350 |
* a classification. |
|
351 |
* Note: As a root node per se has no taxon all filters with filter |
|
352 |
* on taxon related data have no effect for the root node. If the |
|
353 |
* root node is returned only depends on the |
|
354 |
* {@link TaxonNodeFilter#isIncludeRootNodes() includeRootNodes} |
|
355 |
* parameter. |
|
356 |
*/ |
|
309 | 357 |
public boolean isIncludeRootNodes() { |
310 | 358 |
return includeRootNodes; |
311 | 359 |
} |
... | ... | |
314 | 362 |
return this; |
315 | 363 |
} |
316 | 364 |
|
317 |
public LogicFilter<Rank> getRankMax() { |
|
318 |
return rankMax; |
|
319 |
} |
|
320 |
|
|
321 |
public LogicFilter<Rank> getRankMin() { |
|
322 |
return rankMin; |
|
323 |
} |
|
324 |
|
|
325 | 365 |
} |
Also available in: Unified diff
ref #7175, ref #7180, ref #7165, ref #7166 Adapting TaxonNodeFilter for unpublished, minMaxRank and areas